From 5896ecff40c0092c1ae91eb2ef6c880ba2527653 Mon Sep 17 00:00:00 2001 From: John Sirois Date: Wed, 24 Feb 2016 13:13:01 -0800 Subject: [PATCH] Update Godeps. This was a mechanical change: ``` make dep-restore godep update -goversion make dep-save ``` Signed-off-by: John Sirois --- Godeps/Godeps.json | 387 +- .../azure-sdk-for-go/core/http/cgi/child.go | 206 - .../core/http/cgi/child_test.go | 131 - .../azure-sdk-for-go/core/http/cgi/host.go | 377 -- .../core/http/cgi/host_test.go | 461 -- .../core/http/cgi/matryoshka_test.go | 228 - .../core/http/cgi/plan9_test.go | 18 - .../core/http/cgi/posix_test.go | 21 - .../core/http/chunked_test.go | 159 - .../azure-sdk-for-go/core/http/client_test.go | 1038 ----- .../azure-sdk-for-go/core/http/cookie_test.go | 380 -- .../core/http/cookiejar/jar.go | 497 --- .../core/http/cookiejar/jar_test.go | 1267 ------ .../core/http/cookiejar/punycode.go | 159 - .../core/http/cookiejar/punycode_test.go | 161 - .../core/http/example_test.go | 88 - .../azure-sdk-for-go/core/http/export_test.go | 72 - .../azure-sdk-for-go/core/http/fcgi/child.go | 305 -- .../azure-sdk-for-go/core/http/fcgi/fcgi.go | 274 -- .../core/http/fcgi/fcgi_test.go | 150 - .../core/http/filetransport_test.go | 65 - .../azure-sdk-for-go/core/http/fs_test.go | 858 ---- .../azure-sdk-for-go/core/http/header_test.go | 212 - .../core/http/httptest/example_test.go | 50 - .../core/http/httptest/recorder.go | 72 - .../core/http/httptest/recorder_test.go | 90 - .../core/http/httptest/server.go | 228 - .../core/http/httptest/server_test.go | 52 - .../core/http/httputil/chunked.go | 203 - .../core/http/httputil/chunked_test.go | 159 - .../core/http/httputil/dump.go | 276 -- .../core/http/httputil/dump_test.go | 263 -- .../core/http/httputil/httputil.go | 32 - .../core/http/httputil/persist.go | 429 -- .../core/http/httputil/reverseproxy.go | 211 - .../core/http/httputil/reverseproxy_test.go | 213 - .../azure-sdk-for-go/core/http/lex_test.go | 31 - .../azure-sdk-for-go/core/http/npn_test.go | 118 - .../azure-sdk-for-go/core/http/pprof/pprof.go | 205 - .../azure-sdk-for-go/core/http/proxy_test.go | 81 - .../azure-sdk-for-go/core/http/range_test.go | 79 - .../core/http/readrequest_test.go | 331 -- .../core/http/request_test.go | 610 --- .../core/http/requestwrite_test.go | 565 --- .../core/http/response_test.go | 645 --- .../core/http/responsewrite_test.go | 226 - .../azure-sdk-for-go/core/http/serve_test.go | 2848 ------------- .../azure-sdk-for-go/core/http/sniff_test.go | 171 - .../core/http/transfer_test.go | 64 - .../core/http/transport_test.go | 2173 ---------- .../azure-sdk-for-go/core/http/z_last_test.go | 97 - .../azure-sdk-for-go/core/tls/conn_test.go | 106 - .../core/tls/handshake_client_test.go | 3050 ------------- .../core/tls/handshake_messages_test.go | 246 -- .../core/tls/handshake_server_test.go | 3796 ----------------- .../azure-sdk-for-go/core/tls/prf_test.go | 126 - .../azure-sdk-for-go/core/tls/tls_test.go | 107 - .../stscreds/assume_role_provider.go | 130 - .../docker/docker/pkg/units/MAINTAINERS | 2 - .../docker/docker/pkg/units/duration.go | 31 - .../docker/docker/pkg/units/size.go | 91 - vendor/github.com/golang/protobuf/LICENSE | 31 + .../github.com/golang/protobuf/proto/Makefile | 43 + .../github.com/golang/protobuf/proto/clone.go | 223 + .../golang/protobuf/proto/decode.go | 867 ++++ .../golang/protobuf/proto/encode.go | 1325 ++++++ .../github.com/golang/protobuf/proto/equal.go | 276 ++ .../golang/protobuf/proto/extensions.go | 399 ++ .../github.com/golang/protobuf/proto/lib.go | 894 ++++ .../golang/protobuf/proto/message_set.go | 280 ++ .../golang/protobuf/proto/pointer_reflect.go | 479 +++ .../golang/protobuf/proto/pointer_unsafe.go | 266 ++ .../golang/protobuf/proto/properties.go | 846 ++++ .../github.com/golang/protobuf/proto/text.go | 762 ++++ .../golang/protobuf/proto/text_parser.go | 806 ++++ .../blockstorage/v1/apiversions/doc.go | 3 - .../blockstorage/v1/apiversions/requests.go | 21 - .../blockstorage/v1/apiversions/results.go | 58 - .../blockstorage/v1/apiversions/urls.go | 15 - .../blockstorage/v1/snapshots/doc.go | 5 - .../blockstorage/v1/snapshots/fixtures.go | 114 - .../blockstorage/v1/snapshots/requests.go | 173 - .../blockstorage/v1/snapshots/results.go | 123 - .../blockstorage/v1/snapshots/urls.go | 27 - .../blockstorage/v1/snapshots/util.go | 22 - .../openstack/blockstorage/v1/volumes/doc.go | 5 - .../blockstorage/v1/volumes/fixtures.go | 113 - .../blockstorage/v1/volumes/requests.go | 203 - .../blockstorage/v1/volumes/results.go | 113 - .../openstack/blockstorage/v1/volumes/urls.go | 23 - .../openstack/blockstorage/v1/volumes/util.go | 22 - .../blockstorage/v1/volumetypes/doc.go | 9 - .../blockstorage/v1/volumetypes/fixtures.go | 60 - .../blockstorage/v1/volumetypes/requests.go | 76 - .../blockstorage/v1/volumetypes/results.go | 72 - .../blockstorage/v1/volumetypes/urls.go | 19 - .../gophercloud/openstack/cdn/v1/base/doc.go | 4 - .../openstack/cdn/v1/base/fixtures.go | 53 - .../openstack/cdn/v1/base/requests.go | 21 - .../openstack/cdn/v1/base/results.go | 35 - .../gophercloud/openstack/cdn/v1/base/urls.go | 11 - .../openstack/cdn/v1/flavors/doc.go | 6 - .../openstack/cdn/v1/flavors/fixtures.go | 82 - .../openstack/cdn/v1/flavors/requests.go | 22 - .../openstack/cdn/v1/flavors/results.go | 71 - .../openstack/cdn/v1/flavors/urls.go | 11 - .../openstack/cdn/v1/serviceassets/doc.go | 7 - .../cdn/v1/serviceassets/fixtures.go | 19 - .../cdn/v1/serviceassets/requests.go | 48 - .../openstack/cdn/v1/serviceassets/results.go | 8 - .../openstack/cdn/v1/serviceassets/urls.go | 7 - .../openstack/cdn/v1/services/doc.go | 7 - .../openstack/cdn/v1/services/errors.go | 7 - .../openstack/cdn/v1/services/fixtures.go | 372 -- .../openstack/cdn/v1/services/requests.go | 378 -- .../openstack/cdn/v1/services/results.go | 316 -- .../openstack/cdn/v1/services/urls.go | 23 - .../gophercloud/openstack/common/README.md | 3 - .../openstack/common/extensions/doc.go | 15 - .../openstack/common/extensions/errors.go | 1 - .../openstack/common/extensions/fixtures.go | 91 - .../openstack/common/extensions/requests.go | 21 - .../openstack/common/extensions/results.go | 65 - .../openstack/common/extensions/urls.go | 13 - .../v2/extensions/bootfromvolume/requests.go | 106 - .../v2/extensions/bootfromvolume/results.go | 10 - .../v2/extensions/bootfromvolume/urls.go | 7 - .../compute/v2/extensions/defsecrules/doc.go | 1 - .../v2/extensions/defsecrules/fixtures.go | 108 - .../v2/extensions/defsecrules/requests.go | 95 - .../v2/extensions/defsecrules/results.go | 69 - .../compute/v2/extensions/defsecrules/urls.go | 13 - .../compute/v2/extensions/delegate.go | 23 - .../compute/v2/extensions/diskconfig/doc.go | 3 - .../v2/extensions/diskconfig/requests.go | 114 - .../v2/extensions/diskconfig/results.go | 60 - .../openstack/compute/v2/extensions/doc.go | 3 - .../compute/v2/extensions/secgroups/doc.go | 1 - .../v2/extensions/secgroups/fixtures.go | 265 -- .../v2/extensions/secgroups/requests.go | 257 -- .../v2/extensions/secgroups/results.go | 147 - .../compute/v2/extensions/secgroups/urls.go | 32 - .../v2/extensions/tenantnetworks/doc.go | 2 - .../v2/extensions/tenantnetworks/fixtures.go | 84 - .../v2/extensions/tenantnetworks/requests.go | 22 - .../v2/extensions/tenantnetworks/results.go | 68 - .../v2/extensions/tenantnetworks/urls.go | 17 - .../compute/v2/extensions/volumeattach/doc.go | 3 - .../v2/extensions/volumeattach/fixtures.go | 138 - .../v2/extensions/volumeattach/requests.go | 75 - .../v2/extensions/volumeattach/results.go | 84 - .../v2/extensions/volumeattach/urls.go | 25 - .../v2/extensions/admin/roles/docs.go | 16 - .../v2/extensions/admin/roles/fixtures.go | 48 - .../v2/extensions/admin/roles/requests.go | 33 - .../v2/extensions/admin/roles/results.go | 53 - .../v2/extensions/admin/roles/urls.go | 21 - .../identity/v2/extensions/delegate.go | 52 - .../openstack/identity/v2/extensions/doc.go | 3 - .../identity/v2/extensions/fixtures.go | 60 - .../openstack/identity/v2/users/doc.go | 1 - .../openstack/identity/v2/users/fixtures.go | 163 - .../openstack/identity/v2/users/requests.go | 161 - .../openstack/identity/v2/users/results.go | 128 - .../openstack/identity/v2/users/urls.go | 21 - .../openstack/identity/v3/endpoints/doc.go | 6 - .../openstack/identity/v3/endpoints/errors.go | 21 - .../identity/v3/endpoints/requests.go | 123 - .../identity/v3/endpoints/results.go | 82 - .../openstack/identity/v3/endpoints/urls.go | 11 - .../openstack/identity/v3/services/doc.go | 3 - .../identity/v3/services/requests.go | 77 - .../openstack/identity/v3/services/results.go | 80 - .../openstack/identity/v3/services/urls.go | 11 - .../networking/v2/apiversions/doc.go | 4 - .../networking/v2/apiversions/errors.go | 1 - .../networking/v2/apiversions/requests.go | 21 - .../networking/v2/apiversions/results.go | 77 - .../networking/v2/apiversions/urls.go | 15 - .../networking/v2/common/common_tests.go | 14 - .../networking/v2/extensions/delegate.go | 41 - .../networking/v2/extensions/external/doc.go | 3 - .../v2/extensions/external/requests.go | 69 - .../v2/extensions/external/results.go | 81 - .../networking/v2/extensions/fwaas/doc.go | 3 - .../v2/extensions/fwaas/firewalls/errors.go | 11 - .../v2/extensions/fwaas/firewalls/requests.go | 216 - .../v2/extensions/fwaas/firewalls/results.go | 101 - .../v2/extensions/fwaas/firewalls/urls.go | 16 - .../v2/extensions/fwaas/policies/requests.go | 243 -- .../v2/extensions/fwaas/policies/results.go | 101 - .../v2/extensions/fwaas/policies/urls.go | 26 - .../v2/extensions/fwaas/rules/errors.go | 12 - .../v2/extensions/fwaas/rules/requests.go | 285 -- .../v2/extensions/fwaas/rules/results.go | 110 - .../v2/extensions/fwaas/rules/urls.go | 16 - .../networking/v2/extensions/layer3/doc.go | 5 - .../v2/extensions/layer3/routers/requests.go | 224 - .../v2/extensions/layer3/routers/results.go | 161 - .../v2/extensions/layer3/routers/urls.go | 21 - .../networking/v2/extensions/lbaas/doc.go | 3 - .../v2/extensions/lbaas/members/requests.go | 123 - .../v2/extensions/lbaas/members/results.go | 122 - .../v2/extensions/lbaas/members/urls.go | 16 - .../v2/extensions/lbaas/monitors/requests.go | 265 -- .../v2/extensions/lbaas/monitors/results.go | 147 - .../v2/extensions/lbaas/monitors/urls.go | 16 - .../v2/extensions/lbaas/pools/requests.go | 181 - .../v2/extensions/lbaas/pools/results.go | 146 - .../v2/extensions/lbaas/pools/urls.go | 25 - .../v2/extensions/lbaas/vips/requests.go | 256 -- .../v2/extensions/lbaas/vips/results.go | 166 - .../v2/extensions/lbaas/vips/urls.go | 16 - .../networking/v2/extensions/provider/doc.go | 21 - .../v2/extensions/provider/results.go | 124 - .../networking/v2/extensions/security/doc.go | 32 - .../v2/extensions/security/groups/requests.go | 93 - .../v2/extensions/security/groups/results.go | 108 - .../v2/extensions/security/groups/urls.go | 13 - .../v2/extensions/security/rules/requests.go | 169 - .../v2/extensions/security/rules/results.go | 133 - .../v2/extensions/security/rules/urls.go | 13 - .../openstack/networking/v2/subnets/doc.go | 10 - .../openstack/networking/v2/subnets/errors.go | 13 - .../networking/v2/subnets/requests.go | 236 - .../networking/v2/subnets/results.go | 132 - .../openstack/networking/v2/subnets/urls.go | 31 - .../objectstorage/v1/accounts/doc.go | 8 - .../objectstorage/v1/accounts/fixtures.go | 38 - .../objectstorage/v1/accounts/requests.go | 103 - .../objectstorage/v1/accounts/results.go | 102 - .../objectstorage/v1/accounts/urls.go | 11 - .../objectstorage/v1/containers/doc.go | 8 - .../objectstorage/v1/containers/fixtures.go | 143 - .../objectstorage/v1/containers/requests.go | 199 - .../objectstorage/v1/containers/results.go | 270 -- .../objectstorage/v1/containers/urls.go | 23 - .../openstack/objectstorage/v1/objects/doc.go | 5 - .../objectstorage/v1/objects/fixtures.go | 182 - .../objectstorage/v1/objects/requests.go | 464 -- .../objectstorage/v1/objects/results.go | 438 -- .../objectstorage/v1/objects/urls.go | 33 - .../orchestration/v1/apiversions/doc.go | 4 - .../orchestration/v1/apiversions/requests.go | 13 - .../orchestration/v1/apiversions/results.go | 42 - .../orchestration/v1/apiversions/urls.go | 7 - .../orchestration/v1/buildinfo/doc.go | 2 - .../orchestration/v1/buildinfo/fixtures.go | 45 - .../orchestration/v1/buildinfo/requests.go | 10 - .../orchestration/v1/buildinfo/results.go | 37 - .../orchestration/v1/buildinfo/urls.go | 7 - .../orchestration/v1/stackevents/doc.go | 4 - .../orchestration/v1/stackevents/fixtures.go | 446 -- .../orchestration/v1/stackevents/requests.go | 203 - .../orchestration/v1/stackevents/results.go | 172 - .../orchestration/v1/stackevents/urls.go | 19 - .../orchestration/v1/stackresources/doc.go | 5 - .../v1/stackresources/fixtures.go | 451 -- .../v1/stackresources/requests.go | 121 - .../v1/stackresources/results.go | 260 -- .../orchestration/v1/stackresources/urls.go | 31 - .../openstack/orchestration/v1/stacks/doc.go | 8 - .../orchestration/v1/stacks/fixtures.go | 374 -- .../orchestration/v1/stacks/requests.go | 493 --- .../orchestration/v1/stacks/results.go | 309 -- .../openstack/orchestration/v1/stacks/urls.go | 35 - .../orchestration/v1/stacktemplates/doc.go | 8 - .../v1/stacktemplates/fixtures.go | 118 - .../v1/stacktemplates/requests.go | 58 - .../v1/stacktemplates/results.go | 60 - .../orchestration/v1/stacktemplates/urls.go | 11 - .../blockstorage/v1/snapshots/delegate.go | 131 - .../blockstorage/v1/snapshots/doc.go | 3 - .../blockstorage/v1/snapshots/results.go | 147 - .../blockstorage/v1/volumes/delegate.go | 75 - .../rackspace/blockstorage/v1/volumes/doc.go | 3 - .../blockstorage/v1/volumes/results.go | 66 - .../blockstorage/v1/volumetypes/delegate.go | 18 - .../blockstorage/v1/volumetypes/doc.go | 3 - .../blockstorage/v1/volumetypes/results.go | 37 - .../rackspace/cdn/v1/base/delegate.go | 18 - .../gophercloud/rackspace/cdn/v1/base/doc.go | 4 - .../rackspace/cdn/v1/flavors/delegate.go | 18 - .../rackspace/cdn/v1/flavors/doc.go | 6 - .../cdn/v1/serviceassets/delegate.go | 13 - .../rackspace/cdn/v1/serviceassets/doc.go | 7 - .../rackspace/cdn/v1/services/delegate.go | 37 - .../rackspace/cdn/v1/services/doc.go | 7 - .../compute/v2/bootfromvolume/delegate.go | 12 - .../rackspace/compute/v2/flavors/delegate.go | 46 - .../rackspace/compute/v2/flavors/doc.go | 3 - .../rackspace/compute/v2/flavors/fixtures.go | 129 - .../rackspace/compute/v2/images/delegate.go | 22 - .../rackspace/compute/v2/images/doc.go | 3 - .../rackspace/compute/v2/images/fixtures.go | 200 - .../rackspace/compute/v2/keypairs/delegate.go | 33 - .../rackspace/compute/v2/keypairs/doc.go | 3 - .../rackspace/compute/v2/networks/doc.go | 3 - .../rackspace/compute/v2/networks/requests.go | 89 - .../rackspace/compute/v2/networks/results.go | 81 - .../rackspace/compute/v2/networks/urls.go | 27 - .../rackspace/compute/v2/servers/delegate.go | 116 - .../rackspace/compute/v2/servers/doc.go | 3 - .../rackspace/compute/v2/servers/fixtures.go | 574 --- .../rackspace/compute/v2/servers/requests.go | 163 - .../compute/v2/virtualinterfaces/requests.go | 45 - .../compute/v2/virtualinterfaces/results.go | 81 - .../compute/v2/virtualinterfaces/urls.go | 15 - .../compute/v2/volumeattach/delegate.go | 27 - .../rackspace/compute/v2/volumeattach/doc.go | 3 - .../identity/v2/extensions/delegate.go | 24 - .../rackspace/identity/v2/extensions/doc.go | 3 - .../rackspace/identity/v2/roles/delegate.go | 50 - .../rackspace/identity/v2/roles/fixtures.go | 49 - .../rackspace/identity/v2/tenants/delegate.go | 17 - .../rackspace/identity/v2/tenants/doc.go | 3 - .../rackspace/identity/v2/users/delegate.go | 142 - .../rackspace/identity/v2/users/fixtures.go | 154 - .../rackspace/identity/v2/users/results.go | 129 - .../rackspace/identity/v2/users/urls.go | 7 - .../gophercloud/rackspace/lb/v1/acl/doc.go | 12 - .../rackspace/lb/v1/acl/fixtures.go | 109 - .../rackspace/lb/v1/acl/requests.go | 111 - .../rackspace/lb/v1/acl/results.go | 72 - .../gophercloud/rackspace/lb/v1/acl/urls.go | 20 - .../gophercloud/rackspace/lb/v1/lbs/doc.go | 44 - .../rackspace/lb/v1/lbs/fixtures.go | 584 --- .../rackspace/lb/v1/lbs/requests.go | 497 --- .../rackspace/lb/v1/lbs/results.go | 420 -- .../gophercloud/rackspace/lb/v1/lbs/urls.go | 49 - .../rackspace/lb/v1/monitors/doc.go | 21 - .../rackspace/lb/v1/monitors/fixtures.go | 87 - .../rackspace/lb/v1/monitors/requests.go | 160 - .../rackspace/lb/v1/monitors/results.go | 90 - .../rackspace/lb/v1/monitors/urls.go | 16 - .../gophercloud/rackspace/lb/v1/nodes/doc.go | 35 - .../rackspace/lb/v1/nodes/fixtures.go | 207 - .../rackspace/lb/v1/nodes/requests.go | 256 -- .../rackspace/lb/v1/nodes/results.go | 210 - .../gophercloud/rackspace/lb/v1/nodes/urls.go | 25 - .../rackspace/lb/v1/sessions/doc.go | 30 - .../rackspace/lb/v1/sessions/fixtures.go | 58 - .../rackspace/lb/v1/sessions/requests.go | 63 - .../rackspace/lb/v1/sessions/results.go | 58 - .../rackspace/lb/v1/sessions/urls.go | 16 - .../gophercloud/rackspace/lb/v1/ssl/doc.go | 22 - .../rackspace/lb/v1/ssl/fixtures.go | 195 - .../rackspace/lb/v1/ssl/requests.go | 247 -- .../rackspace/lb/v1/ssl/results.go | 148 - .../gophercloud/rackspace/lb/v1/ssl/urls.go | 25 - .../rackspace/lb/v1/throttle/doc.go | 5 - .../rackspace/lb/v1/throttle/fixtures.go | 61 - .../rackspace/lb/v1/throttle/requests.go | 76 - .../rackspace/lb/v1/throttle/results.go | 43 - .../rackspace/lb/v1/throttle/urls.go | 16 - .../gophercloud/rackspace/lb/v1/vips/doc.go | 13 - .../rackspace/lb/v1/vips/fixtures.go | 88 - .../rackspace/lb/v1/vips/requests.go | 97 - .../rackspace/lb/v1/vips/results.go | 89 - .../gophercloud/rackspace/lb/v1/vips/urls.go | 20 - .../networking/v2/common/common_tests.go | 12 - .../networking/v2/networks/delegate.go | 41 - .../rackspace/networking/v2/ports/delegate.go | 43 - .../rackspace/networking/v2/security/doc.go | 32 - .../networking/v2/security/groups/delegate.go | 30 - .../networking/v2/security/rules/delegate.go | 30 - .../networking/v2/subnets/delegate.go | 40 - .../objectstorage/v1/accounts/delegate.go | 39 - .../objectstorage/v1/accounts/doc.go | 3 - .../rackspace/objectstorage/v1/bulk/doc.go | 3 - .../objectstorage/v1/bulk/requests.go | 49 - .../objectstorage/v1/bulk/results.go | 28 - .../rackspace/objectstorage/v1/bulk/urls.go | 11 - .../v1/cdncontainers/delegate.go | 38 - .../objectstorage/v1/cdncontainers/doc.go | 3 - .../v1/cdncontainers/requests.go | 155 - .../objectstorage/v1/cdncontainers/results.go | 149 - .../objectstorage/v1/cdncontainers/urls.go | 15 - .../objectstorage/v1/cdnobjects/delegate.go | 11 - .../objectstorage/v1/cdnobjects/doc.go | 3 - .../objectstorage/v1/cdnobjects/request.go | 15 - .../objectstorage/v1/containers/delegate.go | 93 - .../objectstorage/v1/containers/doc.go | 3 - .../objectstorage/v1/objects/delegate.go | 94 - .../rackspace/objectstorage/v1/objects/doc.go | 3 - .../orchestration/v1/buildinfo/delegate.go | 11 - .../orchestration/v1/buildinfo/doc.go | 2 - .../orchestration/v1/stackevents/delegate.go | 27 - .../orchestration/v1/stackevents/doc.go | 3 - .../v1/stackresources/delegate.go | 42 - .../orchestration/v1/stackresources/doc.go | 5 - .../orchestration/v1/stacks/delegate.go | 49 - .../rackspace/orchestration/v1/stacks/doc.go | 8 - .../orchestration/v1/stacks/fixtures.go | 32 - .../v1/stacktemplates/delegate.go | 16 - .../orchestration/v1/stacktemplates/doc.go | 8 - .../rackconnect/v3/cloudnetworks/requests.go | 24 - .../rackconnect/v3/cloudnetworks/results.go | 113 - .../rackconnect/v3/cloudnetworks/urls.go | 11 - .../rackspace/rackconnect/v3/doc.go | 4 - .../rackspace/rackconnect/v3/lbpools/doc.go | 14 - .../rackconnect/v3/lbpools/requests.go | 146 - .../rackconnect/v3/lbpools/results.go | 505 --- .../rackspace/rackconnect/v3/lbpools/urls.go | 49 - .../rackconnect/v3/publicips/requests.go | 50 - .../rackconnect/v3/publicips/results.go | 221 - .../rackconnect/v3/publicips/urls.go | 25 - .../mo/fixtures/cluster_host_property.xml | 15 - .../hostsystem_list_name_property.xml | 17 - .../vim25/mo/fixtures/nested_property.xml | 14 - .../mo/fixtures/not_authenticated_fault.xml | 42 - .../vim25/mo/fixtures/pointer_property.xml | 15 - .../google.golang.org/appengine/.travis.yml | 18 + vendor/google.golang.org/appengine/LICENSE | 202 + vendor/google.golang.org/appengine/README.md | 73 + .../google.golang.org/appengine/appengine.go | 76 + .../appengine/appengine_vm.go | 56 + vendor/google.golang.org/appengine/errors.go | 46 + .../google.golang.org/appengine/identity.go | 142 + .../appengine/internal/api.go | 640 +++ .../appengine/internal/api_classic.go | 133 + .../appengine/internal/api_common.go | 101 + .../appengine/internal/app_id.go | 28 + .../app_identity/app_identity_service.pb.go | 296 ++ .../app_identity/app_identity_service.proto | 64 + .../appengine/internal/base/api_base.pb.go | 133 + .../appengine/internal/base/api_base.proto | 33 + .../internal/datastore/datastore_v3.pb.go | 2778 ++++++++++++ .../internal/datastore/datastore_v3.proto | 541 +++ .../appengine/internal/identity.go | 14 + .../appengine/internal/identity_classic.go | 27 + .../appengine/internal/identity_vm.go | 97 + .../appengine/internal/internal.go | 144 + .../appengine/internal/log/log_service.pb.go | 899 ++++ .../appengine/internal/log/log_service.proto | 150 + .../appengine/internal/metadata.go | 61 + .../internal/modules/modules_service.pb.go | 375 ++ .../internal/modules/modules_service.proto | 80 + .../appengine/internal/net.go | 56 + .../appengine/internal/regen.sh | 40 + .../internal/remote_api/remote_api.pb.go | 231 + .../internal/remote_api/remote_api.proto | 44 + .../appengine/internal/transaction.go | 107 + .../google.golang.org/appengine/namespace.go | 25 + vendor/google.golang.org/appengine/timeout.go | 20 + 445 files changed, 15585 insertions(+), 50884 deletions(-) delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/child.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/child_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/host.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/host_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/matryoshka_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/plan9_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/posix_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/chunked_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/client_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cookie_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cookiejar/jar.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cookiejar/jar_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cookiejar/punycode.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cookiejar/punycode_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/example_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/export_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/fcgi/child.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/fcgi/fcgi.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/fcgi/fcgi_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/filetransport_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/fs_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/header_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httptest/example_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httptest/recorder.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httptest/recorder_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httptest/server.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httptest/server_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/chunked.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/chunked_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/dump.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/dump_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/httputil.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/persist.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/reverseproxy.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/reverseproxy_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/lex_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/npn_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/pprof/pprof.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/proxy_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/range_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/readrequest_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/request_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/requestwrite_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/response_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/responsewrite_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/serve_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/sniff_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/transfer_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/transport_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/z_last_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/conn_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/handshake_client_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/handshake_messages_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/handshake_server_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/prf_test.go delete mode 100644 vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/tls_test.go delete mode 100644 vendor/github.com/aws/aws-sdk-go/aws/credentials/stscreds/assume_role_provider.go delete mode 100644 vendor/github.com/docker/docker/pkg/units/MAINTAINERS delete mode 100644 vendor/github.com/docker/docker/pkg/units/duration.go delete mode 100644 vendor/github.com/docker/docker/pkg/units/size.go create mode 100644 vendor/github.com/golang/protobuf/LICENSE create mode 100644 vendor/github.com/golang/protobuf/proto/Makefile create mode 100644 vendor/github.com/golang/protobuf/proto/clone.go create mode 100644 vendor/github.com/golang/protobuf/proto/decode.go create mode 100644 vendor/github.com/golang/protobuf/proto/encode.go create mode 100644 vendor/github.com/golang/protobuf/proto/equal.go create mode 100644 vendor/github.com/golang/protobuf/proto/extensions.go create mode 100644 vendor/github.com/golang/protobuf/proto/lib.go create mode 100644 vendor/github.com/golang/protobuf/proto/message_set.go create mode 100644 vendor/github.com/golang/protobuf/proto/pointer_reflect.go create mode 100644 vendor/github.com/golang/protobuf/proto/pointer_unsafe.go create mode 100644 vendor/github.com/golang/protobuf/proto/properties.go create mode 100644 vendor/github.com/golang/protobuf/proto/text.go create mode 100644 vendor/github.com/golang/protobuf/proto/text_parser.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/apiversions/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/apiversions/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/apiversions/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/apiversions/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/util.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/util.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/base/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/base/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/base/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/base/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/base/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/flavors/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/flavors/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/flavors/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/flavors/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/flavors/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/errors.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/common/README.md delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/common/extensions/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/common/extensions/errors.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/common/extensions/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/common/extensions/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/common/extensions/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/common/extensions/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/defsecrules/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/defsecrules/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/defsecrules/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/defsecrules/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/defsecrules/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/diskconfig/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/diskconfig/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/diskconfig/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/admin/roles/docs.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/admin/roles/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/admin/roles/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/admin/roles/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/admin/roles/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/identity/v3/endpoints/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/identity/v3/endpoints/errors.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/identity/v3/endpoints/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/identity/v3/endpoints/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/identity/v3/endpoints/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/identity/v3/services/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/identity/v3/services/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/identity/v3/services/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/identity/v3/services/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/apiversions/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/apiversions/errors.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/apiversions/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/apiversions/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/apiversions/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/common/common_tests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/external/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/external/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/external/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls/errors.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules/errors.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/members/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/members/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/members/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/monitors/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/monitors/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/monitors/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/pools/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/pools/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/pools/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/vips/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/vips/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/vips/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/provider/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/provider/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/groups/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/groups/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/groups/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/rules/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/rules/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/rules/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/errors.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/apiversions/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/apiversions/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/apiversions/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/apiversions/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackevents/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackevents/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackevents/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackevents/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackevents/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackresources/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackresources/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackresources/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackresources/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackresources/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/snapshots/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/snapshots/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/snapshots/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumes/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumes/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumes/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumetypes/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumetypes/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumetypes/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/base/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/base/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/flavors/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/flavors/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/serviceassets/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/serviceassets/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/services/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/services/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/bootfromvolume/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/flavors/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/flavors/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/flavors/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/images/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/images/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/images/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/keypairs/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/keypairs/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/networks/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/networks/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/networks/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/networks/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/servers/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/servers/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/servers/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/servers/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/virtualinterfaces/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/virtualinterfaces/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/virtualinterfaces/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/volumeattach/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/volumeattach/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/extensions/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/extensions/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/roles/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/roles/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/tenants/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/tenants/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/users/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/users/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/users/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/users/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/acl/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/acl/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/acl/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/acl/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/acl/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/lbs/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/lbs/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/lbs/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/lbs/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/lbs/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/monitors/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/monitors/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/monitors/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/monitors/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/monitors/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/nodes/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/nodes/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/nodes/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/nodes/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/nodes/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/sessions/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/sessions/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/sessions/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/sessions/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/sessions/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/ssl/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/ssl/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/ssl/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/ssl/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/ssl/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/throttle/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/throttle/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/throttle/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/throttle/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/throttle/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/vips/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/vips/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/vips/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/vips/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/vips/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/common/common_tests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/networks/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/ports/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/security/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/security/groups/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/security/rules/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/subnets/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/accounts/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/accounts/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/bulk/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/bulk/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/bulk/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/bulk/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdnobjects/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdnobjects/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdnobjects/request.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/containers/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/containers/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/objects/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/objects/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/buildinfo/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/buildinfo/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stackevents/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stackevents/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stackresources/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stackresources/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stacks/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stacks/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stacks/fixtures.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stacktemplates/delegate.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stacktemplates/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/cloudnetworks/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/cloudnetworks/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/cloudnetworks/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/lbpools/doc.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/lbpools/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/lbpools/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/lbpools/urls.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/publicips/requests.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/publicips/results.go delete mode 100644 vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/publicips/urls.go delete mode 100644 vendor/github.com/vmware/govmomi/vim25/mo/fixtures/cluster_host_property.xml delete mode 100644 vendor/github.com/vmware/govmomi/vim25/mo/fixtures/hostsystem_list_name_property.xml delete mode 100644 vendor/github.com/vmware/govmomi/vim25/mo/fixtures/nested_property.xml delete mode 100644 vendor/github.com/vmware/govmomi/vim25/mo/fixtures/not_authenticated_fault.xml delete mode 100644 vendor/github.com/vmware/govmomi/vim25/mo/fixtures/pointer_property.xml create mode 100644 vendor/google.golang.org/appengine/.travis.yml create mode 100644 vendor/google.golang.org/appengine/LICENSE create mode 100644 vendor/google.golang.org/appengine/README.md create mode 100644 vendor/google.golang.org/appengine/appengine.go create mode 100644 vendor/google.golang.org/appengine/appengine_vm.go create mode 100644 vendor/google.golang.org/appengine/errors.go create mode 100644 vendor/google.golang.org/appengine/identity.go create mode 100644 vendor/google.golang.org/appengine/internal/api.go create mode 100644 vendor/google.golang.org/appengine/internal/api_classic.go create mode 100644 vendor/google.golang.org/appengine/internal/api_common.go create mode 100644 vendor/google.golang.org/appengine/internal/app_id.go create mode 100644 vendor/google.golang.org/appengine/internal/app_identity/app_identity_service.pb.go create mode 100644 vendor/google.golang.org/appengine/internal/app_identity/app_identity_service.proto create mode 100644 vendor/google.golang.org/appengine/internal/base/api_base.pb.go create mode 100644 vendor/google.golang.org/appengine/internal/base/api_base.proto create mode 100644 vendor/google.golang.org/appengine/internal/datastore/datastore_v3.pb.go create mode 100644 vendor/google.golang.org/appengine/internal/datastore/datastore_v3.proto create mode 100644 vendor/google.golang.org/appengine/internal/identity.go create mode 100644 vendor/google.golang.org/appengine/internal/identity_classic.go create mode 100644 vendor/google.golang.org/appengine/internal/identity_vm.go create mode 100644 vendor/google.golang.org/appengine/internal/internal.go create mode 100644 vendor/google.golang.org/appengine/internal/log/log_service.pb.go create mode 100644 vendor/google.golang.org/appengine/internal/log/log_service.proto create mode 100644 vendor/google.golang.org/appengine/internal/metadata.go create mode 100644 vendor/google.golang.org/appengine/internal/modules/modules_service.pb.go create mode 100644 vendor/google.golang.org/appengine/internal/modules/modules_service.proto create mode 100644 vendor/google.golang.org/appengine/internal/net.go create mode 100644 vendor/google.golang.org/appengine/internal/regen.sh create mode 100644 vendor/google.golang.org/appengine/internal/remote_api/remote_api.pb.go create mode 100644 vendor/google.golang.org/appengine/internal/remote_api/remote_api.proto create mode 100644 vendor/google.golang.org/appengine/internal/transaction.go create mode 100644 vendor/google.golang.org/appengine/namespace.go create mode 100644 vendor/google.golang.org/appengine/timeout.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 1fd96a964d..ed2e6bc47f 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,6 +1,6 @@ { "ImportPath": "github.com/docker/machine", - "GoVersion": "go1.5", + "GoVersion": "go1.6", "Packages": [ "github.com/docker/machine", "github.com/docker/machine/cmd", @@ -24,12 +24,14 @@ "github.com/docker/machine/drivers/vmwarefusion", "github.com/docker/machine/drivers/vmwarevcloudair", "github.com/docker/machine/drivers/vmwarevsphere", - "github.com/docker/machine/drivers/vmwarevsphere/errors", + "github.com/docker/machine/its", + "github.com/docker/machine/its/cli", + "github.com/docker/machine/its/thirdparty", "github.com/docker/machine/libmachine", "github.com/docker/machine/libmachine/auth", - "github.com/docker/machine/libmachine/bugsnag", "github.com/docker/machine/libmachine/cert", "github.com/docker/machine/libmachine/check", + "github.com/docker/machine/libmachine/crashreport", "github.com/docker/machine/libmachine/drivers", "github.com/docker/machine/libmachine/drivers/plugin", "github.com/docker/machine/libmachine/drivers/plugin/localbinary", @@ -49,37 +51,112 @@ "github.com/docker/machine/libmachine/provider", "github.com/docker/machine/libmachine/provision", "github.com/docker/machine/libmachine/provision/pkgaction", + "github.com/docker/machine/libmachine/provision/provisiontest", "github.com/docker/machine/libmachine/provision/serviceaction", + "github.com/docker/machine/libmachine/shell", "github.com/docker/machine/libmachine/ssh", + "github.com/docker/machine/libmachine/ssh/sshtest", "github.com/docker/machine/libmachine/state", "github.com/docker/machine/libmachine/swarm", "github.com/docker/machine/libmachine/version", "github.com/docker/machine/version" ], "Deps": [ - { - "ImportPath": "github.com/bugsnag/bugsnag-go", - "Comment": "v1.0.5-19-g02e9528", - "Rev": "02e952891c52fbcb15f113d90633897355783b6e" - }, - { - "ImportPath": "github.com/bugsnag/osext", - "Rev": "0dd3f918b21bec95ace9dc86c7e70266cfc5c702" - }, - { - "ImportPath": "github.com/bugsnag/panicwrap", - "Rev": "e5f9854865b9778a45169fc249e99e338d4d6f27" - }, { "ImportPath": "github.com/MSOpenTech/azure-sdk-for-go", "Comment": "v1.1-17-g515f3ec", "Rev": "515f3ec74ce6a5b31e934cefae997c97bd0a1b1e" }, + { + "ImportPath": "github.com/MSOpenTech/azure-sdk-for-go/clients/imageClient", + "Comment": "v1.1-17-g515f3ec", + "Rev": "515f3ec74ce6a5b31e934cefae997c97bd0a1b1e" + }, + { + "ImportPath": "github.com/MSOpenTech/azure-sdk-for-go/clients/locationClient", + "Comment": "v1.1-17-g515f3ec", + "Rev": "515f3ec74ce6a5b31e934cefae997c97bd0a1b1e" + }, + { + "ImportPath": "github.com/MSOpenTech/azure-sdk-for-go/clients/storageServiceClient", + "Comment": "v1.1-17-g515f3ec", + "Rev": "515f3ec74ce6a5b31e934cefae997c97bd0a1b1e" + }, + { + "ImportPath": "github.com/MSOpenTech/azure-sdk-for-go/clients/vmClient", + "Comment": "v1.1-17-g515f3ec", + "Rev": "515f3ec74ce6a5b31e934cefae997c97bd0a1b1e" + }, + { + "ImportPath": "github.com/MSOpenTech/azure-sdk-for-go/core/http", + "Comment": "v1.1-17-g515f3ec", + "Rev": "515f3ec74ce6a5b31e934cefae997c97bd0a1b1e" + }, + { + "ImportPath": "github.com/MSOpenTech/azure-sdk-for-go/core/tls", + "Comment": "v1.1-17-g515f3ec", + "Rev": "515f3ec74ce6a5b31e934cefae997c97bd0a1b1e" + }, { "ImportPath": "github.com/aws/aws-sdk-go/aws", "Comment": "v1.0.2", "Rev": "9d7bc2d6ca2ada0468f705f0e9725ca97f8550c8" }, + { + "ImportPath": "github.com/aws/aws-sdk-go/aws/awserr", + "Comment": "v1.0.2", + "Rev": "9d7bc2d6ca2ada0468f705f0e9725ca97f8550c8" + }, + { + "ImportPath": "github.com/aws/aws-sdk-go/aws/awsutil", + "Comment": "v1.0.2", + "Rev": "9d7bc2d6ca2ada0468f705f0e9725ca97f8550c8" + }, + { + "ImportPath": "github.com/aws/aws-sdk-go/aws/client", + "Comment": "v1.0.2", + "Rev": "9d7bc2d6ca2ada0468f705f0e9725ca97f8550c8" + }, + { + "ImportPath": "github.com/aws/aws-sdk-go/aws/client/metadata", + "Comment": "v1.0.2", + "Rev": "9d7bc2d6ca2ada0468f705f0e9725ca97f8550c8" + }, + { + "ImportPath": "github.com/aws/aws-sdk-go/aws/corehandlers", + "Comment": "v1.0.2", + "Rev": "9d7bc2d6ca2ada0468f705f0e9725ca97f8550c8" + }, + { + "ImportPath": "github.com/aws/aws-sdk-go/aws/credentials", + "Comment": "v1.0.2", + "Rev": "9d7bc2d6ca2ada0468f705f0e9725ca97f8550c8" + }, + { + "ImportPath": "github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds", + "Comment": "v1.0.2", + "Rev": "9d7bc2d6ca2ada0468f705f0e9725ca97f8550c8" + }, + { + "ImportPath": "github.com/aws/aws-sdk-go/aws/defaults", + "Comment": "v1.0.2", + "Rev": "9d7bc2d6ca2ada0468f705f0e9725ca97f8550c8" + }, + { + "ImportPath": "github.com/aws/aws-sdk-go/aws/ec2metadata", + "Comment": "v1.0.2", + "Rev": "9d7bc2d6ca2ada0468f705f0e9725ca97f8550c8" + }, + { + "ImportPath": "github.com/aws/aws-sdk-go/aws/request", + "Comment": "v1.0.2", + "Rev": "9d7bc2d6ca2ada0468f705f0e9725ca97f8550c8" + }, + { + "ImportPath": "github.com/aws/aws-sdk-go/aws/session", + "Comment": "v1.0.2", + "Rev": "9d7bc2d6ca2ada0468f705f0e9725ca97f8550c8" + }, { "ImportPath": "github.com/aws/aws-sdk-go/private/endpoints", "Comment": "v1.0.2", @@ -120,6 +197,24 @@ "Comment": "v1.0.2", "Rev": "9d7bc2d6ca2ada0468f705f0e9725ca97f8550c8" }, + { + "ImportPath": "github.com/bugsnag/bugsnag-go", + "Comment": "v1.0.5-19-g02e9528", + "Rev": "02e952891c52fbcb15f113d90633897355783b6e" + }, + { + "ImportPath": "github.com/bugsnag/bugsnag-go/errors", + "Comment": "v1.0.5-19-g02e9528", + "Rev": "02e952891c52fbcb15f113d90633897355783b6e" + }, + { + "ImportPath": "github.com/bugsnag/osext", + "Rev": "0dd3f918b21bec95ace9dc86c7e70266cfc5c702" + }, + { + "ImportPath": "github.com/bugsnag/panicwrap", + "Rev": "e5f9854865b9778a45169fc249e99e338d4d6f27" + }, { "ImportPath": "github.com/cenkalti/backoff", "Rev": "9831e1e25c874e0a0601b6dc43641071414eec7a" @@ -140,15 +235,19 @@ "Rev": "a8a31eff10544860d2188dddabdee4d727545796" }, { - "ImportPath": "github.com/docker/docker/pkg/units", - "Comment": "v1.5.0", - "Rev": "a8a31eff10544860d2188dddabdee4d727545796" + "ImportPath": "github.com/docker/go-units", + "Comment": "v0.1.0-21-g0bbddae", + "Rev": "0bbddae09c5a5419a8c6dcdd7ff90da3d450393b" }, { "ImportPath": "github.com/go-ini/ini", "Comment": "v0-56-g03e0e7d", "Rev": "03e0e7d51a13a91c765d8d0161246bc14a38001a" }, + { + "ImportPath": "github.com/golang/protobuf/proto", + "Rev": "3c84672111d91bb5ac31719e112f9f7126a0e26e" + }, { "ImportPath": "github.com/google/go-querystring/query", "Rev": "30f7a39f4a218feb5325f3aebc60c32a572a8274" @@ -171,6 +270,101 @@ "Comment": "v1.0.0-558-gce0f487", "Rev": "ce0f487f6747ab43c4e4404722df25349385bebd" }, + { + "ImportPath": "github.com/rackspace/gophercloud/openstack", + "Comment": "v1.0.0-558-gce0f487", + "Rev": "ce0f487f6747ab43c4e4404722df25349385bebd" + }, + { + "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/floatingip", + "Comment": "v1.0.0-558-gce0f487", + "Rev": "ce0f487f6747ab43c4e4404722df25349385bebd" + }, + { + "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/keypairs", + "Comment": "v1.0.0-558-gce0f487", + "Rev": "ce0f487f6747ab43c4e4404722df25349385bebd" + }, + { + "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/startstop", + "Comment": "v1.0.0-558-gce0f487", + "Rev": "ce0f487f6747ab43c4e4404722df25349385bebd" + }, + { + "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/flavors", + "Comment": "v1.0.0-558-gce0f487", + "Rev": "ce0f487f6747ab43c4e4404722df25349385bebd" + }, + { + "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/images", + "Comment": "v1.0.0-558-gce0f487", + "Rev": "ce0f487f6747ab43c4e4404722df25349385bebd" + }, + { + "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/servers", + "Comment": "v1.0.0-558-gce0f487", + "Rev": "ce0f487f6747ab43c4e4404722df25349385bebd" + }, + { + "ImportPath": "github.com/rackspace/gophercloud/openstack/identity/v2/tenants", + "Comment": "v1.0.0-558-gce0f487", + "Rev": "ce0f487f6747ab43c4e4404722df25349385bebd" + }, + { + "ImportPath": "github.com/rackspace/gophercloud/openstack/identity/v2/tokens", + "Comment": "v1.0.0-558-gce0f487", + "Rev": "ce0f487f6747ab43c4e4404722df25349385bebd" + }, + { + "ImportPath": "github.com/rackspace/gophercloud/openstack/identity/v3/tokens", + "Comment": "v1.0.0-558-gce0f487", + "Rev": "ce0f487f6747ab43c4e4404722df25349385bebd" + }, + { + "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/floatingips", + "Comment": "v1.0.0-558-gce0f487", + "Rev": "ce0f487f6747ab43c4e4404722df25349385bebd" + }, + { + "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/networks", + "Comment": "v1.0.0-558-gce0f487", + "Rev": "ce0f487f6747ab43c4e4404722df25349385bebd" + }, + { + "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/ports", + "Comment": "v1.0.0-558-gce0f487", + "Rev": "ce0f487f6747ab43c4e4404722df25349385bebd" + }, + { + "ImportPath": "github.com/rackspace/gophercloud/openstack/utils", + "Comment": "v1.0.0-558-gce0f487", + "Rev": "ce0f487f6747ab43c4e4404722df25349385bebd" + }, + { + "ImportPath": "github.com/rackspace/gophercloud/pagination", + "Comment": "v1.0.0-558-gce0f487", + "Rev": "ce0f487f6747ab43c4e4404722df25349385bebd" + }, + { + "ImportPath": "github.com/rackspace/gophercloud/rackspace", + "Comment": "v1.0.0-558-gce0f487", + "Rev": "ce0f487f6747ab43c4e4404722df25349385bebd" + }, + { + "ImportPath": "github.com/rackspace/gophercloud/rackspace/identity/v2/tokens", + "Comment": "v1.0.0-558-gce0f487", + "Rev": "ce0f487f6747ab43c4e4404722df25349385bebd" + }, + { + "ImportPath": "github.com/rackspace/gophercloud/testhelper", + "Comment": "v1.0.0-558-gce0f487", + "Rev": "ce0f487f6747ab43c4e4404722df25349385bebd" + }, + { + "ImportPath": "github.com/rackspace/gophercloud/testhelper/client", + "Comment": "v1.0.0-558-gce0f487", + "Rev": "ce0f487f6747ab43c4e4404722df25349385bebd" + }, { "ImportPath": "github.com/samalba/dockerclient", "Rev": "f661dd4754aa5c52da85d04b5871ee0e11f4b59c" @@ -192,6 +386,91 @@ "Comment": "v0.0.2", "Rev": "66a23eaabc61518f91769939ff541886fe1dceef" }, + { + "ImportPath": "github.com/vmware/govcloudair/types/v56", + "Comment": "v0.0.2", + "Rev": "66a23eaabc61518f91769939ff541886fe1dceef" + }, + { + "ImportPath": "github.com/vmware/govmomi", + "Comment": "v0.3.0-11-g20c009c", + "Rev": "20c009ce9c493f0c714a9fffa5bda5fb84df2b6c" + }, + { + "ImportPath": "github.com/vmware/govmomi/find", + "Comment": "v0.3.0-11-g20c009c", + "Rev": "20c009ce9c493f0c714a9fffa5bda5fb84df2b6c" + }, + { + "ImportPath": "github.com/vmware/govmomi/guest", + "Comment": "v0.3.0-11-g20c009c", + "Rev": "20c009ce9c493f0c714a9fffa5bda5fb84df2b6c" + }, + { + "ImportPath": "github.com/vmware/govmomi/list", + "Comment": "v0.3.0-11-g20c009c", + "Rev": "20c009ce9c493f0c714a9fffa5bda5fb84df2b6c" + }, + { + "ImportPath": "github.com/vmware/govmomi/object", + "Comment": "v0.3.0-11-g20c009c", + "Rev": "20c009ce9c493f0c714a9fffa5bda5fb84df2b6c" + }, + { + "ImportPath": "github.com/vmware/govmomi/property", + "Comment": "v0.3.0-11-g20c009c", + "Rev": "20c009ce9c493f0c714a9fffa5bda5fb84df2b6c" + }, + { + "ImportPath": "github.com/vmware/govmomi/session", + "Comment": "v0.3.0-11-g20c009c", + "Rev": "20c009ce9c493f0c714a9fffa5bda5fb84df2b6c" + }, + { + "ImportPath": "github.com/vmware/govmomi/task", + "Comment": "v0.3.0-11-g20c009c", + "Rev": "20c009ce9c493f0c714a9fffa5bda5fb84df2b6c" + }, + { + "ImportPath": "github.com/vmware/govmomi/vim25", + "Comment": "v0.3.0-11-g20c009c", + "Rev": "20c009ce9c493f0c714a9fffa5bda5fb84df2b6c" + }, + { + "ImportPath": "github.com/vmware/govmomi/vim25/debug", + "Comment": "v0.3.0-11-g20c009c", + "Rev": "20c009ce9c493f0c714a9fffa5bda5fb84df2b6c" + }, + { + "ImportPath": "github.com/vmware/govmomi/vim25/methods", + "Comment": "v0.3.0-11-g20c009c", + "Rev": "20c009ce9c493f0c714a9fffa5bda5fb84df2b6c" + }, + { + "ImportPath": "github.com/vmware/govmomi/vim25/mo", + "Comment": "v0.3.0-11-g20c009c", + "Rev": "20c009ce9c493f0c714a9fffa5bda5fb84df2b6c" + }, + { + "ImportPath": "github.com/vmware/govmomi/vim25/progress", + "Comment": "v0.3.0-11-g20c009c", + "Rev": "20c009ce9c493f0c714a9fffa5bda5fb84df2b6c" + }, + { + "ImportPath": "github.com/vmware/govmomi/vim25/soap", + "Comment": "v0.3.0-11-g20c009c", + "Rev": "20c009ce9c493f0c714a9fffa5bda5fb84df2b6c" + }, + { + "ImportPath": "github.com/vmware/govmomi/vim25/types", + "Comment": "v0.3.0-11-g20c009c", + "Rev": "20c009ce9c493f0c714a9fffa5bda5fb84df2b6c" + }, + { + "ImportPath": "github.com/vmware/govmomi/vim25/xml", + "Comment": "v0.3.0-11-g20c009c", + "Rev": "20c009ce9c493f0c714a9fffa5bda5fb84df2b6c" + }, { "ImportPath": "golang.org/x/crypto/curve25519", "Rev": "beef0f4390813b96e8e68fd78570396d0f4751fc" @@ -200,14 +479,38 @@ "ImportPath": "golang.org/x/crypto/ssh", "Rev": "beef0f4390813b96e8e68fd78570396d0f4751fc" }, + { + "ImportPath": "golang.org/x/crypto/ssh/terminal", + "Rev": "beef0f4390813b96e8e68fd78570396d0f4751fc" + }, { "ImportPath": "golang.org/x/net/context", "Rev": "4f2fc6c1e69d41baf187332ee08fbd2b296f21ed" }, + { + "ImportPath": "golang.org/x/net/context/ctxhttp", + "Rev": "4f2fc6c1e69d41baf187332ee08fbd2b296f21ed" + }, { "ImportPath": "golang.org/x/oauth2", "Rev": "442624c9ec9243441e83b374a9e22ac549b5c51d" }, + { + "ImportPath": "golang.org/x/oauth2/google", + "Rev": "442624c9ec9243441e83b374a9e22ac549b5c51d" + }, + { + "ImportPath": "golang.org/x/oauth2/internal", + "Rev": "442624c9ec9243441e83b374a9e22ac549b5c51d" + }, + { + "ImportPath": "golang.org/x/oauth2/jws", + "Rev": "442624c9ec9243441e83b374a9e22ac549b5c51d" + }, + { + "ImportPath": "golang.org/x/oauth2/jwt", + "Rev": "442624c9ec9243441e83b374a9e22ac549b5c51d" + }, { "ImportPath": "golang.org/x/sys/windows/registry", "Rev": "d9157a9621b69ad1d8d77a1933590c416593f24f" @@ -224,6 +527,42 @@ "ImportPath": "google.golang.org/api/googleapi", "Rev": "030d584ade5f79aa2ed0ce067e8f7da50c9a10d5" }, + { + "ImportPath": "google.golang.org/api/googleapi/internal/uritemplates", + "Rev": "030d584ade5f79aa2ed0ce067e8f7da50c9a10d5" + }, + { + "ImportPath": "google.golang.org/appengine", + "Rev": "6a436539be38c296a8075a871cc536686b458371" + }, + { + "ImportPath": "google.golang.org/appengine/internal", + "Rev": "6a436539be38c296a8075a871cc536686b458371" + }, + { + "ImportPath": "google.golang.org/appengine/internal/app_identity", + "Rev": "6a436539be38c296a8075a871cc536686b458371" + }, + { + "ImportPath": "google.golang.org/appengine/internal/base", + "Rev": "6a436539be38c296a8075a871cc536686b458371" + }, + { + "ImportPath": "google.golang.org/appengine/internal/datastore", + "Rev": "6a436539be38c296a8075a871cc536686b458371" + }, + { + "ImportPath": "google.golang.org/appengine/internal/log", + "Rev": "6a436539be38c296a8075a871cc536686b458371" + }, + { + "ImportPath": "google.golang.org/appengine/internal/modules", + "Rev": "6a436539be38c296a8075a871cc536686b458371" + }, + { + "ImportPath": "google.golang.org/appengine/internal/remote_api", + "Rev": "6a436539be38c296a8075a871cc536686b458371" + }, { "ImportPath": "google.golang.org/cloud/compute/metadata", "Rev": "975617b05ea8a58727e6c1a06b6161ff4185a9f2" @@ -231,16 +570,6 @@ { "ImportPath": "google.golang.org/cloud/internal", "Rev": "975617b05ea8a58727e6c1a06b6161ff4185a9f2" - }, - { - "ImportPath": "github.com/vmware/govmomi", - "Comment": "v0.3.0-11-g20c009c", - "Rev": "20c009ce9c493f0c714a9fffa5bda5fb84df2b6c" - }, - { - "ImportPath": "github.com/docker/go-units", - "Comment": "v0.1.0-21-g0bbddae", - "Rev": "0bbddae09c5a5419a8c6dcdd7ff90da3d450393b" } ] } diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/child.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/child.go deleted file mode 100644 index 45fc2e57cd..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/child.go +++ /dev/null @@ -1,206 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file implements CGI from the perspective of a child -// process. - -package cgi - -import ( - "bufio" - "crypto/tls" - "errors" - "fmt" - "io" - "io/ioutil" - "net" - "net/http" - "net/url" - "os" - "strconv" - "strings" -) - -// Request returns the HTTP request as represented in the current -// environment. This assumes the current program is being run -// by a web server in a CGI environment. -// The returned Request's Body is populated, if applicable. -func Request() (*http.Request, error) { - r, err := RequestFromMap(envMap(os.Environ())) - if err != nil { - return nil, err - } - if r.ContentLength > 0 { - r.Body = ioutil.NopCloser(io.LimitReader(os.Stdin, r.ContentLength)) - } - return r, nil -} - -func envMap(env []string) map[string]string { - m := make(map[string]string) - for _, kv := range env { - if idx := strings.Index(kv, "="); idx != -1 { - m[kv[:idx]] = kv[idx+1:] - } - } - return m -} - -// RequestFromMap creates an http.Request from CGI variables. -// The returned Request's Body field is not populated. -func RequestFromMap(params map[string]string) (*http.Request, error) { - r := new(http.Request) - r.Method = params["REQUEST_METHOD"] - if r.Method == "" { - return nil, errors.New("cgi: no REQUEST_METHOD in environment") - } - - r.Proto = params["SERVER_PROTOCOL"] - var ok bool - r.ProtoMajor, r.ProtoMinor, ok = http.ParseHTTPVersion(r.Proto) - if !ok { - return nil, errors.New("cgi: invalid SERVER_PROTOCOL version") - } - - r.Close = true - r.Trailer = http.Header{} - r.Header = http.Header{} - - r.Host = params["HTTP_HOST"] - - if lenstr := params["CONTENT_LENGTH"]; lenstr != "" { - clen, err := strconv.ParseInt(lenstr, 10, 64) - if err != nil { - return nil, errors.New("cgi: bad CONTENT_LENGTH in environment: " + lenstr) - } - r.ContentLength = clen - } - - if ct := params["CONTENT_TYPE"]; ct != "" { - r.Header.Set("Content-Type", ct) - } - - // Copy "HTTP_FOO_BAR" variables to "Foo-Bar" Headers - for k, v := range params { - if !strings.HasPrefix(k, "HTTP_") || k == "HTTP_HOST" { - continue - } - r.Header.Add(strings.Replace(k[5:], "_", "-", -1), v) - } - - // TODO: cookies. parsing them isn't exported, though. - - uriStr := params["REQUEST_URI"] - if uriStr == "" { - // Fallback to SCRIPT_NAME, PATH_INFO and QUERY_STRING. - uriStr = params["SCRIPT_NAME"] + params["PATH_INFO"] - s := params["QUERY_STRING"] - if s != "" { - uriStr += "?" + s - } - } - - // There's apparently a de-facto standard for this. - // http://docstore.mik.ua/orelly/linux/cgi/ch03_02.htm#ch03-35636 - if s := params["HTTPS"]; s == "on" || s == "ON" || s == "1" { - r.TLS = &tls.ConnectionState{HandshakeComplete: true} - } - - if r.Host != "" { - // Hostname is provided, so we can reasonably construct a URL. - rawurl := r.Host + uriStr - if r.TLS == nil { - rawurl = "http://" + rawurl - } else { - rawurl = "https://" + rawurl - } - url, err := url.Parse(rawurl) - if err != nil { - return nil, errors.New("cgi: failed to parse host and REQUEST_URI into a URL: " + rawurl) - } - r.URL = url - } - // Fallback logic if we don't have a Host header or the URL - // failed to parse - if r.URL == nil { - url, err := url.Parse(uriStr) - if err != nil { - return nil, errors.New("cgi: failed to parse REQUEST_URI into a URL: " + uriStr) - } - r.URL = url - } - - // Request.RemoteAddr has its port set by Go's standard http - // server, so we do here too. We don't have one, though, so we - // use a dummy one. - r.RemoteAddr = net.JoinHostPort(params["REMOTE_ADDR"], "0") - - return r, nil -} - -// Serve executes the provided Handler on the currently active CGI -// request, if any. If there's no current CGI environment -// an error is returned. The provided handler may be nil to use -// http.DefaultServeMux. -func Serve(handler http.Handler) error { - req, err := Request() - if err != nil { - return err - } - if handler == nil { - handler = http.DefaultServeMux - } - rw := &response{ - req: req, - header: make(http.Header), - bufw: bufio.NewWriter(os.Stdout), - } - handler.ServeHTTP(rw, req) - rw.Write(nil) // make sure a response is sent - if err = rw.bufw.Flush(); err != nil { - return err - } - return nil -} - -type response struct { - req *http.Request - header http.Header - bufw *bufio.Writer - headerSent bool -} - -func (r *response) Flush() { - r.bufw.Flush() -} - -func (r *response) Header() http.Header { - return r.header -} - -func (r *response) Write(p []byte) (n int, err error) { - if !r.headerSent { - r.WriteHeader(http.StatusOK) - } - return r.bufw.Write(p) -} - -func (r *response) WriteHeader(code int) { - if r.headerSent { - // Note: explicitly using Stderr, as Stdout is our HTTP output. - fmt.Fprintf(os.Stderr, "CGI attempted to write header twice on request for %s", r.req.URL) - return - } - r.headerSent = true - fmt.Fprintf(r.bufw, "Status: %d %s\r\n", code, http.StatusText(code)) - - // Set a default Content-Type - if _, hasType := r.header["Content-Type"]; !hasType { - r.header.Add("Content-Type", "text/html; charset=utf-8") - } - - r.header.Write(r.bufw) - r.bufw.WriteString("\r\n") - r.bufw.Flush() -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/child_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/child_test.go deleted file mode 100644 index 075d8411bc..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/child_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Tests for CGI (the child process perspective) - -package cgi - -import ( - "testing" -) - -func TestRequest(t *testing.T) { - env := map[string]string{ - "SERVER_PROTOCOL": "HTTP/1.1", - "REQUEST_METHOD": "GET", - "HTTP_HOST": "example.com", - "HTTP_REFERER": "elsewhere", - "HTTP_USER_AGENT": "goclient", - "HTTP_FOO_BAR": "baz", - "REQUEST_URI": "/path?a=b", - "CONTENT_LENGTH": "123", - "CONTENT_TYPE": "text/xml", - "REMOTE_ADDR": "5.6.7.8", - } - req, err := RequestFromMap(env) - if err != nil { - t.Fatalf("RequestFromMap: %v", err) - } - if g, e := req.UserAgent(), "goclient"; e != g { - t.Errorf("expected UserAgent %q; got %q", e, g) - } - if g, e := req.Method, "GET"; e != g { - t.Errorf("expected Method %q; got %q", e, g) - } - if g, e := req.Header.Get("Content-Type"), "text/xml"; e != g { - t.Errorf("expected Content-Type %q; got %q", e, g) - } - if g, e := req.ContentLength, int64(123); e != g { - t.Errorf("expected ContentLength %d; got %d", e, g) - } - if g, e := req.Referer(), "elsewhere"; e != g { - t.Errorf("expected Referer %q; got %q", e, g) - } - if req.Header == nil { - t.Fatalf("unexpected nil Header") - } - if g, e := req.Header.Get("Foo-Bar"), "baz"; e != g { - t.Errorf("expected Foo-Bar %q; got %q", e, g) - } - if g, e := req.URL.String(), "http://example.com/path?a=b"; e != g { - t.Errorf("expected URL %q; got %q", e, g) - } - if g, e := req.FormValue("a"), "b"; e != g { - t.Errorf("expected FormValue(a) %q; got %q", e, g) - } - if req.Trailer == nil { - t.Errorf("unexpected nil Trailer") - } - if req.TLS != nil { - t.Errorf("expected nil TLS") - } - if e, g := "5.6.7.8:0", req.RemoteAddr; e != g { - t.Errorf("RemoteAddr: got %q; want %q", g, e) - } -} - -func TestRequestWithTLS(t *testing.T) { - env := map[string]string{ - "SERVER_PROTOCOL": "HTTP/1.1", - "REQUEST_METHOD": "GET", - "HTTP_HOST": "example.com", - "HTTP_REFERER": "elsewhere", - "REQUEST_URI": "/path?a=b", - "CONTENT_TYPE": "text/xml", - "HTTPS": "1", - "REMOTE_ADDR": "5.6.7.8", - } - req, err := RequestFromMap(env) - if err != nil { - t.Fatalf("RequestFromMap: %v", err) - } - if g, e := req.URL.String(), "https://example.com/path?a=b"; e != g { - t.Errorf("expected URL %q; got %q", e, g) - } - if req.TLS == nil { - t.Errorf("expected non-nil TLS") - } -} - -func TestRequestWithoutHost(t *testing.T) { - env := map[string]string{ - "SERVER_PROTOCOL": "HTTP/1.1", - "HTTP_HOST": "", - "REQUEST_METHOD": "GET", - "REQUEST_URI": "/path?a=b", - "CONTENT_LENGTH": "123", - } - req, err := RequestFromMap(env) - if err != nil { - t.Fatalf("RequestFromMap: %v", err) - } - if req.URL == nil { - t.Fatalf("unexpected nil URL") - } - if g, e := req.URL.String(), "/path?a=b"; e != g { - t.Errorf("URL = %q; want %q", g, e) - } -} - -func TestRequestWithoutRequestURI(t *testing.T) { - env := map[string]string{ - "SERVER_PROTOCOL": "HTTP/1.1", - "HTTP_HOST": "example.com", - "REQUEST_METHOD": "GET", - "SCRIPT_NAME": "/dir/scriptname", - "PATH_INFO": "/p1/p2", - "QUERY_STRING": "a=1&b=2", - "CONTENT_LENGTH": "123", - } - req, err := RequestFromMap(env) - if err != nil { - t.Fatalf("RequestFromMap: %v", err) - } - if req.URL == nil { - t.Fatalf("unexpected nil URL") - } - if g, e := req.URL.String(), "http://example.com/dir/scriptname/p1/p2?a=1&b=2"; e != g { - t.Errorf("URL = %q; want %q", g, e) - } -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/host.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/host.go deleted file mode 100644 index ec95a972c1..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/host.go +++ /dev/null @@ -1,377 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file implements the host side of CGI (being the webserver -// parent process). - -// Package cgi implements CGI (Common Gateway Interface) as specified -// in RFC 3875. -// -// Note that using CGI means starting a new process to handle each -// request, which is typically less efficient than using a -// long-running server. This package is intended primarily for -// compatibility with existing systems. -package cgi - -import ( - "bufio" - "fmt" - "io" - "log" - "net/http" - "os" - "os/exec" - "path/filepath" - "regexp" - "runtime" - "strconv" - "strings" -) - -var trailingPort = regexp.MustCompile(`:([0-9]+)$`) - -var osDefaultInheritEnv = map[string][]string{ - "darwin": {"DYLD_LIBRARY_PATH"}, - "freebsd": {"LD_LIBRARY_PATH"}, - "hpux": {"LD_LIBRARY_PATH", "SHLIB_PATH"}, - "irix": {"LD_LIBRARY_PATH", "LD_LIBRARYN32_PATH", "LD_LIBRARY64_PATH"}, - "linux": {"LD_LIBRARY_PATH"}, - "openbsd": {"LD_LIBRARY_PATH"}, - "solaris": {"LD_LIBRARY_PATH", "LD_LIBRARY_PATH_32", "LD_LIBRARY_PATH_64"}, - "windows": {"SystemRoot", "COMSPEC", "PATHEXT", "WINDIR"}, -} - -// Handler runs an executable in a subprocess with a CGI environment. -type Handler struct { - Path string // path to the CGI executable - Root string // root URI prefix of handler or empty for "/" - - // Dir specifies the CGI executable's working directory. - // If Dir is empty, the base directory of Path is used. - // If Path has no base directory, the current working - // directory is used. - Dir string - - Env []string // extra environment variables to set, if any, as "key=value" - InheritEnv []string // environment variables to inherit from host, as "key" - Logger *log.Logger // optional log for errors or nil to use log.Print - Args []string // optional arguments to pass to child process - - // PathLocationHandler specifies the root http Handler that - // should handle internal redirects when the CGI process - // returns a Location header value starting with a "/", as - // specified in RFC 3875 § 6.3.2. This will likely be - // http.DefaultServeMux. - // - // If nil, a CGI response with a local URI path is instead sent - // back to the client and not redirected internally. - PathLocationHandler http.Handler -} - -// removeLeadingDuplicates remove leading duplicate in environments. -// It's possible to override environment like following. -// cgi.Handler{ -// ... -// Env: []string{"SCRIPT_FILENAME=foo.php"}, -// } -func removeLeadingDuplicates(env []string) (ret []string) { - n := len(env) - for i := 0; i < n; i++ { - e := env[i] - s := strings.SplitN(e, "=", 2)[0] - found := false - for j := i + 1; j < n; j++ { - if s == strings.SplitN(env[j], "=", 2)[0] { - found = true - break - } - } - if !found { - ret = append(ret, e) - } - } - return -} - -func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request) { - root := h.Root - if root == "" { - root = "/" - } - - if len(req.TransferEncoding) > 0 && req.TransferEncoding[0] == "chunked" { - rw.WriteHeader(http.StatusBadRequest) - rw.Write([]byte("Chunked request bodies are not supported by CGI.")) - return - } - - pathInfo := req.URL.Path - if root != "/" && strings.HasPrefix(pathInfo, root) { - pathInfo = pathInfo[len(root):] - } - - port := "80" - if matches := trailingPort.FindStringSubmatch(req.Host); len(matches) != 0 { - port = matches[1] - } - - env := []string{ - "SERVER_SOFTWARE=go", - "SERVER_NAME=" + req.Host, - "SERVER_PROTOCOL=HTTP/1.1", - "HTTP_HOST=" + req.Host, - "GATEWAY_INTERFACE=CGI/1.1", - "REQUEST_METHOD=" + req.Method, - "QUERY_STRING=" + req.URL.RawQuery, - "REQUEST_URI=" + req.URL.RequestURI(), - "PATH_INFO=" + pathInfo, - "SCRIPT_NAME=" + root, - "SCRIPT_FILENAME=" + h.Path, - "REMOTE_ADDR=" + req.RemoteAddr, - "REMOTE_HOST=" + req.RemoteAddr, - "SERVER_PORT=" + port, - } - - if req.TLS != nil { - env = append(env, "HTTPS=on") - } - - for k, v := range req.Header { - k = strings.Map(upperCaseAndUnderscore, k) - joinStr := ", " - if k == "COOKIE" { - joinStr = "; " - } - env = append(env, "HTTP_"+k+"="+strings.Join(v, joinStr)) - } - - if req.ContentLength > 0 { - env = append(env, fmt.Sprintf("CONTENT_LENGTH=%d", req.ContentLength)) - } - if ctype := req.Header.Get("Content-Type"); ctype != "" { - env = append(env, "CONTENT_TYPE="+ctype) - } - - if h.Env != nil { - env = append(env, h.Env...) - } - - envPath := os.Getenv("PATH") - if envPath == "" { - envPath = "/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/local/bin" - } - env = append(env, "PATH="+envPath) - - for _, e := range h.InheritEnv { - if v := os.Getenv(e); v != "" { - env = append(env, e+"="+v) - } - } - - for _, e := range osDefaultInheritEnv[runtime.GOOS] { - if v := os.Getenv(e); v != "" { - env = append(env, e+"="+v) - } - } - - env = removeLeadingDuplicates(env) - - var cwd, path string - if h.Dir != "" { - path = h.Path - cwd = h.Dir - } else { - cwd, path = filepath.Split(h.Path) - } - if cwd == "" { - cwd = "." - } - - internalError := func(err error) { - rw.WriteHeader(http.StatusInternalServerError) - h.printf("CGI error: %v", err) - } - - cmd := &exec.Cmd{ - Path: path, - Args: append([]string{h.Path}, h.Args...), - Dir: cwd, - Env: env, - Stderr: os.Stderr, // for now - } - if req.ContentLength != 0 { - cmd.Stdin = req.Body - } - stdoutRead, err := cmd.StdoutPipe() - if err != nil { - internalError(err) - return - } - - err = cmd.Start() - if err != nil { - internalError(err) - return - } - if hook := testHookStartProcess; hook != nil { - hook(cmd.Process) - } - defer cmd.Wait() - defer stdoutRead.Close() - - linebody := bufio.NewReaderSize(stdoutRead, 1024) - headers := make(http.Header) - statusCode := 0 - headerLines := 0 - sawBlankLine := false - for { - line, isPrefix, err := linebody.ReadLine() - if isPrefix { - rw.WriteHeader(http.StatusInternalServerError) - h.printf("cgi: long header line from subprocess.") - return - } - if err == io.EOF { - break - } - if err != nil { - rw.WriteHeader(http.StatusInternalServerError) - h.printf("cgi: error reading headers: %v", err) - return - } - if len(line) == 0 { - sawBlankLine = true - break - } - headerLines++ - parts := strings.SplitN(string(line), ":", 2) - if len(parts) < 2 { - h.printf("cgi: bogus header line: %s", string(line)) - continue - } - header, val := parts[0], parts[1] - header = strings.TrimSpace(header) - val = strings.TrimSpace(val) - switch { - case header == "Status": - if len(val) < 3 { - h.printf("cgi: bogus status (short): %q", val) - return - } - code, err := strconv.Atoi(val[0:3]) - if err != nil { - h.printf("cgi: bogus status: %q", val) - h.printf("cgi: line was %q", line) - return - } - statusCode = code - default: - headers.Add(header, val) - } - } - if headerLines == 0 || !sawBlankLine { - rw.WriteHeader(http.StatusInternalServerError) - h.printf("cgi: no headers") - return - } - - if loc := headers.Get("Location"); loc != "" { - if strings.HasPrefix(loc, "/") && h.PathLocationHandler != nil { - h.handleInternalRedirect(rw, req, loc) - return - } - if statusCode == 0 { - statusCode = http.StatusFound - } - } - - if statusCode == 0 && headers.Get("Content-Type") == "" { - rw.WriteHeader(http.StatusInternalServerError) - h.printf("cgi: missing required Content-Type in headers") - return - } - - if statusCode == 0 { - statusCode = http.StatusOK - } - - // Copy headers to rw's headers, after we've decided not to - // go into handleInternalRedirect, which won't want its rw - // headers to have been touched. - for k, vv := range headers { - for _, v := range vv { - rw.Header().Add(k, v) - } - } - - rw.WriteHeader(statusCode) - - _, err = io.Copy(rw, linebody) - if err != nil { - h.printf("cgi: copy error: %v", err) - // And kill the child CGI process so we don't hang on - // the deferred cmd.Wait above if the error was just - // the client (rw) going away. If it was a read error - // (because the child died itself), then the extra - // kill of an already-dead process is harmless (the PID - // won't be reused until the Wait above). - cmd.Process.Kill() - } -} - -func (h *Handler) printf(format string, v ...interface{}) { - if h.Logger != nil { - h.Logger.Printf(format, v...) - } else { - log.Printf(format, v...) - } -} - -func (h *Handler) handleInternalRedirect(rw http.ResponseWriter, req *http.Request, path string) { - url, err := req.URL.Parse(path) - if err != nil { - rw.WriteHeader(http.StatusInternalServerError) - h.printf("cgi: error resolving local URI path %q: %v", path, err) - return - } - // TODO: RFC 3875 isn't clear if only GET is supported, but it - // suggests so: "Note that any message-body attached to the - // request (such as for a POST request) may not be available - // to the resource that is the target of the redirect." We - // should do some tests against Apache to see how it handles - // POST, HEAD, etc. Does the internal redirect get the same - // method or just GET? What about incoming headers? - // (e.g. Cookies) Which headers, if any, are copied into the - // second request? - newReq := &http.Request{ - Method: "GET", - URL: url, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - Header: make(http.Header), - Host: url.Host, - RemoteAddr: req.RemoteAddr, - TLS: req.TLS, - } - h.PathLocationHandler.ServeHTTP(rw, newReq) -} - -func upperCaseAndUnderscore(r rune) rune { - switch { - case r >= 'a' && r <= 'z': - return r - ('a' - 'A') - case r == '-': - return '_' - case r == '=': - // Maybe not part of the CGI 'spec' but would mess up - // the environment in any case, as Go represents the - // environment as a slice of "key=value" strings. - return '_' - } - // TODO: other transformations in spec or practice? - return r -} - -var testHookStartProcess func(*os.Process) // nil except for some tests diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/host_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/host_test.go deleted file mode 100644 index 8c16e6897f..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/host_test.go +++ /dev/null @@ -1,461 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Tests for package cgi - -package cgi - -import ( - "bufio" - "fmt" - "io" - "net" - "net/http" - "net/http/httptest" - "os" - "os/exec" - "path/filepath" - "runtime" - "strconv" - "strings" - "testing" - "time" -) - -func newRequest(httpreq string) *http.Request { - buf := bufio.NewReader(strings.NewReader(httpreq)) - req, err := http.ReadRequest(buf) - if err != nil { - panic("cgi: bogus http request in test: " + httpreq) - } - req.RemoteAddr = "1.2.3.4" - return req -} - -func runCgiTest(t *testing.T, h *Handler, httpreq string, expectedMap map[string]string) *httptest.ResponseRecorder { - rw := httptest.NewRecorder() - req := newRequest(httpreq) - h.ServeHTTP(rw, req) - - // Make a map to hold the test map that the CGI returns. - m := make(map[string]string) - m["_body"] = rw.Body.String() - linesRead := 0 -readlines: - for { - line, err := rw.Body.ReadString('\n') - switch { - case err == io.EOF: - break readlines - case err != nil: - t.Fatalf("unexpected error reading from CGI: %v", err) - } - linesRead++ - trimmedLine := strings.TrimRight(line, "\r\n") - split := strings.SplitN(trimmedLine, "=", 2) - if len(split) != 2 { - t.Fatalf("Unexpected %d parts from invalid line number %v: %q; existing map=%v", - len(split), linesRead, line, m) - } - m[split[0]] = split[1] - } - - for key, expected := range expectedMap { - got := m[key] - if key == "cwd" { - // For Windows. golang.org/issue/4645. - fi1, _ := os.Stat(got) - fi2, _ := os.Stat(expected) - if os.SameFile(fi1, fi2) { - got = expected - } - } - if got != expected { - t.Errorf("for key %q got %q; expected %q", key, got, expected) - } - } - return rw -} - -var cgiTested, cgiWorks bool - -func check(t *testing.T) { - if !cgiTested { - cgiTested = true - cgiWorks = exec.Command("./testdata/test.cgi").Run() == nil - } - if !cgiWorks { - // No Perl on Windows, needed by test.cgi - // TODO: make the child process be Go, not Perl. - t.Skip("Skipping test: test.cgi failed.") - } -} - -func TestCGIBasicGet(t *testing.T) { - check(t) - h := &Handler{ - Path: "testdata/test.cgi", - Root: "/test.cgi", - } - expectedMap := map[string]string{ - "test": "Hello CGI", - "param-a": "b", - "param-foo": "bar", - "env-GATEWAY_INTERFACE": "CGI/1.1", - "env-HTTP_HOST": "example.com", - "env-PATH_INFO": "", - "env-QUERY_STRING": "foo=bar&a=b", - "env-REMOTE_ADDR": "1.2.3.4", - "env-REMOTE_HOST": "1.2.3.4", - "env-REQUEST_METHOD": "GET", - "env-REQUEST_URI": "/test.cgi?foo=bar&a=b", - "env-SCRIPT_FILENAME": "testdata/test.cgi", - "env-SCRIPT_NAME": "/test.cgi", - "env-SERVER_NAME": "example.com", - "env-SERVER_PORT": "80", - "env-SERVER_SOFTWARE": "go", - } - replay := runCgiTest(t, h, "GET /test.cgi?foo=bar&a=b HTTP/1.0\nHost: example.com\n\n", expectedMap) - - if expected, got := "text/html", replay.Header().Get("Content-Type"); got != expected { - t.Errorf("got a Content-Type of %q; expected %q", got, expected) - } - if expected, got := "X-Test-Value", replay.Header().Get("X-Test-Header"); got != expected { - t.Errorf("got a X-Test-Header of %q; expected %q", got, expected) - } -} - -func TestCGIBasicGetAbsPath(t *testing.T) { - check(t) - pwd, err := os.Getwd() - if err != nil { - t.Fatalf("getwd error: %v", err) - } - h := &Handler{ - Path: pwd + "/testdata/test.cgi", - Root: "/test.cgi", - } - expectedMap := map[string]string{ - "env-REQUEST_URI": "/test.cgi?foo=bar&a=b", - "env-SCRIPT_FILENAME": pwd + "/testdata/test.cgi", - "env-SCRIPT_NAME": "/test.cgi", - } - runCgiTest(t, h, "GET /test.cgi?foo=bar&a=b HTTP/1.0\nHost: example.com\n\n", expectedMap) -} - -func TestPathInfo(t *testing.T) { - check(t) - h := &Handler{ - Path: "testdata/test.cgi", - Root: "/test.cgi", - } - expectedMap := map[string]string{ - "param-a": "b", - "env-PATH_INFO": "/extrapath", - "env-QUERY_STRING": "a=b", - "env-REQUEST_URI": "/test.cgi/extrapath?a=b", - "env-SCRIPT_FILENAME": "testdata/test.cgi", - "env-SCRIPT_NAME": "/test.cgi", - } - runCgiTest(t, h, "GET /test.cgi/extrapath?a=b HTTP/1.0\nHost: example.com\n\n", expectedMap) -} - -func TestPathInfoDirRoot(t *testing.T) { - check(t) - h := &Handler{ - Path: "testdata/test.cgi", - Root: "/myscript/", - } - expectedMap := map[string]string{ - "env-PATH_INFO": "bar", - "env-QUERY_STRING": "a=b", - "env-REQUEST_URI": "/myscript/bar?a=b", - "env-SCRIPT_FILENAME": "testdata/test.cgi", - "env-SCRIPT_NAME": "/myscript/", - } - runCgiTest(t, h, "GET /myscript/bar?a=b HTTP/1.0\nHost: example.com\n\n", expectedMap) -} - -func TestDupHeaders(t *testing.T) { - check(t) - h := &Handler{ - Path: "testdata/test.cgi", - } - expectedMap := map[string]string{ - "env-REQUEST_URI": "/myscript/bar?a=b", - "env-SCRIPT_FILENAME": "testdata/test.cgi", - "env-HTTP_COOKIE": "nom=NOM; yum=YUM", - "env-HTTP_X_FOO": "val1, val2", - } - runCgiTest(t, h, "GET /myscript/bar?a=b HTTP/1.0\n"+ - "Cookie: nom=NOM\n"+ - "Cookie: yum=YUM\n"+ - "X-Foo: val1\n"+ - "X-Foo: val2\n"+ - "Host: example.com\n\n", - expectedMap) -} - -func TestPathInfoNoRoot(t *testing.T) { - check(t) - h := &Handler{ - Path: "testdata/test.cgi", - Root: "", - } - expectedMap := map[string]string{ - "env-PATH_INFO": "/bar", - "env-QUERY_STRING": "a=b", - "env-REQUEST_URI": "/bar?a=b", - "env-SCRIPT_FILENAME": "testdata/test.cgi", - "env-SCRIPT_NAME": "/", - } - runCgiTest(t, h, "GET /bar?a=b HTTP/1.0\nHost: example.com\n\n", expectedMap) -} - -func TestCGIBasicPost(t *testing.T) { - check(t) - postReq := `POST /test.cgi?a=b HTTP/1.0 -Host: example.com -Content-Type: application/x-www-form-urlencoded -Content-Length: 15 - -postfoo=postbar` - h := &Handler{ - Path: "testdata/test.cgi", - Root: "/test.cgi", - } - expectedMap := map[string]string{ - "test": "Hello CGI", - "param-postfoo": "postbar", - "env-REQUEST_METHOD": "POST", - "env-CONTENT_LENGTH": "15", - "env-REQUEST_URI": "/test.cgi?a=b", - } - runCgiTest(t, h, postReq, expectedMap) -} - -func chunk(s string) string { - return fmt.Sprintf("%x\r\n%s\r\n", len(s), s) -} - -// The CGI spec doesn't allow chunked requests. -func TestCGIPostChunked(t *testing.T) { - check(t) - postReq := `POST /test.cgi?a=b HTTP/1.1 -Host: example.com -Content-Type: application/x-www-form-urlencoded -Transfer-Encoding: chunked - -` + chunk("postfoo") + chunk("=") + chunk("postbar") + chunk("") - - h := &Handler{ - Path: "testdata/test.cgi", - Root: "/test.cgi", - } - expectedMap := map[string]string{} - resp := runCgiTest(t, h, postReq, expectedMap) - if got, expected := resp.Code, http.StatusBadRequest; got != expected { - t.Fatalf("Expected %v response code from chunked request body; got %d", - expected, got) - } -} - -func TestRedirect(t *testing.T) { - check(t) - h := &Handler{ - Path: "testdata/test.cgi", - Root: "/test.cgi", - } - rec := runCgiTest(t, h, "GET /test.cgi?loc=http://foo.com/ HTTP/1.0\nHost: example.com\n\n", nil) - if e, g := 302, rec.Code; e != g { - t.Errorf("expected status code %d; got %d", e, g) - } - if e, g := "http://foo.com/", rec.Header().Get("Location"); e != g { - t.Errorf("expected Location header of %q; got %q", e, g) - } -} - -func TestInternalRedirect(t *testing.T) { - check(t) - baseHandler := http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { - fmt.Fprintf(rw, "basepath=%s\n", req.URL.Path) - fmt.Fprintf(rw, "remoteaddr=%s\n", req.RemoteAddr) - }) - h := &Handler{ - Path: "testdata/test.cgi", - Root: "/test.cgi", - PathLocationHandler: baseHandler, - } - expectedMap := map[string]string{ - "basepath": "/foo", - "remoteaddr": "1.2.3.4", - } - runCgiTest(t, h, "GET /test.cgi?loc=/foo HTTP/1.0\nHost: example.com\n\n", expectedMap) -} - -// TestCopyError tests that we kill the process if there's an error copying -// its output. (for example, from the client having gone away) -func TestCopyError(t *testing.T) { - check(t) - if runtime.GOOS == "windows" { - t.Skipf("skipping test on %q", runtime.GOOS) - } - h := &Handler{ - Path: "testdata/test.cgi", - Root: "/test.cgi", - } - ts := httptest.NewServer(h) - defer ts.Close() - - conn, err := net.Dial("tcp", ts.Listener.Addr().String()) - if err != nil { - t.Fatal(err) - } - req, _ := http.NewRequest("GET", "http://example.com/test.cgi?bigresponse=1", nil) - err = req.Write(conn) - if err != nil { - t.Fatalf("Write: %v", err) - } - - res, err := http.ReadResponse(bufio.NewReader(conn), req) - if err != nil { - t.Fatalf("ReadResponse: %v", err) - } - - pidstr := res.Header.Get("X-CGI-Pid") - if pidstr == "" { - t.Fatalf("expected an X-CGI-Pid header in response") - } - pid, err := strconv.Atoi(pidstr) - if err != nil { - t.Fatalf("invalid X-CGI-Pid value") - } - - var buf [5000]byte - n, err := io.ReadFull(res.Body, buf[:]) - if err != nil { - t.Fatalf("ReadFull: %d bytes, %v", n, err) - } - - childRunning := func() bool { - return isProcessRunning(t, pid) - } - - if !childRunning() { - t.Fatalf("pre-conn.Close, expected child to be running") - } - conn.Close() - - tries := 0 - for tries < 25 && childRunning() { - time.Sleep(50 * time.Millisecond * time.Duration(tries)) - tries++ - } - if childRunning() { - t.Fatalf("post-conn.Close, expected child to be gone") - } -} - -func TestDirUnix(t *testing.T) { - check(t) - if runtime.GOOS == "windows" { - t.Skipf("skipping test on %q", runtime.GOOS) - } - cwd, _ := os.Getwd() - h := &Handler{ - Path: "testdata/test.cgi", - Root: "/test.cgi", - Dir: cwd, - } - expectedMap := map[string]string{ - "cwd": cwd, - } - runCgiTest(t, h, "GET /test.cgi HTTP/1.0\nHost: example.com\n\n", expectedMap) - - cwd, _ = os.Getwd() - cwd = filepath.Join(cwd, "testdata") - h = &Handler{ - Path: "testdata/test.cgi", - Root: "/test.cgi", - } - expectedMap = map[string]string{ - "cwd": cwd, - } - runCgiTest(t, h, "GET /test.cgi HTTP/1.0\nHost: example.com\n\n", expectedMap) -} - -func TestDirWindows(t *testing.T) { - if runtime.GOOS != "windows" { - t.Skip("Skipping windows specific test.") - } - - cgifile, _ := filepath.Abs("testdata/test.cgi") - - var perl string - var err error - perl, err = exec.LookPath("perl") - if err != nil { - t.Skip("Skipping test: perl not found.") - } - perl, _ = filepath.Abs(perl) - - cwd, _ := os.Getwd() - h := &Handler{ - Path: perl, - Root: "/test.cgi", - Dir: cwd, - Args: []string{cgifile}, - Env: []string{"SCRIPT_FILENAME=" + cgifile}, - } - expectedMap := map[string]string{ - "cwd": cwd, - } - runCgiTest(t, h, "GET /test.cgi HTTP/1.0\nHost: example.com\n\n", expectedMap) - - // If not specify Dir on windows, working directory should be - // base directory of perl. - cwd, _ = filepath.Split(perl) - if cwd != "" && cwd[len(cwd)-1] == filepath.Separator { - cwd = cwd[:len(cwd)-1] - } - h = &Handler{ - Path: perl, - Root: "/test.cgi", - Args: []string{cgifile}, - Env: []string{"SCRIPT_FILENAME=" + cgifile}, - } - expectedMap = map[string]string{ - "cwd": cwd, - } - runCgiTest(t, h, "GET /test.cgi HTTP/1.0\nHost: example.com\n\n", expectedMap) -} - -func TestEnvOverride(t *testing.T) { - cgifile, _ := filepath.Abs("testdata/test.cgi") - - var perl string - var err error - perl, err = exec.LookPath("perl") - if err != nil { - t.Skipf("Skipping test: perl not found.") - } - perl, _ = filepath.Abs(perl) - - cwd, _ := os.Getwd() - h := &Handler{ - Path: perl, - Root: "/test.cgi", - Dir: cwd, - Args: []string{cgifile}, - Env: []string{ - "SCRIPT_FILENAME=" + cgifile, - "REQUEST_URI=/foo/bar"}, - } - expectedMap := map[string]string{ - "cwd": cwd, - "env-SCRIPT_FILENAME": cgifile, - "env-REQUEST_URI": "/foo/bar", - } - runCgiTest(t, h, "GET /test.cgi HTTP/1.0\nHost: example.com\n\n", expectedMap) -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/matryoshka_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/matryoshka_test.go deleted file mode 100644 index 18c4803e71..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/matryoshka_test.go +++ /dev/null @@ -1,228 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Tests a Go CGI program running under a Go CGI host process. -// Further, the two programs are the same binary, just checking -// their environment to figure out what mode to run in. - -package cgi - -import ( - "bytes" - "errors" - "fmt" - "io" - "net/http" - "net/http/httptest" - "os" - "runtime" - "testing" - "time" -) - -// This test is a CGI host (testing host.go) that runs its own binary -// as a child process testing the other half of CGI (child.go). -func TestHostingOurselves(t *testing.T) { - if runtime.GOOS == "nacl" { - t.Skip("skipping on nacl") - } - - h := &Handler{ - Path: os.Args[0], - Root: "/test.go", - Args: []string{"-test.run=TestBeChildCGIProcess"}, - } - expectedMap := map[string]string{ - "test": "Hello CGI-in-CGI", - "param-a": "b", - "param-foo": "bar", - "env-GATEWAY_INTERFACE": "CGI/1.1", - "env-HTTP_HOST": "example.com", - "env-PATH_INFO": "", - "env-QUERY_STRING": "foo=bar&a=b", - "env-REMOTE_ADDR": "1.2.3.4", - "env-REMOTE_HOST": "1.2.3.4", - "env-REQUEST_METHOD": "GET", - "env-REQUEST_URI": "/test.go?foo=bar&a=b", - "env-SCRIPT_FILENAME": os.Args[0], - "env-SCRIPT_NAME": "/test.go", - "env-SERVER_NAME": "example.com", - "env-SERVER_PORT": "80", - "env-SERVER_SOFTWARE": "go", - } - replay := runCgiTest(t, h, "GET /test.go?foo=bar&a=b HTTP/1.0\nHost: example.com\n\n", expectedMap) - - if expected, got := "text/html; charset=utf-8", replay.Header().Get("Content-Type"); got != expected { - t.Errorf("got a Content-Type of %q; expected %q", got, expected) - } - if expected, got := "X-Test-Value", replay.Header().Get("X-Test-Header"); got != expected { - t.Errorf("got a X-Test-Header of %q; expected %q", got, expected) - } -} - -type customWriterRecorder struct { - w io.Writer - *httptest.ResponseRecorder -} - -func (r *customWriterRecorder) Write(p []byte) (n int, err error) { - return r.w.Write(p) -} - -type limitWriter struct { - w io.Writer - n int -} - -func (w *limitWriter) Write(p []byte) (n int, err error) { - if len(p) > w.n { - p = p[:w.n] - } - if len(p) > 0 { - n, err = w.w.Write(p) - w.n -= n - } - if w.n == 0 { - err = errors.New("past write limit") - } - return -} - -// If there's an error copying the child's output to the parent, test -// that we kill the child. -func TestKillChildAfterCopyError(t *testing.T) { - if runtime.GOOS == "nacl" { - t.Skip("skipping on nacl") - } - - defer func() { testHookStartProcess = nil }() - proc := make(chan *os.Process, 1) - testHookStartProcess = func(p *os.Process) { - proc <- p - } - - h := &Handler{ - Path: os.Args[0], - Root: "/test.go", - Args: []string{"-test.run=TestBeChildCGIProcess"}, - } - req, _ := http.NewRequest("GET", "http://example.com/test.cgi?write-forever=1", nil) - rec := httptest.NewRecorder() - var out bytes.Buffer - const writeLen = 50 << 10 - rw := &customWriterRecorder{&limitWriter{&out, writeLen}, rec} - - donec := make(chan bool, 1) - go func() { - h.ServeHTTP(rw, req) - donec <- true - }() - - select { - case <-donec: - if out.Len() != writeLen || out.Bytes()[0] != 'a' { - t.Errorf("unexpected output: %q", out.Bytes()) - } - case <-time.After(5 * time.Second): - t.Errorf("timeout. ServeHTTP hung and didn't kill the child process?") - select { - case p := <-proc: - p.Kill() - t.Logf("killed process") - default: - t.Logf("didn't kill process") - } - } -} - -// Test that a child handler writing only headers works. -// golang.org/issue/7196 -func TestChildOnlyHeaders(t *testing.T) { - if runtime.GOOS == "nacl" { - t.Skip("skipping on nacl") - } - - h := &Handler{ - Path: os.Args[0], - Root: "/test.go", - Args: []string{"-test.run=TestBeChildCGIProcess"}, - } - expectedMap := map[string]string{ - "_body": "", - } - replay := runCgiTest(t, h, "GET /test.go?no-body=1 HTTP/1.0\nHost: example.com\n\n", expectedMap) - if expected, got := "X-Test-Value", replay.Header().Get("X-Test-Header"); got != expected { - t.Errorf("got a X-Test-Header of %q; expected %q", got, expected) - } -} - -// golang.org/issue/7198 -func Test500WithNoHeaders(t *testing.T) { want500Test(t, "/immediate-disconnect") } -func Test500WithNoContentType(t *testing.T) { want500Test(t, "/no-content-type") } -func Test500WithEmptyHeaders(t *testing.T) { want500Test(t, "/empty-headers") } - -func want500Test(t *testing.T, path string) { - h := &Handler{ - Path: os.Args[0], - Root: "/test.go", - Args: []string{"-test.run=TestBeChildCGIProcess"}, - } - expectedMap := map[string]string{ - "_body": "", - } - replay := runCgiTest(t, h, "GET "+path+" HTTP/1.0\nHost: example.com\n\n", expectedMap) - if replay.Code != 500 { - t.Errorf("Got code %d; want 500", replay.Code) - } -} - -type neverEnding byte - -func (b neverEnding) Read(p []byte) (n int, err error) { - for i := range p { - p[i] = byte(b) - } - return len(p), nil -} - -// Note: not actually a test. -func TestBeChildCGIProcess(t *testing.T) { - if os.Getenv("REQUEST_METHOD") == "" { - // Not in a CGI environment; skipping test. - return - } - switch os.Getenv("REQUEST_URI") { - case "/immediate-disconnect": - os.Exit(0) - case "/no-content-type": - fmt.Printf("Content-Length: 6\n\nHello\n") - os.Exit(0) - case "/empty-headers": - fmt.Printf("\nHello") - os.Exit(0) - } - Serve(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { - rw.Header().Set("X-Test-Header", "X-Test-Value") - req.ParseForm() - if req.FormValue("no-body") == "1" { - return - } - if req.FormValue("write-forever") == "1" { - io.Copy(rw, neverEnding('a')) - for { - time.Sleep(5 * time.Second) // hang forever, until killed - } - } - fmt.Fprintf(rw, "test=Hello CGI-in-CGI\n") - for k, vv := range req.Form { - for _, v := range vv { - fmt.Fprintf(rw, "param-%s=%s\n", k, v) - } - } - for _, kv := range os.Environ() { - fmt.Fprintf(rw, "env-%s\n", kv) - } - })) - os.Exit(0) -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/plan9_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/plan9_test.go deleted file mode 100644 index c8235831b0..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/plan9_test.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build plan9 - -package cgi - -import ( - "os" - "strconv" - "testing" -) - -func isProcessRunning(t *testing.T, pid int) bool { - _, err := os.Stat("/proc/" + strconv.Itoa(pid)) - return err == nil -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/posix_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/posix_test.go deleted file mode 100644 index 5ff9e7d5eb..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cgi/posix_test.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !plan9 - -package cgi - -import ( - "os" - "syscall" - "testing" -) - -func isProcessRunning(t *testing.T, pid int) bool { - p, err := os.FindProcess(pid) - if err != nil { - return false - } - return p.Signal(syscall.Signal(0)) == nil -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/chunked_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/chunked_test.go deleted file mode 100644 index 34544790af..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/chunked_test.go +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This code is duplicated in net/http and net/http/httputil. -// Please make any changes in both files. - -package http - -import ( - "bufio" - "bytes" - "fmt" - "io" - "io/ioutil" - "strings" - "testing" -) - -func TestChunk(t *testing.T) { - var b bytes.Buffer - - w := newChunkedWriter(&b) - const chunk1 = "hello, " - const chunk2 = "world! 0123456789abcdef" - w.Write([]byte(chunk1)) - w.Write([]byte(chunk2)) - w.Close() - - if g, e := b.String(), "7\r\nhello, \r\n17\r\nworld! 0123456789abcdef\r\n0\r\n"; g != e { - t.Fatalf("chunk writer wrote %q; want %q", g, e) - } - - r := newChunkedReader(&b) - data, err := ioutil.ReadAll(r) - if err != nil { - t.Logf(`data: "%s"`, data) - t.Fatalf("ReadAll from reader: %v", err) - } - if g, e := string(data), chunk1+chunk2; g != e { - t.Errorf("chunk reader read %q; want %q", g, e) - } -} - -func TestChunkReadMultiple(t *testing.T) { - // Bunch of small chunks, all read together. - { - var b bytes.Buffer - w := newChunkedWriter(&b) - w.Write([]byte("foo")) - w.Write([]byte("bar")) - w.Close() - - r := newChunkedReader(&b) - buf := make([]byte, 10) - n, err := r.Read(buf) - if n != 6 || err != io.EOF { - t.Errorf("Read = %d, %v; want 6, EOF", n, err) - } - buf = buf[:n] - if string(buf) != "foobar" { - t.Errorf("Read = %q; want %q", buf, "foobar") - } - } - - // One big chunk followed by a little chunk, but the small bufio.Reader size - // should prevent the second chunk header from being read. - { - var b bytes.Buffer - w := newChunkedWriter(&b) - // fillBufChunk is 11 bytes + 3 bytes header + 2 bytes footer = 16 bytes, - // the same as the bufio ReaderSize below (the minimum), so even - // though we're going to try to Read with a buffer larger enough to also - // receive "foo", the second chunk header won't be read yet. - const fillBufChunk = "0123456789a" - const shortChunk = "foo" - w.Write([]byte(fillBufChunk)) - w.Write([]byte(shortChunk)) - w.Close() - - r := newChunkedReader(bufio.NewReaderSize(&b, 16)) - buf := make([]byte, len(fillBufChunk)+len(shortChunk)) - n, err := r.Read(buf) - if n != len(fillBufChunk) || err != nil { - t.Errorf("Read = %d, %v; want %d, nil", n, err, len(fillBufChunk)) - } - buf = buf[:n] - if string(buf) != fillBufChunk { - t.Errorf("Read = %q; want %q", buf, fillBufChunk) - } - - n, err = r.Read(buf) - if n != len(shortChunk) || err != io.EOF { - t.Errorf("Read = %d, %v; want %d, EOF", n, err, len(shortChunk)) - } - } - - // And test that we see an EOF chunk, even though our buffer is already full: - { - r := newChunkedReader(bufio.NewReader(strings.NewReader("3\r\nfoo\r\n0\r\n"))) - buf := make([]byte, 3) - n, err := r.Read(buf) - if n != 3 || err != io.EOF { - t.Errorf("Read = %d, %v; want 3, EOF", n, err) - } - if string(buf) != "foo" { - t.Errorf("buf = %q; want foo", buf) - } - } -} - -func TestChunkReaderAllocs(t *testing.T) { - if testing.Short() { - t.Skip("skipping in short mode") - } - var buf bytes.Buffer - w := newChunkedWriter(&buf) - a, b, c := []byte("aaaaaa"), []byte("bbbbbbbbbbbb"), []byte("cccccccccccccccccccccccc") - w.Write(a) - w.Write(b) - w.Write(c) - w.Close() - - readBuf := make([]byte, len(a)+len(b)+len(c)+1) - byter := bytes.NewReader(buf.Bytes()) - bufr := bufio.NewReader(byter) - mallocs := testing.AllocsPerRun(100, func() { - byter.Seek(0, 0) - bufr.Reset(byter) - r := newChunkedReader(bufr) - n, err := io.ReadFull(r, readBuf) - if n != len(readBuf)-1 { - t.Fatalf("read %d bytes; want %d", n, len(readBuf)-1) - } - if err != io.ErrUnexpectedEOF { - t.Fatalf("read error = %v; want ErrUnexpectedEOF", err) - } - }) - if mallocs > 1.5 { - t.Errorf("mallocs = %v; want 1", mallocs) - } -} - -func TestParseHexUint(t *testing.T) { - for i := uint64(0); i <= 1234; i++ { - line := []byte(fmt.Sprintf("%x", i)) - got, err := parseHexUint(line) - if err != nil { - t.Fatalf("on %d: %v", i, err) - } - if got != i { - t.Errorf("for input %q = %d; want %d", line, got, i) - } - } - _, err := parseHexUint([]byte("bogus")) - if err == nil { - t.Error("expected error on bogus input") - } -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/client_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/client_test.go deleted file mode 100644 index 6392c1baf3..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/client_test.go +++ /dev/null @@ -1,1038 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Tests for client.go - -package http_test - -import ( - "bytes" - "crypto/tls" - "crypto/x509" - "encoding/base64" - "errors" - "fmt" - "io" - "io/ioutil" - "log" - "net" - . "net/http" - "net/http/httptest" - "net/url" - "reflect" - "sort" - "strconv" - "strings" - "sync" - "testing" - "time" -) - -var robotsTxtHandler = HandlerFunc(func(w ResponseWriter, r *Request) { - w.Header().Set("Last-Modified", "sometime") - fmt.Fprintf(w, "User-agent: go\nDisallow: /something/") -}) - -// pedanticReadAll works like ioutil.ReadAll but additionally -// verifies that r obeys the documented io.Reader contract. -func pedanticReadAll(r io.Reader) (b []byte, err error) { - var bufa [64]byte - buf := bufa[:] - for { - n, err := r.Read(buf) - if n == 0 && err == nil { - return nil, fmt.Errorf("Read: n=0 with err=nil") - } - b = append(b, buf[:n]...) - if err == io.EOF { - n, err := r.Read(buf) - if n != 0 || err != io.EOF { - return nil, fmt.Errorf("Read: n=%d err=%#v after EOF", n, err) - } - return b, nil - } - if err != nil { - return b, err - } - } -} - -type chanWriter chan string - -func (w chanWriter) Write(p []byte) (n int, err error) { - w <- string(p) - return len(p), nil -} - -func TestClient(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(robotsTxtHandler) - defer ts.Close() - - r, err := Get(ts.URL) - var b []byte - if err == nil { - b, err = pedanticReadAll(r.Body) - r.Body.Close() - } - if err != nil { - t.Error(err) - } else if s := string(b); !strings.HasPrefix(s, "User-agent:") { - t.Errorf("Incorrect page body (did not begin with User-agent): %q", s) - } -} - -func TestClientHead(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(robotsTxtHandler) - defer ts.Close() - - r, err := Head(ts.URL) - if err != nil { - t.Fatal(err) - } - if _, ok := r.Header["Last-Modified"]; !ok { - t.Error("Last-Modified header not found.") - } -} - -type recordingTransport struct { - req *Request -} - -func (t *recordingTransport) RoundTrip(req *Request) (resp *Response, err error) { - t.req = req - return nil, errors.New("dummy impl") -} - -func TestGetRequestFormat(t *testing.T) { - defer afterTest(t) - tr := &recordingTransport{} - client := &Client{Transport: tr} - url := "http://dummy.faketld/" - client.Get(url) // Note: doesn't hit network - if tr.req.Method != "GET" { - t.Errorf("expected method %q; got %q", "GET", tr.req.Method) - } - if tr.req.URL.String() != url { - t.Errorf("expected URL %q; got %q", url, tr.req.URL.String()) - } - if tr.req.Header == nil { - t.Errorf("expected non-nil request Header") - } -} - -func TestPostRequestFormat(t *testing.T) { - defer afterTest(t) - tr := &recordingTransport{} - client := &Client{Transport: tr} - - url := "http://dummy.faketld/" - json := `{"key":"value"}` - b := strings.NewReader(json) - client.Post(url, "application/json", b) // Note: doesn't hit network - - if tr.req.Method != "POST" { - t.Errorf("got method %q, want %q", tr.req.Method, "POST") - } - if tr.req.URL.String() != url { - t.Errorf("got URL %q, want %q", tr.req.URL.String(), url) - } - if tr.req.Header == nil { - t.Fatalf("expected non-nil request Header") - } - if tr.req.Close { - t.Error("got Close true, want false") - } - if g, e := tr.req.ContentLength, int64(len(json)); g != e { - t.Errorf("got ContentLength %d, want %d", g, e) - } -} - -func TestPostFormRequestFormat(t *testing.T) { - defer afterTest(t) - tr := &recordingTransport{} - client := &Client{Transport: tr} - - urlStr := "http://dummy.faketld/" - form := make(url.Values) - form.Set("foo", "bar") - form.Add("foo", "bar2") - form.Set("bar", "baz") - client.PostForm(urlStr, form) // Note: doesn't hit network - - if tr.req.Method != "POST" { - t.Errorf("got method %q, want %q", tr.req.Method, "POST") - } - if tr.req.URL.String() != urlStr { - t.Errorf("got URL %q, want %q", tr.req.URL.String(), urlStr) - } - if tr.req.Header == nil { - t.Fatalf("expected non-nil request Header") - } - if g, e := tr.req.Header.Get("Content-Type"), "application/x-www-form-urlencoded"; g != e { - t.Errorf("got Content-Type %q, want %q", g, e) - } - if tr.req.Close { - t.Error("got Close true, want false") - } - // Depending on map iteration, body can be either of these. - expectedBody := "foo=bar&foo=bar2&bar=baz" - expectedBody1 := "bar=baz&foo=bar&foo=bar2" - if g, e := tr.req.ContentLength, int64(len(expectedBody)); g != e { - t.Errorf("got ContentLength %d, want %d", g, e) - } - bodyb, err := ioutil.ReadAll(tr.req.Body) - if err != nil { - t.Fatalf("ReadAll on req.Body: %v", err) - } - if g := string(bodyb); g != expectedBody && g != expectedBody1 { - t.Errorf("got body %q, want %q or %q", g, expectedBody, expectedBody1) - } -} - -func TestClientRedirects(t *testing.T) { - defer afterTest(t) - var ts *httptest.Server - ts = httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - n, _ := strconv.Atoi(r.FormValue("n")) - // Test Referer header. (7 is arbitrary position to test at) - if n == 7 { - if g, e := r.Referer(), ts.URL+"/?n=6"; e != g { - t.Errorf("on request ?n=7, expected referer of %q; got %q", e, g) - } - } - if n < 15 { - Redirect(w, r, fmt.Sprintf("/?n=%d", n+1), StatusFound) - return - } - fmt.Fprintf(w, "n=%d", n) - })) - defer ts.Close() - - c := &Client{} - _, err := c.Get(ts.URL) - if e, g := "Get /?n=10: stopped after 10 redirects", fmt.Sprintf("%v", err); e != g { - t.Errorf("with default client Get, expected error %q, got %q", e, g) - } - - // HEAD request should also have the ability to follow redirects. - _, err = c.Head(ts.URL) - if e, g := "Head /?n=10: stopped after 10 redirects", fmt.Sprintf("%v", err); e != g { - t.Errorf("with default client Head, expected error %q, got %q", e, g) - } - - // Do should also follow redirects. - greq, _ := NewRequest("GET", ts.URL, nil) - _, err = c.Do(greq) - if e, g := "Get /?n=10: stopped after 10 redirects", fmt.Sprintf("%v", err); e != g { - t.Errorf("with default client Do, expected error %q, got %q", e, g) - } - - var checkErr error - var lastVia []*Request - c = &Client{CheckRedirect: func(_ *Request, via []*Request) error { - lastVia = via - return checkErr - }} - res, err := c.Get(ts.URL) - if err != nil { - t.Fatalf("Get error: %v", err) - } - res.Body.Close() - finalUrl := res.Request.URL.String() - if e, g := "", fmt.Sprintf("%v", err); e != g { - t.Errorf("with custom client, expected error %q, got %q", e, g) - } - if !strings.HasSuffix(finalUrl, "/?n=15") { - t.Errorf("expected final url to end in /?n=15; got url %q", finalUrl) - } - if e, g := 15, len(lastVia); e != g { - t.Errorf("expected lastVia to have contained %d elements; got %d", e, g) - } - - checkErr = errors.New("no redirects allowed") - res, err = c.Get(ts.URL) - if urlError, ok := err.(*url.Error); !ok || urlError.Err != checkErr { - t.Errorf("with redirects forbidden, expected a *url.Error with our 'no redirects allowed' error inside; got %#v (%q)", err, err) - } - if res == nil { - t.Fatalf("Expected a non-nil Response on CheckRedirect failure (http://golang.org/issue/3795)") - } - res.Body.Close() - if res.Header.Get("Location") == "" { - t.Errorf("no Location header in Response") - } -} - -func TestPostRedirects(t *testing.T) { - defer afterTest(t) - var log struct { - sync.Mutex - bytes.Buffer - } - var ts *httptest.Server - ts = httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - log.Lock() - fmt.Fprintf(&log.Buffer, "%s %s ", r.Method, r.RequestURI) - log.Unlock() - if v := r.URL.Query().Get("code"); v != "" { - code, _ := strconv.Atoi(v) - if code/100 == 3 { - w.Header().Set("Location", ts.URL) - } - w.WriteHeader(code) - } - })) - defer ts.Close() - tests := []struct { - suffix string - want int // response code - }{ - {"/", 200}, - {"/?code=301", 301}, - {"/?code=302", 200}, - {"/?code=303", 200}, - {"/?code=404", 404}, - } - for _, tt := range tests { - res, err := Post(ts.URL+tt.suffix, "text/plain", strings.NewReader("Some content")) - if err != nil { - t.Fatal(err) - } - if res.StatusCode != tt.want { - t.Errorf("POST %s: status code = %d; want %d", tt.suffix, res.StatusCode, tt.want) - } - } - log.Lock() - got := log.String() - log.Unlock() - want := "POST / POST /?code=301 POST /?code=302 GET / POST /?code=303 GET / POST /?code=404 " - if got != want { - t.Errorf("Log differs.\n Got: %q\nWant: %q", got, want) - } -} - -var expectedCookies = []*Cookie{ - {Name: "ChocolateChip", Value: "tasty"}, - {Name: "First", Value: "Hit"}, - {Name: "Second", Value: "Hit"}, -} - -var echoCookiesRedirectHandler = HandlerFunc(func(w ResponseWriter, r *Request) { - for _, cookie := range r.Cookies() { - SetCookie(w, cookie) - } - if r.URL.Path == "/" { - SetCookie(w, expectedCookies[1]) - Redirect(w, r, "/second", StatusMovedPermanently) - } else { - SetCookie(w, expectedCookies[2]) - w.Write([]byte("hello")) - } -}) - -func TestClientSendsCookieFromJar(t *testing.T) { - tr := &recordingTransport{} - client := &Client{Transport: tr} - client.Jar = &TestJar{perURL: make(map[string][]*Cookie)} - us := "http://dummy.faketld/" - u, _ := url.Parse(us) - client.Jar.SetCookies(u, expectedCookies) - - client.Get(us) // Note: doesn't hit network - matchReturnedCookies(t, expectedCookies, tr.req.Cookies()) - - client.Head(us) // Note: doesn't hit network - matchReturnedCookies(t, expectedCookies, tr.req.Cookies()) - - client.Post(us, "text/plain", strings.NewReader("body")) // Note: doesn't hit network - matchReturnedCookies(t, expectedCookies, tr.req.Cookies()) - - client.PostForm(us, url.Values{}) // Note: doesn't hit network - matchReturnedCookies(t, expectedCookies, tr.req.Cookies()) - - req, _ := NewRequest("GET", us, nil) - client.Do(req) // Note: doesn't hit network - matchReturnedCookies(t, expectedCookies, tr.req.Cookies()) - - req, _ = NewRequest("POST", us, nil) - client.Do(req) // Note: doesn't hit network - matchReturnedCookies(t, expectedCookies, tr.req.Cookies()) -} - -// Just enough correctness for our redirect tests. Uses the URL.Host as the -// scope of all cookies. -type TestJar struct { - m sync.Mutex - perURL map[string][]*Cookie -} - -func (j *TestJar) SetCookies(u *url.URL, cookies []*Cookie) { - j.m.Lock() - defer j.m.Unlock() - if j.perURL == nil { - j.perURL = make(map[string][]*Cookie) - } - j.perURL[u.Host] = cookies -} - -func (j *TestJar) Cookies(u *url.URL) []*Cookie { - j.m.Lock() - defer j.m.Unlock() - return j.perURL[u.Host] -} - -func TestRedirectCookiesJar(t *testing.T) { - defer afterTest(t) - var ts *httptest.Server - ts = httptest.NewServer(echoCookiesRedirectHandler) - defer ts.Close() - c := &Client{ - Jar: new(TestJar), - } - u, _ := url.Parse(ts.URL) - c.Jar.SetCookies(u, []*Cookie{expectedCookies[0]}) - resp, err := c.Get(ts.URL) - if err != nil { - t.Fatalf("Get: %v", err) - } - resp.Body.Close() - matchReturnedCookies(t, expectedCookies, resp.Cookies()) -} - -func matchReturnedCookies(t *testing.T, expected, given []*Cookie) { - if len(given) != len(expected) { - t.Logf("Received cookies: %v", given) - t.Errorf("Expected %d cookies, got %d", len(expected), len(given)) - } - for _, ec := range expected { - foundC := false - for _, c := range given { - if ec.Name == c.Name && ec.Value == c.Value { - foundC = true - break - } - } - if !foundC { - t.Errorf("Missing cookie %v", ec) - } - } -} - -func TestJarCalls(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - pathSuffix := r.RequestURI[1:] - if r.RequestURI == "/nosetcookie" { - return // dont set cookies for this path - } - SetCookie(w, &Cookie{Name: "name" + pathSuffix, Value: "val" + pathSuffix}) - if r.RequestURI == "/" { - Redirect(w, r, "http://secondhost.fake/secondpath", 302) - } - })) - defer ts.Close() - jar := new(RecordingJar) - c := &Client{ - Jar: jar, - Transport: &Transport{ - Dial: func(_ string, _ string) (net.Conn, error) { - return net.Dial("tcp", ts.Listener.Addr().String()) - }, - }, - } - _, err := c.Get("http://firsthost.fake/") - if err != nil { - t.Fatal(err) - } - _, err = c.Get("http://firsthost.fake/nosetcookie") - if err != nil { - t.Fatal(err) - } - got := jar.log.String() - want := `Cookies("http://firsthost.fake/") -SetCookie("http://firsthost.fake/", [name=val]) -Cookies("http://secondhost.fake/secondpath") -SetCookie("http://secondhost.fake/secondpath", [namesecondpath=valsecondpath]) -Cookies("http://firsthost.fake/nosetcookie") -` - if got != want { - t.Errorf("Got Jar calls:\n%s\nWant:\n%s", got, want) - } -} - -// RecordingJar keeps a log of calls made to it, without -// tracking any cookies. -type RecordingJar struct { - mu sync.Mutex - log bytes.Buffer -} - -func (j *RecordingJar) SetCookies(u *url.URL, cookies []*Cookie) { - j.logf("SetCookie(%q, %v)\n", u, cookies) -} - -func (j *RecordingJar) Cookies(u *url.URL) []*Cookie { - j.logf("Cookies(%q)\n", u) - return nil -} - -func (j *RecordingJar) logf(format string, args ...interface{}) { - j.mu.Lock() - defer j.mu.Unlock() - fmt.Fprintf(&j.log, format, args...) -} - -func TestStreamingGet(t *testing.T) { - defer afterTest(t) - say := make(chan string) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - w.(Flusher).Flush() - for str := range say { - w.Write([]byte(str)) - w.(Flusher).Flush() - } - })) - defer ts.Close() - - c := &Client{} - res, err := c.Get(ts.URL) - if err != nil { - t.Fatal(err) - } - var buf [10]byte - for _, str := range []string{"i", "am", "also", "known", "as", "comet"} { - say <- str - n, err := io.ReadFull(res.Body, buf[0:len(str)]) - if err != nil { - t.Fatalf("ReadFull on %q: %v", str, err) - } - if n != len(str) { - t.Fatalf("Receiving %q, only read %d bytes", str, n) - } - got := string(buf[0:n]) - if got != str { - t.Fatalf("Expected %q, got %q", str, got) - } - } - close(say) - _, err = io.ReadFull(res.Body, buf[0:1]) - if err != io.EOF { - t.Fatalf("at end expected EOF, got %v", err) - } -} - -type writeCountingConn struct { - net.Conn - count *int -} - -func (c *writeCountingConn) Write(p []byte) (int, error) { - *c.count++ - return c.Conn.Write(p) -} - -// TestClientWrites verifies that client requests are buffered and we -// don't send a TCP packet per line of the http request + body. -func TestClientWrites(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - })) - defer ts.Close() - - writes := 0 - dialer := func(netz string, addr string) (net.Conn, error) { - c, err := net.Dial(netz, addr) - if err == nil { - c = &writeCountingConn{c, &writes} - } - return c, err - } - c := &Client{Transport: &Transport{Dial: dialer}} - - _, err := c.Get(ts.URL) - if err != nil { - t.Fatal(err) - } - if writes != 1 { - t.Errorf("Get request did %d Write calls, want 1", writes) - } - - writes = 0 - _, err = c.PostForm(ts.URL, url.Values{"foo": {"bar"}}) - if err != nil { - t.Fatal(err) - } - if writes != 1 { - t.Errorf("Post request did %d Write calls, want 1", writes) - } -} - -func TestClientInsecureTransport(t *testing.T) { - defer afterTest(t) - ts := httptest.NewTLSServer(HandlerFunc(func(w ResponseWriter, r *Request) { - w.Write([]byte("Hello")) - })) - errc := make(chanWriter, 10) // but only expecting 1 - ts.Config.ErrorLog = log.New(errc, "", 0) - defer ts.Close() - - // TODO(bradfitz): add tests for skipping hostname checks too? - // would require a new cert for testing, and probably - // redundant with these tests. - for _, insecure := range []bool{true, false} { - tr := &Transport{ - TLSClientConfig: &tls.Config{ - InsecureSkipVerify: insecure, - }, - } - defer tr.CloseIdleConnections() - c := &Client{Transport: tr} - res, err := c.Get(ts.URL) - if (err == nil) != insecure { - t.Errorf("insecure=%v: got unexpected err=%v", insecure, err) - } - if res != nil { - res.Body.Close() - } - } - - select { - case v := <-errc: - if !strings.Contains(v, "TLS handshake error") { - t.Errorf("expected an error log message containing 'TLS handshake error'; got %q", v) - } - case <-time.After(5 * time.Second): - t.Errorf("timeout waiting for logged error") - } - -} - -func TestClientErrorWithRequestURI(t *testing.T) { - defer afterTest(t) - req, _ := NewRequest("GET", "http://localhost:1234/", nil) - req.RequestURI = "/this/field/is/illegal/and/should/error/" - _, err := DefaultClient.Do(req) - if err == nil { - t.Fatalf("expected an error") - } - if !strings.Contains(err.Error(), "RequestURI") { - t.Errorf("wanted error mentioning RequestURI; got error: %v", err) - } -} - -func newTLSTransport(t *testing.T, ts *httptest.Server) *Transport { - certs := x509.NewCertPool() - for _, c := range ts.TLS.Certificates { - roots, err := x509.ParseCertificates(c.Certificate[len(c.Certificate)-1]) - if err != nil { - t.Fatalf("error parsing server's root cert: %v", err) - } - for _, root := range roots { - certs.AddCert(root) - } - } - return &Transport{ - TLSClientConfig: &tls.Config{RootCAs: certs}, - } -} - -func TestClientWithCorrectTLSServerName(t *testing.T) { - defer afterTest(t) - ts := httptest.NewTLSServer(HandlerFunc(func(w ResponseWriter, r *Request) { - if r.TLS.ServerName != "127.0.0.1" { - t.Errorf("expected client to set ServerName 127.0.0.1, got: %q", r.TLS.ServerName) - } - })) - defer ts.Close() - - c := &Client{Transport: newTLSTransport(t, ts)} - if _, err := c.Get(ts.URL); err != nil { - t.Fatalf("expected successful TLS connection, got error: %v", err) - } -} - -func TestClientWithIncorrectTLSServerName(t *testing.T) { - defer afterTest(t) - ts := httptest.NewTLSServer(HandlerFunc(func(w ResponseWriter, r *Request) {})) - defer ts.Close() - errc := make(chanWriter, 10) // but only expecting 1 - ts.Config.ErrorLog = log.New(errc, "", 0) - - trans := newTLSTransport(t, ts) - trans.TLSClientConfig.ServerName = "badserver" - c := &Client{Transport: trans} - _, err := c.Get(ts.URL) - if err == nil { - t.Fatalf("expected an error") - } - if !strings.Contains(err.Error(), "127.0.0.1") || !strings.Contains(err.Error(), "badserver") { - t.Errorf("wanted error mentioning 127.0.0.1 and badserver; got error: %v", err) - } - select { - case v := <-errc: - if !strings.Contains(v, "TLS handshake error") { - t.Errorf("expected an error log message containing 'TLS handshake error'; got %q", v) - } - case <-time.After(5 * time.Second): - t.Errorf("timeout waiting for logged error") - } -} - -// Test for golang.org/issue/5829; the Transport should respect TLSClientConfig.ServerName -// when not empty. -// -// tls.Config.ServerName (non-empty, set to "example.com") takes -// precedence over "some-other-host.tld" which previously incorrectly -// took precedence. We don't actually connect to (or even resolve) -// "some-other-host.tld", though, because of the Transport.Dial hook. -// -// The httptest.Server has a cert with "example.com" as its name. -func TestTransportUsesTLSConfigServerName(t *testing.T) { - defer afterTest(t) - ts := httptest.NewTLSServer(HandlerFunc(func(w ResponseWriter, r *Request) { - w.Write([]byte("Hello")) - })) - defer ts.Close() - - tr := newTLSTransport(t, ts) - tr.TLSClientConfig.ServerName = "example.com" // one of httptest's Server cert names - tr.Dial = func(netw, addr string) (net.Conn, error) { - return net.Dial(netw, ts.Listener.Addr().String()) - } - defer tr.CloseIdleConnections() - c := &Client{Transport: tr} - res, err := c.Get("https://some-other-host.tld/") - if err != nil { - t.Fatal(err) - } - res.Body.Close() -} - -func TestResponseSetsTLSConnectionState(t *testing.T) { - defer afterTest(t) - ts := httptest.NewTLSServer(HandlerFunc(func(w ResponseWriter, r *Request) { - w.Write([]byte("Hello")) - })) - defer ts.Close() - - tr := newTLSTransport(t, ts) - tr.TLSClientConfig.CipherSuites = []uint16{tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA} - tr.Dial = func(netw, addr string) (net.Conn, error) { - return net.Dial(netw, ts.Listener.Addr().String()) - } - defer tr.CloseIdleConnections() - c := &Client{Transport: tr} - res, err := c.Get("https://example.com/") - if err != nil { - t.Fatal(err) - } - defer res.Body.Close() - if res.TLS == nil { - t.Fatal("Response didn't set TLS Connection State.") - } - if got, want := res.TLS.CipherSuite, tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA; got != want { - t.Errorf("TLS Cipher Suite = %d; want %d", got, want) - } -} - -// Verify Response.ContentLength is populated. http://golang.org/issue/4126 -func TestClientHeadContentLength(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - if v := r.FormValue("cl"); v != "" { - w.Header().Set("Content-Length", v) - } - })) - defer ts.Close() - tests := []struct { - suffix string - want int64 - }{ - {"/?cl=1234", 1234}, - {"/?cl=0", 0}, - {"", -1}, - } - for _, tt := range tests { - req, _ := NewRequest("HEAD", ts.URL+tt.suffix, nil) - res, err := DefaultClient.Do(req) - if err != nil { - t.Fatal(err) - } - if res.ContentLength != tt.want { - t.Errorf("Content-Length = %d; want %d", res.ContentLength, tt.want) - } - bs, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatal(err) - } - if len(bs) != 0 { - t.Errorf("Unexpected content: %q", bs) - } - } -} - -func TestEmptyPasswordAuth(t *testing.T) { - defer afterTest(t) - gopher := "gopher" - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - auth := r.Header.Get("Authorization") - if strings.HasPrefix(auth, "Basic ") { - encoded := auth[6:] - decoded, err := base64.StdEncoding.DecodeString(encoded) - if err != nil { - t.Fatal(err) - } - expected := gopher + ":" - s := string(decoded) - if expected != s { - t.Errorf("Invalid Authorization header. Got %q, wanted %q", s, expected) - } - } else { - t.Errorf("Invalid auth %q", auth) - } - })) - defer ts.Close() - c := &Client{} - req, err := NewRequest("GET", ts.URL, nil) - if err != nil { - t.Fatal(err) - } - req.URL.User = url.User(gopher) - resp, err := c.Do(req) - if err != nil { - t.Fatal(err) - } - defer resp.Body.Close() -} - -func TestBasicAuth(t *testing.T) { - defer afterTest(t) - tr := &recordingTransport{} - client := &Client{Transport: tr} - - url := "http://My%20User:My%20Pass@dummy.faketld/" - expected := "My User:My Pass" - client.Get(url) - - if tr.req.Method != "GET" { - t.Errorf("got method %q, want %q", tr.req.Method, "GET") - } - if tr.req.URL.String() != url { - t.Errorf("got URL %q, want %q", tr.req.URL.String(), url) - } - if tr.req.Header == nil { - t.Fatalf("expected non-nil request Header") - } - auth := tr.req.Header.Get("Authorization") - if strings.HasPrefix(auth, "Basic ") { - encoded := auth[6:] - decoded, err := base64.StdEncoding.DecodeString(encoded) - if err != nil { - t.Fatal(err) - } - s := string(decoded) - if expected != s { - t.Errorf("Invalid Authorization header. Got %q, wanted %q", s, expected) - } - } else { - t.Errorf("Invalid auth %q", auth) - } -} - -func TestClientTimeout(t *testing.T) { - if testing.Short() { - t.Skip("skipping in short mode") - } - defer afterTest(t) - sawRoot := make(chan bool, 1) - sawSlow := make(chan bool, 1) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - if r.URL.Path == "/" { - sawRoot <- true - Redirect(w, r, "/slow", StatusFound) - return - } - if r.URL.Path == "/slow" { - w.Write([]byte("Hello")) - w.(Flusher).Flush() - sawSlow <- true - time.Sleep(2 * time.Second) - return - } - })) - defer ts.Close() - const timeout = 500 * time.Millisecond - c := &Client{ - Timeout: timeout, - } - - res, err := c.Get(ts.URL) - if err != nil { - t.Fatal(err) - } - - select { - case <-sawRoot: - // good. - default: - t.Fatal("handler never got / request") - } - - select { - case <-sawSlow: - // good. - default: - t.Fatal("handler never got /slow request") - } - - errc := make(chan error, 1) - go func() { - _, err := ioutil.ReadAll(res.Body) - errc <- err - res.Body.Close() - }() - - const failTime = timeout * 2 - select { - case err := <-errc: - if err == nil { - t.Error("expected error from ReadAll") - } - // Expected error. - case <-time.After(failTime): - t.Errorf("timeout after %v waiting for timeout of %v", failTime, timeout) - } -} - -func TestClientRedirectEatsBody(t *testing.T) { - defer afterTest(t) - saw := make(chan string, 2) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - saw <- r.RemoteAddr - if r.URL.Path == "/" { - Redirect(w, r, "/foo", StatusFound) // which includes a body - } - })) - defer ts.Close() - - res, err := Get(ts.URL) - if err != nil { - t.Fatal(err) - } - _, err = ioutil.ReadAll(res.Body) - if err != nil { - t.Fatal(err) - } - res.Body.Close() - - var first string - select { - case first = <-saw: - default: - t.Fatal("server didn't see a request") - } - - var second string - select { - case second = <-saw: - default: - t.Fatal("server didn't see a second request") - } - - if first != second { - t.Fatal("server saw different client ports before & after the redirect") - } -} - -// eofReaderFunc is an io.Reader that runs itself, and then returns io.EOF. -type eofReaderFunc func() - -func (f eofReaderFunc) Read(p []byte) (n int, err error) { - f() - return 0, io.EOF -} - -func TestClientTrailers(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - w.Header().Set("Connection", "close") - w.Header().Set("Trailer", "Server-Trailer-A, Server-Trailer-B") - w.Header().Add("Trailer", "Server-Trailer-C") - - var decl []string - for k := range r.Trailer { - decl = append(decl, k) - } - sort.Strings(decl) - - slurp, err := ioutil.ReadAll(r.Body) - if err != nil { - t.Errorf("Server reading request body: %v", err) - } - if string(slurp) != "foo" { - t.Errorf("Server read request body %q; want foo", slurp) - } - if r.Trailer == nil { - io.WriteString(w, "nil Trailer") - } else { - fmt.Fprintf(w, "decl: %v, vals: %s, %s", - decl, - r.Trailer.Get("Client-Trailer-A"), - r.Trailer.Get("Client-Trailer-B")) - } - - // TODO: golang.org/issue/7759: there's no way yet for - // the server to set trailers without hijacking, so do - // that for now, just to test the client. Later, in - // Go 1.4, it should be implicit that any mutations - // to w.Header() after the initial write are the - // trailers to be sent, if and only if they were - // previously declared with w.Header().Set("Trailer", - // ..keys..) - w.(Flusher).Flush() - conn, buf, _ := w.(Hijacker).Hijack() - t := Header{} - t.Set("Server-Trailer-A", "valuea") - t.Set("Server-Trailer-C", "valuec") // skipping B - buf.WriteString("0\r\n") // eof - t.Write(buf) - buf.WriteString("\r\n") // end of trailers - buf.Flush() - conn.Close() - })) - defer ts.Close() - - var req *Request - req, _ = NewRequest("POST", ts.URL, io.MultiReader( - eofReaderFunc(func() { - req.Trailer["Client-Trailer-A"] = []string{"valuea"} - }), - strings.NewReader("foo"), - eofReaderFunc(func() { - req.Trailer["Client-Trailer-B"] = []string{"valueb"} - }), - )) - req.Trailer = Header{ - "Client-Trailer-A": nil, // to be set later - "Client-Trailer-B": nil, // to be set later - } - req.ContentLength = -1 - res, err := DefaultClient.Do(req) - if err != nil { - t.Fatal(err) - } - if err := wantBody(res, err, "decl: [Client-Trailer-A Client-Trailer-B], vals: valuea, valueb"); err != nil { - t.Error(err) - } - want := Header{ - "Server-Trailer-A": []string{"valuea"}, - "Server-Trailer-B": nil, - "Server-Trailer-C": []string{"valuec"}, - } - if !reflect.DeepEqual(res.Trailer, want) { - t.Errorf("Response trailers = %#v; want %#v", res.Trailer, want) - } -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cookie_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cookie_test.go deleted file mode 100644 index f78f37299f..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cookie_test.go +++ /dev/null @@ -1,380 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http - -import ( - "bytes" - "encoding/json" - "fmt" - "log" - "os" - "reflect" - "strings" - "testing" - "time" -) - -var writeSetCookiesTests = []struct { - Cookie *Cookie - Raw string -}{ - { - &Cookie{Name: "cookie-1", Value: "v$1"}, - "cookie-1=v$1", - }, - { - &Cookie{Name: "cookie-2", Value: "two", MaxAge: 3600}, - "cookie-2=two; Max-Age=3600", - }, - { - &Cookie{Name: "cookie-3", Value: "three", Domain: ".example.com"}, - "cookie-3=three; Domain=example.com", - }, - { - &Cookie{Name: "cookie-4", Value: "four", Path: "/restricted/"}, - "cookie-4=four; Path=/restricted/", - }, - { - &Cookie{Name: "cookie-5", Value: "five", Domain: "wrong;bad.abc"}, - "cookie-5=five", - }, - { - &Cookie{Name: "cookie-6", Value: "six", Domain: "bad-.abc"}, - "cookie-6=six", - }, - { - &Cookie{Name: "cookie-7", Value: "seven", Domain: "127.0.0.1"}, - "cookie-7=seven; Domain=127.0.0.1", - }, - { - &Cookie{Name: "cookie-8", Value: "eight", Domain: "::1"}, - "cookie-8=eight", - }, - // The "special" cookies have values containing commas or spaces which - // are disallowed by RFC 6265 but are common in the wild. - { - &Cookie{Name: "special-1", Value: "a z"}, - `special-1=a z`, - }, - { - &Cookie{Name: "special-2", Value: " z"}, - `special-2=" z"`, - }, - { - &Cookie{Name: "special-3", Value: "a "}, - `special-3="a "`, - }, - { - &Cookie{Name: "special-4", Value: " "}, - `special-4=" "`, - }, - { - &Cookie{Name: "special-5", Value: "a,z"}, - `special-5=a,z`, - }, - { - &Cookie{Name: "special-6", Value: ",z"}, - `special-6=",z"`, - }, - { - &Cookie{Name: "special-7", Value: "a,"}, - `special-7="a,"`, - }, - { - &Cookie{Name: "special-8", Value: ","}, - `special-8=","`, - }, - { - &Cookie{Name: "empty-value", Value: ""}, - `empty-value=`, - }, -} - -func TestWriteSetCookies(t *testing.T) { - defer log.SetOutput(os.Stderr) - var logbuf bytes.Buffer - log.SetOutput(&logbuf) - - for i, tt := range writeSetCookiesTests { - if g, e := tt.Cookie.String(), tt.Raw; g != e { - t.Errorf("Test %d, expecting:\n%s\nGot:\n%s\n", i, e, g) - continue - } - } - - if got, sub := logbuf.String(), "dropping domain attribute"; !strings.Contains(got, sub) { - t.Errorf("Expected substring %q in log output. Got:\n%s", sub, got) - } -} - -type headerOnlyResponseWriter Header - -func (ho headerOnlyResponseWriter) Header() Header { - return Header(ho) -} - -func (ho headerOnlyResponseWriter) Write([]byte) (int, error) { - panic("NOIMPL") -} - -func (ho headerOnlyResponseWriter) WriteHeader(int) { - panic("NOIMPL") -} - -func TestSetCookie(t *testing.T) { - m := make(Header) - SetCookie(headerOnlyResponseWriter(m), &Cookie{Name: "cookie-1", Value: "one", Path: "/restricted/"}) - SetCookie(headerOnlyResponseWriter(m), &Cookie{Name: "cookie-2", Value: "two", MaxAge: 3600}) - if l := len(m["Set-Cookie"]); l != 2 { - t.Fatalf("expected %d cookies, got %d", 2, l) - } - if g, e := m["Set-Cookie"][0], "cookie-1=one; Path=/restricted/"; g != e { - t.Errorf("cookie #1: want %q, got %q", e, g) - } - if g, e := m["Set-Cookie"][1], "cookie-2=two; Max-Age=3600"; g != e { - t.Errorf("cookie #2: want %q, got %q", e, g) - } -} - -var addCookieTests = []struct { - Cookies []*Cookie - Raw string -}{ - { - []*Cookie{}, - "", - }, - { - []*Cookie{{Name: "cookie-1", Value: "v$1"}}, - "cookie-1=v$1", - }, - { - []*Cookie{ - {Name: "cookie-1", Value: "v$1"}, - {Name: "cookie-2", Value: "v$2"}, - {Name: "cookie-3", Value: "v$3"}, - }, - "cookie-1=v$1; cookie-2=v$2; cookie-3=v$3", - }, -} - -func TestAddCookie(t *testing.T) { - for i, tt := range addCookieTests { - req, _ := NewRequest("GET", "http://example.com/", nil) - for _, c := range tt.Cookies { - req.AddCookie(c) - } - if g := req.Header.Get("Cookie"); g != tt.Raw { - t.Errorf("Test %d:\nwant: %s\n got: %s\n", i, tt.Raw, g) - continue - } - } -} - -var readSetCookiesTests = []struct { - Header Header - Cookies []*Cookie -}{ - { - Header{"Set-Cookie": {"Cookie-1=v$1"}}, - []*Cookie{{Name: "Cookie-1", Value: "v$1", Raw: "Cookie-1=v$1"}}, - }, - { - Header{"Set-Cookie": {"NID=99=YsDT5i3E-CXax-; expires=Wed, 23-Nov-2011 01:05:03 GMT; path=/; domain=.google.ch; HttpOnly"}}, - []*Cookie{{ - Name: "NID", - Value: "99=YsDT5i3E-CXax-", - Path: "/", - Domain: ".google.ch", - HttpOnly: true, - Expires: time.Date(2011, 11, 23, 1, 5, 3, 0, time.UTC), - RawExpires: "Wed, 23-Nov-2011 01:05:03 GMT", - Raw: "NID=99=YsDT5i3E-CXax-; expires=Wed, 23-Nov-2011 01:05:03 GMT; path=/; domain=.google.ch; HttpOnly", - }}, - }, - { - Header{"Set-Cookie": {".ASPXAUTH=7E3AA; expires=Wed, 07-Mar-2012 14:25:06 GMT; path=/; HttpOnly"}}, - []*Cookie{{ - Name: ".ASPXAUTH", - Value: "7E3AA", - Path: "/", - Expires: time.Date(2012, 3, 7, 14, 25, 6, 0, time.UTC), - RawExpires: "Wed, 07-Mar-2012 14:25:06 GMT", - HttpOnly: true, - Raw: ".ASPXAUTH=7E3AA; expires=Wed, 07-Mar-2012 14:25:06 GMT; path=/; HttpOnly", - }}, - }, - { - Header{"Set-Cookie": {"ASP.NET_SessionId=foo; path=/; HttpOnly"}}, - []*Cookie{{ - Name: "ASP.NET_SessionId", - Value: "foo", - Path: "/", - HttpOnly: true, - Raw: "ASP.NET_SessionId=foo; path=/; HttpOnly", - }}, - }, - // Make sure we can properly read back the Set-Cookie headers we create - // for values containing spaces or commas: - { - Header{"Set-Cookie": {`special-1=a z`}}, - []*Cookie{{Name: "special-1", Value: "a z", Raw: `special-1=a z`}}, - }, - { - Header{"Set-Cookie": {`special-2=" z"`}}, - []*Cookie{{Name: "special-2", Value: " z", Raw: `special-2=" z"`}}, - }, - { - Header{"Set-Cookie": {`special-3="a "`}}, - []*Cookie{{Name: "special-3", Value: "a ", Raw: `special-3="a "`}}, - }, - { - Header{"Set-Cookie": {`special-4=" "`}}, - []*Cookie{{Name: "special-4", Value: " ", Raw: `special-4=" "`}}, - }, - { - Header{"Set-Cookie": {`special-5=a,z`}}, - []*Cookie{{Name: "special-5", Value: "a,z", Raw: `special-5=a,z`}}, - }, - { - Header{"Set-Cookie": {`special-6=",z"`}}, - []*Cookie{{Name: "special-6", Value: ",z", Raw: `special-6=",z"`}}, - }, - { - Header{"Set-Cookie": {`special-7=a,`}}, - []*Cookie{{Name: "special-7", Value: "a,", Raw: `special-7=a,`}}, - }, - { - Header{"Set-Cookie": {`special-8=","`}}, - []*Cookie{{Name: "special-8", Value: ",", Raw: `special-8=","`}}, - }, - - // TODO(bradfitz): users have reported seeing this in the - // wild, but do browsers handle it? RFC 6265 just says "don't - // do that" (section 3) and then never mentions header folding - // again. - // Header{"Set-Cookie": {"ASP.NET_SessionId=foo; path=/; HttpOnly, .ASPXAUTH=7E3AA; expires=Wed, 07-Mar-2012 14:25:06 GMT; path=/; HttpOnly"}}, -} - -func toJSON(v interface{}) string { - b, err := json.Marshal(v) - if err != nil { - return fmt.Sprintf("%#v", v) - } - return string(b) -} - -func TestReadSetCookies(t *testing.T) { - for i, tt := range readSetCookiesTests { - for n := 0; n < 2; n++ { // to verify readSetCookies doesn't mutate its input - c := readSetCookies(tt.Header) - if !reflect.DeepEqual(c, tt.Cookies) { - t.Errorf("#%d readSetCookies: have\n%s\nwant\n%s\n", i, toJSON(c), toJSON(tt.Cookies)) - continue - } - } - } -} - -var readCookiesTests = []struct { - Header Header - Filter string - Cookies []*Cookie -}{ - { - Header{"Cookie": {"Cookie-1=v$1", "c2=v2"}}, - "", - []*Cookie{ - {Name: "Cookie-1", Value: "v$1"}, - {Name: "c2", Value: "v2"}, - }, - }, - { - Header{"Cookie": {"Cookie-1=v$1", "c2=v2"}}, - "c2", - []*Cookie{ - {Name: "c2", Value: "v2"}, - }, - }, - { - Header{"Cookie": {"Cookie-1=v$1; c2=v2"}}, - "", - []*Cookie{ - {Name: "Cookie-1", Value: "v$1"}, - {Name: "c2", Value: "v2"}, - }, - }, - { - Header{"Cookie": {"Cookie-1=v$1; c2=v2"}}, - "c2", - []*Cookie{ - {Name: "c2", Value: "v2"}, - }, - }, -} - -func TestReadCookies(t *testing.T) { - for i, tt := range readCookiesTests { - for n := 0; n < 2; n++ { // to verify readCookies doesn't mutate its input - c := readCookies(tt.Header, tt.Filter) - if !reflect.DeepEqual(c, tt.Cookies) { - t.Errorf("#%d readCookies:\nhave: %s\nwant: %s\n", i, toJSON(c), toJSON(tt.Cookies)) - continue - } - } - } -} - -func TestCookieSanitizeValue(t *testing.T) { - defer log.SetOutput(os.Stderr) - var logbuf bytes.Buffer - log.SetOutput(&logbuf) - - tests := []struct { - in, want string - }{ - {"foo", "foo"}, - {"foo;bar", "foobar"}, - {"foo\\bar", "foobar"}, - {"foo\"bar", "foobar"}, - {"\x00\x7e\x7f\x80", "\x7e"}, - {`"withquotes"`, "withquotes"}, - {"a z", "a z"}, - {" z", `" z"`}, - {"a ", `"a "`}, - } - for _, tt := range tests { - if got := sanitizeCookieValue(tt.in); got != tt.want { - t.Errorf("sanitizeCookieValue(%q) = %q; want %q", tt.in, got, tt.want) - } - } - - if got, sub := logbuf.String(), "dropping invalid bytes"; !strings.Contains(got, sub) { - t.Errorf("Expected substring %q in log output. Got:\n%s", sub, got) - } -} - -func TestCookieSanitizePath(t *testing.T) { - defer log.SetOutput(os.Stderr) - var logbuf bytes.Buffer - log.SetOutput(&logbuf) - - tests := []struct { - in, want string - }{ - {"/path", "/path"}, - {"/path with space/", "/path with space/"}, - {"/just;no;semicolon\x00orstuff/", "/justnosemicolonorstuff/"}, - } - for _, tt := range tests { - if got := sanitizeCookiePath(tt.in); got != tt.want { - t.Errorf("sanitizeCookiePath(%q) = %q; want %q", tt.in, got, tt.want) - } - } - - if got, sub := logbuf.String(), "dropping invalid bytes"; !strings.Contains(got, sub) { - t.Errorf("Expected substring %q in log output. Got:\n%s", sub, got) - } -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cookiejar/jar.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cookiejar/jar.go deleted file mode 100644 index 389ab58e41..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cookiejar/jar.go +++ /dev/null @@ -1,497 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package cookiejar implements an in-memory RFC 6265-compliant http.CookieJar. -package cookiejar - -import ( - "errors" - "fmt" - "net" - "net/http" - "net/url" - "sort" - "strings" - "sync" - "time" -) - -// PublicSuffixList provides the public suffix of a domain. For example: -// - the public suffix of "example.com" is "com", -// - the public suffix of "foo1.foo2.foo3.co.uk" is "co.uk", and -// - the public suffix of "bar.pvt.k12.ma.us" is "pvt.k12.ma.us". -// -// Implementations of PublicSuffixList must be safe for concurrent use by -// multiple goroutines. -// -// An implementation that always returns "" is valid and may be useful for -// testing but it is not secure: it means that the HTTP server for foo.com can -// set a cookie for bar.com. -// -// A public suffix list implementation is in the package -// code.google.com/p/go.net/publicsuffix. -type PublicSuffixList interface { - // PublicSuffix returns the public suffix of domain. - // - // TODO: specify which of the caller and callee is responsible for IP - // addresses, for leading and trailing dots, for case sensitivity, and - // for IDN/Punycode. - PublicSuffix(domain string) string - - // String returns a description of the source of this public suffix - // list. The description will typically contain something like a time - // stamp or version number. - String() string -} - -// Options are the options for creating a new Jar. -type Options struct { - // PublicSuffixList is the public suffix list that determines whether - // an HTTP server can set a cookie for a domain. - // - // A nil value is valid and may be useful for testing but it is not - // secure: it means that the HTTP server for foo.co.uk can set a cookie - // for bar.co.uk. - PublicSuffixList PublicSuffixList -} - -// Jar implements the http.CookieJar interface from the net/http package. -type Jar struct { - psList PublicSuffixList - - // mu locks the remaining fields. - mu sync.Mutex - - // entries is a set of entries, keyed by their eTLD+1 and subkeyed by - // their name/domain/path. - entries map[string]map[string]entry - - // nextSeqNum is the next sequence number assigned to a new cookie - // created SetCookies. - nextSeqNum uint64 -} - -// New returns a new cookie jar. A nil *Options is equivalent to a zero -// Options. -func New(o *Options) (*Jar, error) { - jar := &Jar{ - entries: make(map[string]map[string]entry), - } - if o != nil { - jar.psList = o.PublicSuffixList - } - return jar, nil -} - -// entry is the internal representation of a cookie. -// -// This struct type is not used outside of this package per se, but the exported -// fields are those of RFC 6265. -type entry struct { - Name string - Value string - Domain string - Path string - Secure bool - HttpOnly bool - Persistent bool - HostOnly bool - Expires time.Time - Creation time.Time - LastAccess time.Time - - // seqNum is a sequence number so that Cookies returns cookies in a - // deterministic order, even for cookies that have equal Path length and - // equal Creation time. This simplifies testing. - seqNum uint64 -} - -// Id returns the domain;path;name triple of e as an id. -func (e *entry) id() string { - return fmt.Sprintf("%s;%s;%s", e.Domain, e.Path, e.Name) -} - -// shouldSend determines whether e's cookie qualifies to be included in a -// request to host/path. It is the caller's responsibility to check if the -// cookie is expired. -func (e *entry) shouldSend(https bool, host, path string) bool { - return e.domainMatch(host) && e.pathMatch(path) && (https || !e.Secure) -} - -// domainMatch implements "domain-match" of RFC 6265 section 5.1.3. -func (e *entry) domainMatch(host string) bool { - if e.Domain == host { - return true - } - return !e.HostOnly && hasDotSuffix(host, e.Domain) -} - -// pathMatch implements "path-match" according to RFC 6265 section 5.1.4. -func (e *entry) pathMatch(requestPath string) bool { - if requestPath == e.Path { - return true - } - if strings.HasPrefix(requestPath, e.Path) { - if e.Path[len(e.Path)-1] == '/' { - return true // The "/any/" matches "/any/path" case. - } else if requestPath[len(e.Path)] == '/' { - return true // The "/any" matches "/any/path" case. - } - } - return false -} - -// hasDotSuffix reports whether s ends in "."+suffix. -func hasDotSuffix(s, suffix string) bool { - return len(s) > len(suffix) && s[len(s)-len(suffix)-1] == '.' && s[len(s)-len(suffix):] == suffix -} - -// byPathLength is a []entry sort.Interface that sorts according to RFC 6265 -// section 5.4 point 2: by longest path and then by earliest creation time. -type byPathLength []entry - -func (s byPathLength) Len() int { return len(s) } - -func (s byPathLength) Less(i, j int) bool { - if len(s[i].Path) != len(s[j].Path) { - return len(s[i].Path) > len(s[j].Path) - } - if !s[i].Creation.Equal(s[j].Creation) { - return s[i].Creation.Before(s[j].Creation) - } - return s[i].seqNum < s[j].seqNum -} - -func (s byPathLength) Swap(i, j int) { s[i], s[j] = s[j], s[i] } - -// Cookies implements the Cookies method of the http.CookieJar interface. -// -// It returns an empty slice if the URL's scheme is not HTTP or HTTPS. -func (j *Jar) Cookies(u *url.URL) (cookies []*http.Cookie) { - return j.cookies(u, time.Now()) -} - -// cookies is like Cookies but takes the current time as a parameter. -func (j *Jar) cookies(u *url.URL, now time.Time) (cookies []*http.Cookie) { - if u.Scheme != "http" && u.Scheme != "https" { - return cookies - } - host, err := canonicalHost(u.Host) - if err != nil { - return cookies - } - key := jarKey(host, j.psList) - - j.mu.Lock() - defer j.mu.Unlock() - - submap := j.entries[key] - if submap == nil { - return cookies - } - - https := u.Scheme == "https" - path := u.Path - if path == "" { - path = "/" - } - - modified := false - var selected []entry - for id, e := range submap { - if e.Persistent && !e.Expires.After(now) { - delete(submap, id) - modified = true - continue - } - if !e.shouldSend(https, host, path) { - continue - } - e.LastAccess = now - submap[id] = e - selected = append(selected, e) - modified = true - } - if modified { - if len(submap) == 0 { - delete(j.entries, key) - } else { - j.entries[key] = submap - } - } - - sort.Sort(byPathLength(selected)) - for _, e := range selected { - cookies = append(cookies, &http.Cookie{Name: e.Name, Value: e.Value}) - } - - return cookies -} - -// SetCookies implements the SetCookies method of the http.CookieJar interface. -// -// It does nothing if the URL's scheme is not HTTP or HTTPS. -func (j *Jar) SetCookies(u *url.URL, cookies []*http.Cookie) { - j.setCookies(u, cookies, time.Now()) -} - -// setCookies is like SetCookies but takes the current time as parameter. -func (j *Jar) setCookies(u *url.URL, cookies []*http.Cookie, now time.Time) { - if len(cookies) == 0 { - return - } - if u.Scheme != "http" && u.Scheme != "https" { - return - } - host, err := canonicalHost(u.Host) - if err != nil { - return - } - key := jarKey(host, j.psList) - defPath := defaultPath(u.Path) - - j.mu.Lock() - defer j.mu.Unlock() - - submap := j.entries[key] - - modified := false - for _, cookie := range cookies { - e, remove, err := j.newEntry(cookie, now, defPath, host) - if err != nil { - continue - } - id := e.id() - if remove { - if submap != nil { - if _, ok := submap[id]; ok { - delete(submap, id) - modified = true - } - } - continue - } - if submap == nil { - submap = make(map[string]entry) - } - - if old, ok := submap[id]; ok { - e.Creation = old.Creation - e.seqNum = old.seqNum - } else { - e.Creation = now - e.seqNum = j.nextSeqNum - j.nextSeqNum++ - } - e.LastAccess = now - submap[id] = e - modified = true - } - - if modified { - if len(submap) == 0 { - delete(j.entries, key) - } else { - j.entries[key] = submap - } - } -} - -// canonicalHost strips port from host if present and returns the canonicalized -// host name. -func canonicalHost(host string) (string, error) { - var err error - host = strings.ToLower(host) - if hasPort(host) { - host, _, err = net.SplitHostPort(host) - if err != nil { - return "", err - } - } - if strings.HasSuffix(host, ".") { - // Strip trailing dot from fully qualified domain names. - host = host[:len(host)-1] - } - return toASCII(host) -} - -// hasPort reports whether host contains a port number. host may be a host -// name, an IPv4 or an IPv6 address. -func hasPort(host string) bool { - colons := strings.Count(host, ":") - if colons == 0 { - return false - } - if colons == 1 { - return true - } - return host[0] == '[' && strings.Contains(host, "]:") -} - -// jarKey returns the key to use for a jar. -func jarKey(host string, psl PublicSuffixList) string { - if isIP(host) { - return host - } - - var i int - if psl == nil { - i = strings.LastIndex(host, ".") - if i == -1 { - return host - } - } else { - suffix := psl.PublicSuffix(host) - if suffix == host { - return host - } - i = len(host) - len(suffix) - if i <= 0 || host[i-1] != '.' { - // The provided public suffix list psl is broken. - // Storing cookies under host is a safe stopgap. - return host - } - } - prevDot := strings.LastIndex(host[:i-1], ".") - return host[prevDot+1:] -} - -// isIP reports whether host is an IP address. -func isIP(host string) bool { - return net.ParseIP(host) != nil -} - -// defaultPath returns the directory part of an URL's path according to -// RFC 6265 section 5.1.4. -func defaultPath(path string) string { - if len(path) == 0 || path[0] != '/' { - return "/" // Path is empty or malformed. - } - - i := strings.LastIndex(path, "/") // Path starts with "/", so i != -1. - if i == 0 { - return "/" // Path has the form "/abc". - } - return path[:i] // Path is either of form "/abc/xyz" or "/abc/xyz/". -} - -// newEntry creates an entry from a http.Cookie c. now is the current time and -// is compared to c.Expires to determine deletion of c. defPath and host are the -// default-path and the canonical host name of the URL c was received from. -// -// remove records whether the jar should delete this cookie, as it has already -// expired with respect to now. In this case, e may be incomplete, but it will -// be valid to call e.id (which depends on e's Name, Domain and Path). -// -// A malformed c.Domain will result in an error. -func (j *Jar) newEntry(c *http.Cookie, now time.Time, defPath, host string) (e entry, remove bool, err error) { - e.Name = c.Name - - if c.Path == "" || c.Path[0] != '/' { - e.Path = defPath - } else { - e.Path = c.Path - } - - e.Domain, e.HostOnly, err = j.domainAndType(host, c.Domain) - if err != nil { - return e, false, err - } - - // MaxAge takes precedence over Expires. - if c.MaxAge < 0 { - return e, true, nil - } else if c.MaxAge > 0 { - e.Expires = now.Add(time.Duration(c.MaxAge) * time.Second) - e.Persistent = true - } else { - if c.Expires.IsZero() { - e.Expires = endOfTime - e.Persistent = false - } else { - if !c.Expires.After(now) { - return e, true, nil - } - e.Expires = c.Expires - e.Persistent = true - } - } - - e.Value = c.Value - e.Secure = c.Secure - e.HttpOnly = c.HttpOnly - - return e, false, nil -} - -var ( - errIllegalDomain = errors.New("cookiejar: illegal cookie domain attribute") - errMalformedDomain = errors.New("cookiejar: malformed cookie domain attribute") - errNoHostname = errors.New("cookiejar: no host name available (IP only)") -) - -// endOfTime is the time when session (non-persistent) cookies expire. -// This instant is representable in most date/time formats (not just -// Go's time.Time) and should be far enough in the future. -var endOfTime = time.Date(9999, 12, 31, 23, 59, 59, 0, time.UTC) - -// domainAndType determines the cookie's domain and hostOnly attribute. -func (j *Jar) domainAndType(host, domain string) (string, bool, error) { - if domain == "" { - // No domain attribute in the SetCookie header indicates a - // host cookie. - return host, true, nil - } - - if isIP(host) { - // According to RFC 6265 domain-matching includes not being - // an IP address. - // TODO: This might be relaxed as in common browsers. - return "", false, errNoHostname - } - - // From here on: If the cookie is valid, it is a domain cookie (with - // the one exception of a public suffix below). - // See RFC 6265 section 5.2.3. - if domain[0] == '.' { - domain = domain[1:] - } - - if len(domain) == 0 || domain[0] == '.' { - // Received either "Domain=." or "Domain=..some.thing", - // both are illegal. - return "", false, errMalformedDomain - } - domain = strings.ToLower(domain) - - if domain[len(domain)-1] == '.' { - // We received stuff like "Domain=www.example.com.". - // Browsers do handle such stuff (actually differently) but - // RFC 6265 seems to be clear here (e.g. section 4.1.2.3) in - // requiring a reject. 4.1.2.3 is not normative, but - // "Domain Matching" (5.1.3) and "Canonicalized Host Names" - // (5.1.2) are. - return "", false, errMalformedDomain - } - - // See RFC 6265 section 5.3 #5. - if j.psList != nil { - if ps := j.psList.PublicSuffix(domain); ps != "" && !hasDotSuffix(domain, ps) { - if host == domain { - // This is the one exception in which a cookie - // with a domain attribute is a host cookie. - return host, true, nil - } - return "", false, errIllegalDomain - } - } - - // The domain must domain-match host: www.mycompany.com cannot - // set cookies for .ourcompetitors.com. - if host != domain && !hasDotSuffix(host, domain) { - return "", false, errIllegalDomain - } - - return domain, false, nil -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cookiejar/jar_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cookiejar/jar_test.go deleted file mode 100644 index 3aa601586e..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cookiejar/jar_test.go +++ /dev/null @@ -1,1267 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package cookiejar - -import ( - "fmt" - "net/http" - "net/url" - "sort" - "strings" - "testing" - "time" -) - -// tNow is the synthetic current time used as now during testing. -var tNow = time.Date(2013, 1, 1, 12, 0, 0, 0, time.UTC) - -// testPSL implements PublicSuffixList with just two rules: "co.uk" -// and the default rule "*". -type testPSL struct{} - -func (testPSL) String() string { - return "testPSL" -} -func (testPSL) PublicSuffix(d string) string { - if d == "co.uk" || strings.HasSuffix(d, ".co.uk") { - return "co.uk" - } - return d[strings.LastIndex(d, ".")+1:] -} - -// newTestJar creates an empty Jar with testPSL as the public suffix list. -func newTestJar() *Jar { - jar, err := New(&Options{PublicSuffixList: testPSL{}}) - if err != nil { - panic(err) - } - return jar -} - -var hasDotSuffixTests = [...]struct { - s, suffix string -}{ - {"", ""}, - {"", "."}, - {"", "x"}, - {".", ""}, - {".", "."}, - {".", ".."}, - {".", "x"}, - {".", "x."}, - {".", ".x"}, - {".", ".x."}, - {"x", ""}, - {"x", "."}, - {"x", ".."}, - {"x", "x"}, - {"x", "x."}, - {"x", ".x"}, - {"x", ".x."}, - {".x", ""}, - {".x", "."}, - {".x", ".."}, - {".x", "x"}, - {".x", "x."}, - {".x", ".x"}, - {".x", ".x."}, - {"x.", ""}, - {"x.", "."}, - {"x.", ".."}, - {"x.", "x"}, - {"x.", "x."}, - {"x.", ".x"}, - {"x.", ".x."}, - {"com", ""}, - {"com", "m"}, - {"com", "om"}, - {"com", "com"}, - {"com", ".com"}, - {"com", "x.com"}, - {"com", "xcom"}, - {"com", "xorg"}, - {"com", "org"}, - {"com", "rg"}, - {"foo.com", ""}, - {"foo.com", "m"}, - {"foo.com", "om"}, - {"foo.com", "com"}, - {"foo.com", ".com"}, - {"foo.com", "o.com"}, - {"foo.com", "oo.com"}, - {"foo.com", "foo.com"}, - {"foo.com", ".foo.com"}, - {"foo.com", "x.foo.com"}, - {"foo.com", "xfoo.com"}, - {"foo.com", "xfoo.org"}, - {"foo.com", "foo.org"}, - {"foo.com", "oo.org"}, - {"foo.com", "o.org"}, - {"foo.com", ".org"}, - {"foo.com", "org"}, - {"foo.com", "rg"}, -} - -func TestHasDotSuffix(t *testing.T) { - for _, tc := range hasDotSuffixTests { - got := hasDotSuffix(tc.s, tc.suffix) - want := strings.HasSuffix(tc.s, "."+tc.suffix) - if got != want { - t.Errorf("s=%q, suffix=%q: got %v, want %v", tc.s, tc.suffix, got, want) - } - } -} - -var canonicalHostTests = map[string]string{ - "www.example.com": "www.example.com", - "WWW.EXAMPLE.COM": "www.example.com", - "wWw.eXAmple.CoM": "www.example.com", - "www.example.com:80": "www.example.com", - "192.168.0.10": "192.168.0.10", - "192.168.0.5:8080": "192.168.0.5", - "2001:4860:0:2001::68": "2001:4860:0:2001::68", - "[2001:4860:0:::68]:8080": "2001:4860:0:::68", - "www.bücher.de": "www.xn--bcher-kva.de", - "www.example.com.": "www.example.com", - "[bad.unmatched.bracket:": "error", -} - -func TestCanonicalHost(t *testing.T) { - for h, want := range canonicalHostTests { - got, err := canonicalHost(h) - if want == "error" { - if err == nil { - t.Errorf("%q: got nil error, want non-nil", h) - } - continue - } - if err != nil { - t.Errorf("%q: %v", h, err) - continue - } - if got != want { - t.Errorf("%q: got %q, want %q", h, got, want) - continue - } - } -} - -var hasPortTests = map[string]bool{ - "www.example.com": false, - "www.example.com:80": true, - "127.0.0.1": false, - "127.0.0.1:8080": true, - "2001:4860:0:2001::68": false, - "[2001::0:::68]:80": true, -} - -func TestHasPort(t *testing.T) { - for host, want := range hasPortTests { - if got := hasPort(host); got != want { - t.Errorf("%q: got %t, want %t", host, got, want) - } - } -} - -var jarKeyTests = map[string]string{ - "foo.www.example.com": "example.com", - "www.example.com": "example.com", - "example.com": "example.com", - "com": "com", - "foo.www.bbc.co.uk": "bbc.co.uk", - "www.bbc.co.uk": "bbc.co.uk", - "bbc.co.uk": "bbc.co.uk", - "co.uk": "co.uk", - "uk": "uk", - "192.168.0.5": "192.168.0.5", -} - -func TestJarKey(t *testing.T) { - for host, want := range jarKeyTests { - if got := jarKey(host, testPSL{}); got != want { - t.Errorf("%q: got %q, want %q", host, got, want) - } - } -} - -var jarKeyNilPSLTests = map[string]string{ - "foo.www.example.com": "example.com", - "www.example.com": "example.com", - "example.com": "example.com", - "com": "com", - "foo.www.bbc.co.uk": "co.uk", - "www.bbc.co.uk": "co.uk", - "bbc.co.uk": "co.uk", - "co.uk": "co.uk", - "uk": "uk", - "192.168.0.5": "192.168.0.5", -} - -func TestJarKeyNilPSL(t *testing.T) { - for host, want := range jarKeyNilPSLTests { - if got := jarKey(host, nil); got != want { - t.Errorf("%q: got %q, want %q", host, got, want) - } - } -} - -var isIPTests = map[string]bool{ - "127.0.0.1": true, - "1.2.3.4": true, - "2001:4860:0:2001::68": true, - "example.com": false, - "1.1.1.300": false, - "www.foo.bar.net": false, - "123.foo.bar.net": false, -} - -func TestIsIP(t *testing.T) { - for host, want := range isIPTests { - if got := isIP(host); got != want { - t.Errorf("%q: got %t, want %t", host, got, want) - } - } -} - -var defaultPathTests = map[string]string{ - "/": "/", - "/abc": "/", - "/abc/": "/abc", - "/abc/xyz": "/abc", - "/abc/xyz/": "/abc/xyz", - "/a/b/c.html": "/a/b", - "": "/", - "strange": "/", - "//": "/", - "/a//b": "/a/", - "/a/./b": "/a/.", - "/a/../b": "/a/..", -} - -func TestDefaultPath(t *testing.T) { - for path, want := range defaultPathTests { - if got := defaultPath(path); got != want { - t.Errorf("%q: got %q, want %q", path, got, want) - } - } -} - -var domainAndTypeTests = [...]struct { - host string // host Set-Cookie header was received from - domain string // domain attribute in Set-Cookie header - wantDomain string // expected domain of cookie - wantHostOnly bool // expected host-cookie flag - wantErr error // expected error -}{ - {"www.example.com", "", "www.example.com", true, nil}, - {"127.0.0.1", "", "127.0.0.1", true, nil}, - {"2001:4860:0:2001::68", "", "2001:4860:0:2001::68", true, nil}, - {"www.example.com", "example.com", "example.com", false, nil}, - {"www.example.com", ".example.com", "example.com", false, nil}, - {"www.example.com", "www.example.com", "www.example.com", false, nil}, - {"www.example.com", ".www.example.com", "www.example.com", false, nil}, - {"foo.sso.example.com", "sso.example.com", "sso.example.com", false, nil}, - {"bar.co.uk", "bar.co.uk", "bar.co.uk", false, nil}, - {"foo.bar.co.uk", ".bar.co.uk", "bar.co.uk", false, nil}, - {"127.0.0.1", "127.0.0.1", "", false, errNoHostname}, - {"2001:4860:0:2001::68", "2001:4860:0:2001::68", "2001:4860:0:2001::68", false, errNoHostname}, - {"www.example.com", ".", "", false, errMalformedDomain}, - {"www.example.com", "..", "", false, errMalformedDomain}, - {"www.example.com", "other.com", "", false, errIllegalDomain}, - {"www.example.com", "com", "", false, errIllegalDomain}, - {"www.example.com", ".com", "", false, errIllegalDomain}, - {"foo.bar.co.uk", ".co.uk", "", false, errIllegalDomain}, - {"127.www.0.0.1", "127.0.0.1", "", false, errIllegalDomain}, - {"com", "", "com", true, nil}, - {"com", "com", "com", true, nil}, - {"com", ".com", "com", true, nil}, - {"co.uk", "", "co.uk", true, nil}, - {"co.uk", "co.uk", "co.uk", true, nil}, - {"co.uk", ".co.uk", "co.uk", true, nil}, -} - -func TestDomainAndType(t *testing.T) { - jar := newTestJar() - for _, tc := range domainAndTypeTests { - domain, hostOnly, err := jar.domainAndType(tc.host, tc.domain) - if err != tc.wantErr { - t.Errorf("%q/%q: got %q error, want %q", - tc.host, tc.domain, err, tc.wantErr) - continue - } - if err != nil { - continue - } - if domain != tc.wantDomain || hostOnly != tc.wantHostOnly { - t.Errorf("%q/%q: got %q/%t want %q/%t", - tc.host, tc.domain, domain, hostOnly, - tc.wantDomain, tc.wantHostOnly) - } - } -} - -// expiresIn creates an expires attribute delta seconds from tNow. -func expiresIn(delta int) string { - t := tNow.Add(time.Duration(delta) * time.Second) - return "expires=" + t.Format(time.RFC1123) -} - -// mustParseURL parses s to an URL and panics on error. -func mustParseURL(s string) *url.URL { - u, err := url.Parse(s) - if err != nil || u.Scheme == "" || u.Host == "" { - panic(fmt.Sprintf("Unable to parse URL %s.", s)) - } - return u -} - -// jarTest encapsulates the following actions on a jar: -// 1. Perform SetCookies with fromURL and the cookies from setCookies. -// (Done at time tNow + 0 ms.) -// 2. Check that the entries in the jar matches content. -// (Done at time tNow + 1001 ms.) -// 3. For each query in tests: Check that Cookies with toURL yields the -// cookies in want. -// (Query n done at tNow + (n+2)*1001 ms.) -type jarTest struct { - description string // The description of what this test is supposed to test - fromURL string // The full URL of the request from which Set-Cookie headers where received - setCookies []string // All the cookies received from fromURL - content string // The whole (non-expired) content of the jar - queries []query // Queries to test the Jar.Cookies method -} - -// query contains one test of the cookies returned from Jar.Cookies. -type query struct { - toURL string // the URL in the Cookies call - want string // the expected list of cookies (order matters) -} - -// run runs the jarTest. -func (test jarTest) run(t *testing.T, jar *Jar) { - now := tNow - - // Populate jar with cookies. - setCookies := make([]*http.Cookie, len(test.setCookies)) - for i, cs := range test.setCookies { - cookies := (&http.Response{Header: http.Header{"Set-Cookie": {cs}}}).Cookies() - if len(cookies) != 1 { - panic(fmt.Sprintf("Wrong cookie line %q: %#v", cs, cookies)) - } - setCookies[i] = cookies[0] - } - jar.setCookies(mustParseURL(test.fromURL), setCookies, now) - now = now.Add(1001 * time.Millisecond) - - // Serialize non-expired entries in the form "name1=val1 name2=val2". - var cs []string - for _, submap := range jar.entries { - for _, cookie := range submap { - if !cookie.Expires.After(now) { - continue - } - cs = append(cs, cookie.Name+"="+cookie.Value) - } - } - sort.Strings(cs) - got := strings.Join(cs, " ") - - // Make sure jar content matches our expectations. - if got != test.content { - t.Errorf("Test %q Content\ngot %q\nwant %q", - test.description, got, test.content) - } - - // Test different calls to Cookies. - for i, query := range test.queries { - now = now.Add(1001 * time.Millisecond) - var s []string - for _, c := range jar.cookies(mustParseURL(query.toURL), now) { - s = append(s, c.Name+"="+c.Value) - } - if got := strings.Join(s, " "); got != query.want { - t.Errorf("Test %q #%d\ngot %q\nwant %q", test.description, i, got, query.want) - } - } -} - -// basicsTests contains fundamental tests. Each jarTest has to be performed on -// a fresh, empty Jar. -var basicsTests = [...]jarTest{ - { - "Retrieval of a plain host cookie.", - "http://www.host.test/", - []string{"A=a"}, - "A=a", - []query{ - {"http://www.host.test", "A=a"}, - {"http://www.host.test/", "A=a"}, - {"http://www.host.test/some/path", "A=a"}, - {"https://www.host.test", "A=a"}, - {"https://www.host.test/", "A=a"}, - {"https://www.host.test/some/path", "A=a"}, - {"ftp://www.host.test", ""}, - {"ftp://www.host.test/", ""}, - {"ftp://www.host.test/some/path", ""}, - {"http://www.other.org", ""}, - {"http://sibling.host.test", ""}, - {"http://deep.www.host.test", ""}, - }, - }, - { - "Secure cookies are not returned to http.", - "http://www.host.test/", - []string{"A=a; secure"}, - "A=a", - []query{ - {"http://www.host.test", ""}, - {"http://www.host.test/", ""}, - {"http://www.host.test/some/path", ""}, - {"https://www.host.test", "A=a"}, - {"https://www.host.test/", "A=a"}, - {"https://www.host.test/some/path", "A=a"}, - }, - }, - { - "Explicit path.", - "http://www.host.test/", - []string{"A=a; path=/some/path"}, - "A=a", - []query{ - {"http://www.host.test", ""}, - {"http://www.host.test/", ""}, - {"http://www.host.test/some", ""}, - {"http://www.host.test/some/", ""}, - {"http://www.host.test/some/path", "A=a"}, - {"http://www.host.test/some/paths", ""}, - {"http://www.host.test/some/path/foo", "A=a"}, - {"http://www.host.test/some/path/foo/", "A=a"}, - }, - }, - { - "Implicit path #1: path is a directory.", - "http://www.host.test/some/path/", - []string{"A=a"}, - "A=a", - []query{ - {"http://www.host.test", ""}, - {"http://www.host.test/", ""}, - {"http://www.host.test/some", ""}, - {"http://www.host.test/some/", ""}, - {"http://www.host.test/some/path", "A=a"}, - {"http://www.host.test/some/paths", ""}, - {"http://www.host.test/some/path/foo", "A=a"}, - {"http://www.host.test/some/path/foo/", "A=a"}, - }, - }, - { - "Implicit path #2: path is not a directory.", - "http://www.host.test/some/path/index.html", - []string{"A=a"}, - "A=a", - []query{ - {"http://www.host.test", ""}, - {"http://www.host.test/", ""}, - {"http://www.host.test/some", ""}, - {"http://www.host.test/some/", ""}, - {"http://www.host.test/some/path", "A=a"}, - {"http://www.host.test/some/paths", ""}, - {"http://www.host.test/some/path/foo", "A=a"}, - {"http://www.host.test/some/path/foo/", "A=a"}, - }, - }, - { - "Implicit path #3: no path in URL at all.", - "http://www.host.test", - []string{"A=a"}, - "A=a", - []query{ - {"http://www.host.test", "A=a"}, - {"http://www.host.test/", "A=a"}, - {"http://www.host.test/some/path", "A=a"}, - }, - }, - { - "Cookies are sorted by path length.", - "http://www.host.test/", - []string{ - "A=a; path=/foo/bar", - "B=b; path=/foo/bar/baz/qux", - "C=c; path=/foo/bar/baz", - "D=d; path=/foo"}, - "A=a B=b C=c D=d", - []query{ - {"http://www.host.test/foo/bar/baz/qux", "B=b C=c A=a D=d"}, - {"http://www.host.test/foo/bar/baz/", "C=c A=a D=d"}, - {"http://www.host.test/foo/bar", "A=a D=d"}, - }, - }, - { - "Creation time determines sorting on same length paths.", - "http://www.host.test/", - []string{ - "A=a; path=/foo/bar", - "X=x; path=/foo/bar", - "Y=y; path=/foo/bar/baz/qux", - "B=b; path=/foo/bar/baz/qux", - "C=c; path=/foo/bar/baz", - "W=w; path=/foo/bar/baz", - "Z=z; path=/foo", - "D=d; path=/foo"}, - "A=a B=b C=c D=d W=w X=x Y=y Z=z", - []query{ - {"http://www.host.test/foo/bar/baz/qux", "Y=y B=b C=c W=w A=a X=x Z=z D=d"}, - {"http://www.host.test/foo/bar/baz/", "C=c W=w A=a X=x Z=z D=d"}, - {"http://www.host.test/foo/bar", "A=a X=x Z=z D=d"}, - }, - }, - { - "Sorting of same-name cookies.", - "http://www.host.test/", - []string{ - "A=1; path=/", - "A=2; path=/path", - "A=3; path=/quux", - "A=4; path=/path/foo", - "A=5; domain=.host.test; path=/path", - "A=6; domain=.host.test; path=/quux", - "A=7; domain=.host.test; path=/path/foo", - }, - "A=1 A=2 A=3 A=4 A=5 A=6 A=7", - []query{ - {"http://www.host.test/path", "A=2 A=5 A=1"}, - {"http://www.host.test/path/foo", "A=4 A=7 A=2 A=5 A=1"}, - }, - }, - { - "Disallow domain cookie on public suffix.", - "http://www.bbc.co.uk", - []string{ - "a=1", - "b=2; domain=co.uk", - }, - "a=1", - []query{{"http://www.bbc.co.uk", "a=1"}}, - }, - { - "Host cookie on IP.", - "http://192.168.0.10", - []string{"a=1"}, - "a=1", - []query{{"http://192.168.0.10", "a=1"}}, - }, - { - "Port is ignored #1.", - "http://www.host.test/", - []string{"a=1"}, - "a=1", - []query{ - {"http://www.host.test", "a=1"}, - {"http://www.host.test:8080/", "a=1"}, - }, - }, - { - "Port is ignored #2.", - "http://www.host.test:8080/", - []string{"a=1"}, - "a=1", - []query{ - {"http://www.host.test", "a=1"}, - {"http://www.host.test:8080/", "a=1"}, - {"http://www.host.test:1234/", "a=1"}, - }, - }, -} - -func TestBasics(t *testing.T) { - for _, test := range basicsTests { - jar := newTestJar() - test.run(t, jar) - } -} - -// updateAndDeleteTests contains jarTests which must be performed on the same -// Jar. -var updateAndDeleteTests = [...]jarTest{ - { - "Set initial cookies.", - "http://www.host.test", - []string{ - "a=1", - "b=2; secure", - "c=3; httponly", - "d=4; secure; httponly"}, - "a=1 b=2 c=3 d=4", - []query{ - {"http://www.host.test", "a=1 c=3"}, - {"https://www.host.test", "a=1 b=2 c=3 d=4"}, - }, - }, - { - "Update value via http.", - "http://www.host.test", - []string{ - "a=w", - "b=x; secure", - "c=y; httponly", - "d=z; secure; httponly"}, - "a=w b=x c=y d=z", - []query{ - {"http://www.host.test", "a=w c=y"}, - {"https://www.host.test", "a=w b=x c=y d=z"}, - }, - }, - { - "Clear Secure flag from a http.", - "http://www.host.test/", - []string{ - "b=xx", - "d=zz; httponly"}, - "a=w b=xx c=y d=zz", - []query{{"http://www.host.test", "a=w b=xx c=y d=zz"}}, - }, - { - "Delete all.", - "http://www.host.test/", - []string{ - "a=1; max-Age=-1", // delete via MaxAge - "b=2; " + expiresIn(-10), // delete via Expires - "c=2; max-age=-1; " + expiresIn(-10), // delete via both - "d=4; max-age=-1; " + expiresIn(10)}, // MaxAge takes precedence - "", - []query{{"http://www.host.test", ""}}, - }, - { - "Refill #1.", - "http://www.host.test", - []string{ - "A=1", - "A=2; path=/foo", - "A=3; domain=.host.test", - "A=4; path=/foo; domain=.host.test"}, - "A=1 A=2 A=3 A=4", - []query{{"http://www.host.test/foo", "A=2 A=4 A=1 A=3"}}, - }, - { - "Refill #2.", - "http://www.google.com", - []string{ - "A=6", - "A=7; path=/foo", - "A=8; domain=.google.com", - "A=9; path=/foo; domain=.google.com"}, - "A=1 A=2 A=3 A=4 A=6 A=7 A=8 A=9", - []query{ - {"http://www.host.test/foo", "A=2 A=4 A=1 A=3"}, - {"http://www.google.com/foo", "A=7 A=9 A=6 A=8"}, - }, - }, - { - "Delete A7.", - "http://www.google.com", - []string{"A=; path=/foo; max-age=-1"}, - "A=1 A=2 A=3 A=4 A=6 A=8 A=9", - []query{ - {"http://www.host.test/foo", "A=2 A=4 A=1 A=3"}, - {"http://www.google.com/foo", "A=9 A=6 A=8"}, - }, - }, - { - "Delete A4.", - "http://www.host.test", - []string{"A=; path=/foo; domain=host.test; max-age=-1"}, - "A=1 A=2 A=3 A=6 A=8 A=9", - []query{ - {"http://www.host.test/foo", "A=2 A=1 A=3"}, - {"http://www.google.com/foo", "A=9 A=6 A=8"}, - }, - }, - { - "Delete A6.", - "http://www.google.com", - []string{"A=; max-age=-1"}, - "A=1 A=2 A=3 A=8 A=9", - []query{ - {"http://www.host.test/foo", "A=2 A=1 A=3"}, - {"http://www.google.com/foo", "A=9 A=8"}, - }, - }, - { - "Delete A3.", - "http://www.host.test", - []string{"A=; domain=host.test; max-age=-1"}, - "A=1 A=2 A=8 A=9", - []query{ - {"http://www.host.test/foo", "A=2 A=1"}, - {"http://www.google.com/foo", "A=9 A=8"}, - }, - }, - { - "No cross-domain delete.", - "http://www.host.test", - []string{ - "A=; domain=google.com; max-age=-1", - "A=; path=/foo; domain=google.com; max-age=-1"}, - "A=1 A=2 A=8 A=9", - []query{ - {"http://www.host.test/foo", "A=2 A=1"}, - {"http://www.google.com/foo", "A=9 A=8"}, - }, - }, - { - "Delete A8 and A9.", - "http://www.google.com", - []string{ - "A=; domain=google.com; max-age=-1", - "A=; path=/foo; domain=google.com; max-age=-1"}, - "A=1 A=2", - []query{ - {"http://www.host.test/foo", "A=2 A=1"}, - {"http://www.google.com/foo", ""}, - }, - }, -} - -func TestUpdateAndDelete(t *testing.T) { - jar := newTestJar() - for _, test := range updateAndDeleteTests { - test.run(t, jar) - } -} - -func TestExpiration(t *testing.T) { - jar := newTestJar() - jarTest{ - "Expiration.", - "http://www.host.test", - []string{ - "a=1", - "b=2; max-age=3", - "c=3; " + expiresIn(3), - "d=4; max-age=5", - "e=5; " + expiresIn(5), - "f=6; max-age=100", - }, - "a=1 b=2 c=3 d=4 e=5 f=6", // executed at t0 + 1001 ms - []query{ - {"http://www.host.test", "a=1 b=2 c=3 d=4 e=5 f=6"}, // t0 + 2002 ms - {"http://www.host.test", "a=1 d=4 e=5 f=6"}, // t0 + 3003 ms - {"http://www.host.test", "a=1 d=4 e=5 f=6"}, // t0 + 4004 ms - {"http://www.host.test", "a=1 f=6"}, // t0 + 5005 ms - {"http://www.host.test", "a=1 f=6"}, // t0 + 6006 ms - }, - }.run(t, jar) -} - -// -// Tests derived from Chromium's cookie_store_unittest.h. -// - -// See http://src.chromium.org/viewvc/chrome/trunk/src/net/cookies/cookie_store_unittest.h?revision=159685&content-type=text/plain -// Some of the original tests are in a bad condition (e.g. -// DomainWithTrailingDotTest) or are not RFC 6265 conforming (e.g. -// TestNonDottedAndTLD #1 and #6) and have not been ported. - -// chromiumBasicsTests contains fundamental tests. Each jarTest has to be -// performed on a fresh, empty Jar. -var chromiumBasicsTests = [...]jarTest{ - { - "DomainWithTrailingDotTest.", - "http://www.google.com/", - []string{ - "a=1; domain=.www.google.com.", - "b=2; domain=.www.google.com.."}, - "", - []query{ - {"http://www.google.com", ""}, - }, - }, - { - "ValidSubdomainTest #1.", - "http://a.b.c.d.com", - []string{ - "a=1; domain=.a.b.c.d.com", - "b=2; domain=.b.c.d.com", - "c=3; domain=.c.d.com", - "d=4; domain=.d.com"}, - "a=1 b=2 c=3 d=4", - []query{ - {"http://a.b.c.d.com", "a=1 b=2 c=3 d=4"}, - {"http://b.c.d.com", "b=2 c=3 d=4"}, - {"http://c.d.com", "c=3 d=4"}, - {"http://d.com", "d=4"}, - }, - }, - { - "ValidSubdomainTest #2.", - "http://a.b.c.d.com", - []string{ - "a=1; domain=.a.b.c.d.com", - "b=2; domain=.b.c.d.com", - "c=3; domain=.c.d.com", - "d=4; domain=.d.com", - "X=bcd; domain=.b.c.d.com", - "X=cd; domain=.c.d.com"}, - "X=bcd X=cd a=1 b=2 c=3 d=4", - []query{ - {"http://b.c.d.com", "b=2 c=3 d=4 X=bcd X=cd"}, - {"http://c.d.com", "c=3 d=4 X=cd"}, - }, - }, - { - "InvalidDomainTest #1.", - "http://foo.bar.com", - []string{ - "a=1; domain=.yo.foo.bar.com", - "b=2; domain=.foo.com", - "c=3; domain=.bar.foo.com", - "d=4; domain=.foo.bar.com.net", - "e=5; domain=ar.com", - "f=6; domain=.", - "g=7; domain=/", - "h=8; domain=http://foo.bar.com", - "i=9; domain=..foo.bar.com", - "j=10; domain=..bar.com", - "k=11; domain=.foo.bar.com?blah", - "l=12; domain=.foo.bar.com/blah", - "m=12; domain=.foo.bar.com:80", - "n=14; domain=.foo.bar.com:", - "o=15; domain=.foo.bar.com#sup", - }, - "", // Jar is empty. - []query{{"http://foo.bar.com", ""}}, - }, - { - "InvalidDomainTest #2.", - "http://foo.com.com", - []string{"a=1; domain=.foo.com.com.com"}, - "", - []query{{"http://foo.bar.com", ""}}, - }, - { - "DomainWithoutLeadingDotTest #1.", - "http://manage.hosted.filefront.com", - []string{"a=1; domain=filefront.com"}, - "a=1", - []query{{"http://www.filefront.com", "a=1"}}, - }, - { - "DomainWithoutLeadingDotTest #2.", - "http://www.google.com", - []string{"a=1; domain=www.google.com"}, - "a=1", - []query{ - {"http://www.google.com", "a=1"}, - {"http://sub.www.google.com", "a=1"}, - {"http://something-else.com", ""}, - }, - }, - { - "CaseInsensitiveDomainTest.", - "http://www.google.com", - []string{ - "a=1; domain=.GOOGLE.COM", - "b=2; domain=.www.gOOgLE.coM"}, - "a=1 b=2", - []query{{"http://www.google.com", "a=1 b=2"}}, - }, - { - "TestIpAddress #1.", - "http://1.2.3.4/foo", - []string{"a=1; path=/"}, - "a=1", - []query{{"http://1.2.3.4/foo", "a=1"}}, - }, - { - "TestIpAddress #2.", - "http://1.2.3.4/foo", - []string{ - "a=1; domain=.1.2.3.4", - "b=2; domain=.3.4"}, - "", - []query{{"http://1.2.3.4/foo", ""}}, - }, - { - "TestIpAddress #3.", - "http://1.2.3.4/foo", - []string{"a=1; domain=1.2.3.4"}, - "", - []query{{"http://1.2.3.4/foo", ""}}, - }, - { - "TestNonDottedAndTLD #2.", - "http://com./index.html", - []string{"a=1"}, - "a=1", - []query{ - {"http://com./index.html", "a=1"}, - {"http://no-cookies.com./index.html", ""}, - }, - }, - { - "TestNonDottedAndTLD #3.", - "http://a.b", - []string{ - "a=1; domain=.b", - "b=2; domain=b"}, - "", - []query{{"http://bar.foo", ""}}, - }, - { - "TestNonDottedAndTLD #4.", - "http://google.com", - []string{ - "a=1; domain=.com", - "b=2; domain=com"}, - "", - []query{{"http://google.com", ""}}, - }, - { - "TestNonDottedAndTLD #5.", - "http://google.co.uk", - []string{ - "a=1; domain=.co.uk", - "b=2; domain=.uk"}, - "", - []query{ - {"http://google.co.uk", ""}, - {"http://else.co.com", ""}, - {"http://else.uk", ""}, - }, - }, - { - "TestHostEndsWithDot.", - "http://www.google.com", - []string{ - "a=1", - "b=2; domain=.www.google.com."}, - "a=1", - []query{{"http://www.google.com", "a=1"}}, - }, - { - "PathTest", - "http://www.google.izzle", - []string{"a=1; path=/wee"}, - "a=1", - []query{ - {"http://www.google.izzle/wee", "a=1"}, - {"http://www.google.izzle/wee/", "a=1"}, - {"http://www.google.izzle/wee/war", "a=1"}, - {"http://www.google.izzle/wee/war/more/more", "a=1"}, - {"http://www.google.izzle/weehee", ""}, - {"http://www.google.izzle/", ""}, - }, - }, -} - -func TestChromiumBasics(t *testing.T) { - for _, test := range chromiumBasicsTests { - jar := newTestJar() - test.run(t, jar) - } -} - -// chromiumDomainTests contains jarTests which must be executed all on the -// same Jar. -var chromiumDomainTests = [...]jarTest{ - { - "Fill #1.", - "http://www.google.izzle", - []string{"A=B"}, - "A=B", - []query{{"http://www.google.izzle", "A=B"}}, - }, - { - "Fill #2.", - "http://www.google.izzle", - []string{"C=D; domain=.google.izzle"}, - "A=B C=D", - []query{{"http://www.google.izzle", "A=B C=D"}}, - }, - { - "Verify A is a host cookie and not accessible from subdomain.", - "http://unused.nil", - []string{}, - "A=B C=D", - []query{{"http://foo.www.google.izzle", "C=D"}}, - }, - { - "Verify domain cookies are found on proper domain.", - "http://www.google.izzle", - []string{"E=F; domain=.www.google.izzle"}, - "A=B C=D E=F", - []query{{"http://www.google.izzle", "A=B C=D E=F"}}, - }, - { - "Leading dots in domain attributes are optional.", - "http://www.google.izzle", - []string{"G=H; domain=www.google.izzle"}, - "A=B C=D E=F G=H", - []query{{"http://www.google.izzle", "A=B C=D E=F G=H"}}, - }, - { - "Verify domain enforcement works #1.", - "http://www.google.izzle", - []string{"K=L; domain=.bar.www.google.izzle"}, - "A=B C=D E=F G=H", - []query{{"http://bar.www.google.izzle", "C=D E=F G=H"}}, - }, - { - "Verify domain enforcement works #2.", - "http://unused.nil", - []string{}, - "A=B C=D E=F G=H", - []query{{"http://www.google.izzle", "A=B C=D E=F G=H"}}, - }, -} - -func TestChromiumDomain(t *testing.T) { - jar := newTestJar() - for _, test := range chromiumDomainTests { - test.run(t, jar) - } - -} - -// chromiumDeletionTests must be performed all on the same Jar. -var chromiumDeletionTests = [...]jarTest{ - { - "Create session cookie a1.", - "http://www.google.com", - []string{"a=1"}, - "a=1", - []query{{"http://www.google.com", "a=1"}}, - }, - { - "Delete sc a1 via MaxAge.", - "http://www.google.com", - []string{"a=1; max-age=-1"}, - "", - []query{{"http://www.google.com", ""}}, - }, - { - "Create session cookie b2.", - "http://www.google.com", - []string{"b=2"}, - "b=2", - []query{{"http://www.google.com", "b=2"}}, - }, - { - "Delete sc b2 via Expires.", - "http://www.google.com", - []string{"b=2; " + expiresIn(-10)}, - "", - []query{{"http://www.google.com", ""}}, - }, - { - "Create persistent cookie c3.", - "http://www.google.com", - []string{"c=3; max-age=3600"}, - "c=3", - []query{{"http://www.google.com", "c=3"}}, - }, - { - "Delete pc c3 via MaxAge.", - "http://www.google.com", - []string{"c=3; max-age=-1"}, - "", - []query{{"http://www.google.com", ""}}, - }, - { - "Create persistent cookie d4.", - "http://www.google.com", - []string{"d=4; max-age=3600"}, - "d=4", - []query{{"http://www.google.com", "d=4"}}, - }, - { - "Delete pc d4 via Expires.", - "http://www.google.com", - []string{"d=4; " + expiresIn(-10)}, - "", - []query{{"http://www.google.com", ""}}, - }, -} - -func TestChromiumDeletion(t *testing.T) { - jar := newTestJar() - for _, test := range chromiumDeletionTests { - test.run(t, jar) - } -} - -// domainHandlingTests tests and documents the rules for domain handling. -// Each test must be performed on an empty new Jar. -var domainHandlingTests = [...]jarTest{ - { - "Host cookie", - "http://www.host.test", - []string{"a=1"}, - "a=1", - []query{ - {"http://www.host.test", "a=1"}, - {"http://host.test", ""}, - {"http://bar.host.test", ""}, - {"http://foo.www.host.test", ""}, - {"http://other.test", ""}, - {"http://test", ""}, - }, - }, - { - "Domain cookie #1", - "http://www.host.test", - []string{"a=1; domain=host.test"}, - "a=1", - []query{ - {"http://www.host.test", "a=1"}, - {"http://host.test", "a=1"}, - {"http://bar.host.test", "a=1"}, - {"http://foo.www.host.test", "a=1"}, - {"http://other.test", ""}, - {"http://test", ""}, - }, - }, - { - "Domain cookie #2", - "http://www.host.test", - []string{"a=1; domain=.host.test"}, - "a=1", - []query{ - {"http://www.host.test", "a=1"}, - {"http://host.test", "a=1"}, - {"http://bar.host.test", "a=1"}, - {"http://foo.www.host.test", "a=1"}, - {"http://other.test", ""}, - {"http://test", ""}, - }, - }, - { - "Host cookie on IDNA domain #1", - "http://www.bücher.test", - []string{"a=1"}, - "a=1", - []query{ - {"http://www.bücher.test", "a=1"}, - {"http://www.xn--bcher-kva.test", "a=1"}, - {"http://bücher.test", ""}, - {"http://xn--bcher-kva.test", ""}, - {"http://bar.bücher.test", ""}, - {"http://bar.xn--bcher-kva.test", ""}, - {"http://foo.www.bücher.test", ""}, - {"http://foo.www.xn--bcher-kva.test", ""}, - {"http://other.test", ""}, - {"http://test", ""}, - }, - }, - { - "Host cookie on IDNA domain #2", - "http://www.xn--bcher-kva.test", - []string{"a=1"}, - "a=1", - []query{ - {"http://www.bücher.test", "a=1"}, - {"http://www.xn--bcher-kva.test", "a=1"}, - {"http://bücher.test", ""}, - {"http://xn--bcher-kva.test", ""}, - {"http://bar.bücher.test", ""}, - {"http://bar.xn--bcher-kva.test", ""}, - {"http://foo.www.bücher.test", ""}, - {"http://foo.www.xn--bcher-kva.test", ""}, - {"http://other.test", ""}, - {"http://test", ""}, - }, - }, - { - "Domain cookie on IDNA domain #1", - "http://www.bücher.test", - []string{"a=1; domain=xn--bcher-kva.test"}, - "a=1", - []query{ - {"http://www.bücher.test", "a=1"}, - {"http://www.xn--bcher-kva.test", "a=1"}, - {"http://bücher.test", "a=1"}, - {"http://xn--bcher-kva.test", "a=1"}, - {"http://bar.bücher.test", "a=1"}, - {"http://bar.xn--bcher-kva.test", "a=1"}, - {"http://foo.www.bücher.test", "a=1"}, - {"http://foo.www.xn--bcher-kva.test", "a=1"}, - {"http://other.test", ""}, - {"http://test", ""}, - }, - }, - { - "Domain cookie on IDNA domain #2", - "http://www.xn--bcher-kva.test", - []string{"a=1; domain=xn--bcher-kva.test"}, - "a=1", - []query{ - {"http://www.bücher.test", "a=1"}, - {"http://www.xn--bcher-kva.test", "a=1"}, - {"http://bücher.test", "a=1"}, - {"http://xn--bcher-kva.test", "a=1"}, - {"http://bar.bücher.test", "a=1"}, - {"http://bar.xn--bcher-kva.test", "a=1"}, - {"http://foo.www.bücher.test", "a=1"}, - {"http://foo.www.xn--bcher-kva.test", "a=1"}, - {"http://other.test", ""}, - {"http://test", ""}, - }, - }, - { - "Host cookie on TLD.", - "http://com", - []string{"a=1"}, - "a=1", - []query{ - {"http://com", "a=1"}, - {"http://any.com", ""}, - {"http://any.test", ""}, - }, - }, - { - "Domain cookie on TLD becomes a host cookie.", - "http://com", - []string{"a=1; domain=com"}, - "a=1", - []query{ - {"http://com", "a=1"}, - {"http://any.com", ""}, - {"http://any.test", ""}, - }, - }, - { - "Host cookie on public suffix.", - "http://co.uk", - []string{"a=1"}, - "a=1", - []query{ - {"http://co.uk", "a=1"}, - {"http://uk", ""}, - {"http://some.co.uk", ""}, - {"http://foo.some.co.uk", ""}, - {"http://any.uk", ""}, - }, - }, - { - "Domain cookie on public suffix is ignored.", - "http://some.co.uk", - []string{"a=1; domain=co.uk"}, - "", - []query{ - {"http://co.uk", ""}, - {"http://uk", ""}, - {"http://some.co.uk", ""}, - {"http://foo.some.co.uk", ""}, - {"http://any.uk", ""}, - }, - }, -} - -func TestDomainHandling(t *testing.T) { - for _, test := range domainHandlingTests { - jar := newTestJar() - test.run(t, jar) - } -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cookiejar/punycode.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cookiejar/punycode.go deleted file mode 100644 index ea7ceb5ef3..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cookiejar/punycode.go +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package cookiejar - -// This file implements the Punycode algorithm from RFC 3492. - -import ( - "fmt" - "strings" - "unicode/utf8" -) - -// These parameter values are specified in section 5. -// -// All computation is done with int32s, so that overflow behavior is identical -// regardless of whether int is 32-bit or 64-bit. -const ( - base int32 = 36 - damp int32 = 700 - initialBias int32 = 72 - initialN int32 = 128 - skew int32 = 38 - tmax int32 = 26 - tmin int32 = 1 -) - -// encode encodes a string as specified in section 6.3 and prepends prefix to -// the result. -// -// The "while h < length(input)" line in the specification becomes "for -// remaining != 0" in the Go code, because len(s) in Go is in bytes, not runes. -func encode(prefix, s string) (string, error) { - output := make([]byte, len(prefix), len(prefix)+1+2*len(s)) - copy(output, prefix) - delta, n, bias := int32(0), initialN, initialBias - b, remaining := int32(0), int32(0) - for _, r := range s { - if r < 0x80 { - b++ - output = append(output, byte(r)) - } else { - remaining++ - } - } - h := b - if b > 0 { - output = append(output, '-') - } - for remaining != 0 { - m := int32(0x7fffffff) - for _, r := range s { - if m > r && r >= n { - m = r - } - } - delta += (m - n) * (h + 1) - if delta < 0 { - return "", fmt.Errorf("cookiejar: invalid label %q", s) - } - n = m - for _, r := range s { - if r < n { - delta++ - if delta < 0 { - return "", fmt.Errorf("cookiejar: invalid label %q", s) - } - continue - } - if r > n { - continue - } - q := delta - for k := base; ; k += base { - t := k - bias - if t < tmin { - t = tmin - } else if t > tmax { - t = tmax - } - if q < t { - break - } - output = append(output, encodeDigit(t+(q-t)%(base-t))) - q = (q - t) / (base - t) - } - output = append(output, encodeDigit(q)) - bias = adapt(delta, h+1, h == b) - delta = 0 - h++ - remaining-- - } - delta++ - n++ - } - return string(output), nil -} - -func encodeDigit(digit int32) byte { - switch { - case 0 <= digit && digit < 26: - return byte(digit + 'a') - case 26 <= digit && digit < 36: - return byte(digit + ('0' - 26)) - } - panic("cookiejar: internal error in punycode encoding") -} - -// adapt is the bias adaptation function specified in section 6.1. -func adapt(delta, numPoints int32, firstTime bool) int32 { - if firstTime { - delta /= damp - } else { - delta /= 2 - } - delta += delta / numPoints - k := int32(0) - for delta > ((base-tmin)*tmax)/2 { - delta /= base - tmin - k += base - } - return k + (base-tmin+1)*delta/(delta+skew) -} - -// Strictly speaking, the remaining code below deals with IDNA (RFC 5890 and -// friends) and not Punycode (RFC 3492) per se. - -// acePrefix is the ASCII Compatible Encoding prefix. -const acePrefix = "xn--" - -// toASCII converts a domain or domain label to its ASCII form. For example, -// toASCII("bücher.example.com") is "xn--bcher-kva.example.com", and -// toASCII("golang") is "golang". -func toASCII(s string) (string, error) { - if ascii(s) { - return s, nil - } - labels := strings.Split(s, ".") - for i, label := range labels { - if !ascii(label) { - a, err := encode(acePrefix, label) - if err != nil { - return "", err - } - labels[i] = a - } - } - return strings.Join(labels, "."), nil -} - -func ascii(s string) bool { - for i := 0; i < len(s); i++ { - if s[i] >= utf8.RuneSelf { - return false - } - } - return true -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cookiejar/punycode_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cookiejar/punycode_test.go deleted file mode 100644 index 0301de14e4..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/cookiejar/punycode_test.go +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package cookiejar - -import ( - "testing" -) - -var punycodeTestCases = [...]struct { - s, encoded string -}{ - {"", ""}, - {"-", "--"}, - {"-a", "-a-"}, - {"-a-", "-a--"}, - {"a", "a-"}, - {"a-", "a--"}, - {"a-b", "a-b-"}, - {"books", "books-"}, - {"bücher", "bcher-kva"}, - {"Hello世界", "Hello-ck1hg65u"}, - {"ü", "tda"}, - {"üý", "tdac"}, - - // The test cases below come from RFC 3492 section 7.1 with Errata 3026. - { - // (A) Arabic (Egyptian). - "\u0644\u064A\u0647\u0645\u0627\u0628\u062A\u0643\u0644" + - "\u0645\u0648\u0634\u0639\u0631\u0628\u064A\u061F", - "egbpdaj6bu4bxfgehfvwxn", - }, - { - // (B) Chinese (simplified). - "\u4ED6\u4EEC\u4E3A\u4EC0\u4E48\u4E0D\u8BF4\u4E2D\u6587", - "ihqwcrb4cv8a8dqg056pqjye", - }, - { - // (C) Chinese (traditional). - "\u4ED6\u5011\u7232\u4EC0\u9EBD\u4E0D\u8AAA\u4E2D\u6587", - "ihqwctvzc91f659drss3x8bo0yb", - }, - { - // (D) Czech. - "\u0050\u0072\u006F\u010D\u0070\u0072\u006F\u0073\u0074" + - "\u011B\u006E\u0065\u006D\u006C\u0075\u0076\u00ED\u010D" + - "\u0065\u0073\u006B\u0079", - "Proprostnemluvesky-uyb24dma41a", - }, - { - // (E) Hebrew. - "\u05DC\u05DE\u05D4\u05D4\u05DD\u05E4\u05E9\u05D5\u05D8" + - "\u05DC\u05D0\u05DE\u05D3\u05D1\u05E8\u05D9\u05DD\u05E2" + - "\u05D1\u05E8\u05D9\u05EA", - "4dbcagdahymbxekheh6e0a7fei0b", - }, - { - // (F) Hindi (Devanagari). - "\u092F\u0939\u0932\u094B\u0917\u0939\u093F\u0928\u094D" + - "\u0926\u0940\u0915\u094D\u092F\u094B\u0902\u0928\u0939" + - "\u0940\u0902\u092C\u094B\u0932\u0938\u0915\u0924\u0947" + - "\u0939\u0948\u0902", - "i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd", - }, - { - // (G) Japanese (kanji and hiragana). - "\u306A\u305C\u307F\u3093\u306A\u65E5\u672C\u8A9E\u3092" + - "\u8A71\u3057\u3066\u304F\u308C\u306A\u3044\u306E\u304B", - "n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa", - }, - { - // (H) Korean (Hangul syllables). - "\uC138\uACC4\uC758\uBAA8\uB4E0\uC0AC\uB78C\uB4E4\uC774" + - "\uD55C\uAD6D\uC5B4\uB97C\uC774\uD574\uD55C\uB2E4\uBA74" + - "\uC5BC\uB9C8\uB098\uC88B\uC744\uAE4C", - "989aomsvi5e83db1d2a355cv1e0vak1dwrv93d5xbh15a0dt30a5j" + - "psd879ccm6fea98c", - }, - { - // (I) Russian (Cyrillic). - "\u043F\u043E\u0447\u0435\u043C\u0443\u0436\u0435\u043E" + - "\u043D\u0438\u043D\u0435\u0433\u043E\u0432\u043E\u0440" + - "\u044F\u0442\u043F\u043E\u0440\u0443\u0441\u0441\u043A" + - "\u0438", - "b1abfaaepdrnnbgefbadotcwatmq2g4l", - }, - { - // (J) Spanish. - "\u0050\u006F\u0072\u0071\u0075\u00E9\u006E\u006F\u0070" + - "\u0075\u0065\u0064\u0065\u006E\u0073\u0069\u006D\u0070" + - "\u006C\u0065\u006D\u0065\u006E\u0074\u0065\u0068\u0061" + - "\u0062\u006C\u0061\u0072\u0065\u006E\u0045\u0073\u0070" + - "\u0061\u00F1\u006F\u006C", - "PorqunopuedensimplementehablarenEspaol-fmd56a", - }, - { - // (K) Vietnamese. - "\u0054\u1EA1\u0069\u0073\u0061\u006F\u0068\u1ECD\u006B" + - "\u0068\u00F4\u006E\u0067\u0074\u0068\u1EC3\u0063\u0068" + - "\u1EC9\u006E\u00F3\u0069\u0074\u0069\u1EBF\u006E\u0067" + - "\u0056\u0069\u1EC7\u0074", - "TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g", - }, - { - // (L) 3B. - "\u0033\u5E74\u0042\u7D44\u91D1\u516B\u5148\u751F", - "3B-ww4c5e180e575a65lsy2b", - }, - { - // (M) -with-SUPER-MONKEYS. - "\u5B89\u5BA4\u5948\u7F8E\u6075\u002D\u0077\u0069\u0074" + - "\u0068\u002D\u0053\u0055\u0050\u0045\u0052\u002D\u004D" + - "\u004F\u004E\u004B\u0045\u0059\u0053", - "-with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n", - }, - { - // (N) Hello-Another-Way-. - "\u0048\u0065\u006C\u006C\u006F\u002D\u0041\u006E\u006F" + - "\u0074\u0068\u0065\u0072\u002D\u0057\u0061\u0079\u002D" + - "\u305D\u308C\u305E\u308C\u306E\u5834\u6240", - "Hello-Another-Way--fc4qua05auwb3674vfr0b", - }, - { - // (O) 2. - "\u3072\u3068\u3064\u5C4B\u6839\u306E\u4E0B\u0032", - "2-u9tlzr9756bt3uc0v", - }, - { - // (P) MajiKoi5 - "\u004D\u0061\u006A\u0069\u3067\u004B\u006F\u0069\u3059" + - "\u308B\u0035\u79D2\u524D", - "MajiKoi5-783gue6qz075azm5e", - }, - { - // (Q) de - "\u30D1\u30D5\u30A3\u30FC\u0064\u0065\u30EB\u30F3\u30D0", - "de-jg4avhby1noc0d", - }, - { - // (R) - "\u305D\u306E\u30B9\u30D4\u30FC\u30C9\u3067", - "d9juau41awczczp", - }, - { - // (S) -> $1.00 <- - "\u002D\u003E\u0020\u0024\u0031\u002E\u0030\u0030\u0020" + - "\u003C\u002D", - "-> $1.00 <--", - }, -} - -func TestPunycode(t *testing.T) { - for _, tc := range punycodeTestCases { - if got, err := encode("", tc.s); err != nil { - t.Errorf(`encode("", %q): %v`, tc.s, err) - } else if got != tc.encoded { - t.Errorf(`encode("", %q): got %q, want %q`, tc.s, got, tc.encoded) - } - } -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/example_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/example_test.go deleted file mode 100644 index 88b97d9e3d..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/example_test.go +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http_test - -import ( - "fmt" - "io/ioutil" - "log" - "net/http" -) - -func ExampleHijacker() { - http.HandleFunc("/hijack", func(w http.ResponseWriter, r *http.Request) { - hj, ok := w.(http.Hijacker) - if !ok { - http.Error(w, "webserver doesn't support hijacking", http.StatusInternalServerError) - return - } - conn, bufrw, err := hj.Hijack() - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - // Don't forget to close the connection: - defer conn.Close() - bufrw.WriteString("Now we're speaking raw TCP. Say hi: ") - bufrw.Flush() - s, err := bufrw.ReadString('\n') - if err != nil { - log.Printf("error reading string: %v", err) - return - } - fmt.Fprintf(bufrw, "You said: %q\nBye.\n", s) - bufrw.Flush() - }) -} - -func ExampleGet() { - res, err := http.Get("http://www.google.com/robots.txt") - if err != nil { - log.Fatal(err) - } - robots, err := ioutil.ReadAll(res.Body) - res.Body.Close() - if err != nil { - log.Fatal(err) - } - fmt.Printf("%s", robots) -} - -func ExampleFileServer() { - // Simple static webserver: - log.Fatal(http.ListenAndServe(":8080", http.FileServer(http.Dir("/usr/share/doc")))) -} - -func ExampleFileServer_stripPrefix() { - // To serve a directory on disk (/tmp) under an alternate URL - // path (/tmpfiles/), use StripPrefix to modify the request - // URL's path before the FileServer sees it: - http.Handle("/tmpfiles/", http.StripPrefix("/tmpfiles/", http.FileServer(http.Dir("/tmp")))) -} - -func ExampleStripPrefix() { - // To serve a directory on disk (/tmp) under an alternate URL - // path (/tmpfiles/), use StripPrefix to modify the request - // URL's path before the FileServer sees it: - http.Handle("/tmpfiles/", http.StripPrefix("/tmpfiles/", http.FileServer(http.Dir("/tmp")))) -} - -type apiHandler struct{} - -func (apiHandler) ServeHTTP(http.ResponseWriter, *http.Request) {} - -func ExampleServeMux_Handle() { - mux := http.NewServeMux() - mux.Handle("/api/", apiHandler{}) - mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { - // The "/" pattern matches everything, so we need to check - // that we're at the root here. - if req.URL.Path != "/" { - http.NotFound(w, req) - return - } - fmt.Fprintf(w, "Welcome to the home page!") - }) -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/export_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/export_test.go deleted file mode 100644 index 960563b240..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/export_test.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Bridge package to expose http internals to tests in the http_test -// package. - -package http - -import ( - "net" - "time" -) - -func NewLoggingConn(baseName string, c net.Conn) net.Conn { - return newLoggingConn(baseName, c) -} - -var ExportAppendTime = appendTime - -func (t *Transport) NumPendingRequestsForTesting() int { - t.reqMu.Lock() - defer t.reqMu.Unlock() - return len(t.reqCanceler) -} - -func (t *Transport) IdleConnKeysForTesting() (keys []string) { - keys = make([]string, 0) - t.idleMu.Lock() - defer t.idleMu.Unlock() - if t.idleConn == nil { - return - } - for key := range t.idleConn { - keys = append(keys, key.String()) - } - return -} - -func (t *Transport) IdleConnCountForTesting(cacheKey string) int { - t.idleMu.Lock() - defer t.idleMu.Unlock() - if t.idleConn == nil { - return 0 - } - for k, conns := range t.idleConn { - if k.String() == cacheKey { - return len(conns) - } - } - return 0 -} - -func (t *Transport) IdleConnChMapSizeForTesting() int { - t.idleMu.Lock() - defer t.idleMu.Unlock() - return len(t.idleConnCh) -} - -func NewTestTimeoutHandler(handler Handler, ch <-chan time.Time) Handler { - f := func() <-chan time.Time { - return ch - } - return &timeoutHandler{handler, f, ""} -} - -func ResetCachedEnvironment() { - httpProxyEnv.reset() - noProxyEnv.reset() -} - -var DefaultUserAgent = defaultUserAgent diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/fcgi/child.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/fcgi/child.go deleted file mode 100644 index a3beaa33a8..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/fcgi/child.go +++ /dev/null @@ -1,305 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package fcgi - -// This file implements FastCGI from the perspective of a child process. - -import ( - "errors" - "fmt" - "io" - "io/ioutil" - "net" - "net/http" - "net/http/cgi" - "os" - "strings" - "sync" - "time" -) - -// request holds the state for an in-progress request. As soon as it's complete, -// it's converted to an http.Request. -type request struct { - pw *io.PipeWriter - reqId uint16 - params map[string]string - buf [1024]byte - rawParams []byte - keepConn bool -} - -func newRequest(reqId uint16, flags uint8) *request { - r := &request{ - reqId: reqId, - params: map[string]string{}, - keepConn: flags&flagKeepConn != 0, - } - r.rawParams = r.buf[:0] - return r -} - -// parseParams reads an encoded []byte into Params. -func (r *request) parseParams() { - text := r.rawParams - r.rawParams = nil - for len(text) > 0 { - keyLen, n := readSize(text) - if n == 0 { - return - } - text = text[n:] - valLen, n := readSize(text) - if n == 0 { - return - } - text = text[n:] - key := readString(text, keyLen) - text = text[keyLen:] - val := readString(text, valLen) - text = text[valLen:] - r.params[key] = val - } -} - -// response implements http.ResponseWriter. -type response struct { - req *request - header http.Header - w *bufWriter - wroteHeader bool -} - -func newResponse(c *child, req *request) *response { - return &response{ - req: req, - header: http.Header{}, - w: newWriter(c.conn, typeStdout, req.reqId), - } -} - -func (r *response) Header() http.Header { - return r.header -} - -func (r *response) Write(data []byte) (int, error) { - if !r.wroteHeader { - r.WriteHeader(http.StatusOK) - } - return r.w.Write(data) -} - -func (r *response) WriteHeader(code int) { - if r.wroteHeader { - return - } - r.wroteHeader = true - if code == http.StatusNotModified { - // Must not have body. - r.header.Del("Content-Type") - r.header.Del("Content-Length") - r.header.Del("Transfer-Encoding") - } else if r.header.Get("Content-Type") == "" { - r.header.Set("Content-Type", "text/html; charset=utf-8") - } - - if r.header.Get("Date") == "" { - r.header.Set("Date", time.Now().UTC().Format(http.TimeFormat)) - } - - fmt.Fprintf(r.w, "Status: %d %s\r\n", code, http.StatusText(code)) - r.header.Write(r.w) - r.w.WriteString("\r\n") -} - -func (r *response) Flush() { - if !r.wroteHeader { - r.WriteHeader(http.StatusOK) - } - r.w.Flush() -} - -func (r *response) Close() error { - r.Flush() - return r.w.Close() -} - -type child struct { - conn *conn - handler http.Handler - - mu sync.Mutex // protects requests: - requests map[uint16]*request // keyed by request ID -} - -func newChild(rwc io.ReadWriteCloser, handler http.Handler) *child { - return &child{ - conn: newConn(rwc), - handler: handler, - requests: make(map[uint16]*request), - } -} - -func (c *child) serve() { - defer c.conn.Close() - var rec record - for { - if err := rec.read(c.conn.rwc); err != nil { - return - } - if err := c.handleRecord(&rec); err != nil { - return - } - } -} - -var errCloseConn = errors.New("fcgi: connection should be closed") - -var emptyBody = ioutil.NopCloser(strings.NewReader("")) - -func (c *child) handleRecord(rec *record) error { - c.mu.Lock() - req, ok := c.requests[rec.h.Id] - c.mu.Unlock() - if !ok && rec.h.Type != typeBeginRequest && rec.h.Type != typeGetValues { - // The spec says to ignore unknown request IDs. - return nil - } - - switch rec.h.Type { - case typeBeginRequest: - if req != nil { - // The server is trying to begin a request with the same ID - // as an in-progress request. This is an error. - return errors.New("fcgi: received ID that is already in-flight") - } - - var br beginRequest - if err := br.read(rec.content()); err != nil { - return err - } - if br.role != roleResponder { - c.conn.writeEndRequest(rec.h.Id, 0, statusUnknownRole) - return nil - } - req = newRequest(rec.h.Id, br.flags) - c.mu.Lock() - c.requests[rec.h.Id] = req - c.mu.Unlock() - return nil - case typeParams: - // NOTE(eds): Technically a key-value pair can straddle the boundary - // between two packets. We buffer until we've received all parameters. - if len(rec.content()) > 0 { - req.rawParams = append(req.rawParams, rec.content()...) - return nil - } - req.parseParams() - return nil - case typeStdin: - content := rec.content() - if req.pw == nil { - var body io.ReadCloser - if len(content) > 0 { - // body could be an io.LimitReader, but it shouldn't matter - // as long as both sides are behaving. - body, req.pw = io.Pipe() - } else { - body = emptyBody - } - go c.serveRequest(req, body) - } - if len(content) > 0 { - // TODO(eds): This blocks until the handler reads from the pipe. - // If the handler takes a long time, it might be a problem. - req.pw.Write(content) - } else if req.pw != nil { - req.pw.Close() - } - return nil - case typeGetValues: - values := map[string]string{"FCGI_MPXS_CONNS": "1"} - c.conn.writePairs(typeGetValuesResult, 0, values) - return nil - case typeData: - // If the filter role is implemented, read the data stream here. - return nil - case typeAbortRequest: - println("abort") - c.mu.Lock() - delete(c.requests, rec.h.Id) - c.mu.Unlock() - c.conn.writeEndRequest(rec.h.Id, 0, statusRequestComplete) - if !req.keepConn { - // connection will close upon return - return errCloseConn - } - return nil - default: - b := make([]byte, 8) - b[0] = byte(rec.h.Type) - c.conn.writeRecord(typeUnknownType, 0, b) - return nil - } -} - -func (c *child) serveRequest(req *request, body io.ReadCloser) { - r := newResponse(c, req) - httpReq, err := cgi.RequestFromMap(req.params) - if err != nil { - // there was an error reading the request - r.WriteHeader(http.StatusInternalServerError) - c.conn.writeRecord(typeStderr, req.reqId, []byte(err.Error())) - } else { - httpReq.Body = body - c.handler.ServeHTTP(r, httpReq) - } - r.Close() - c.mu.Lock() - delete(c.requests, req.reqId) - c.mu.Unlock() - c.conn.writeEndRequest(req.reqId, 0, statusRequestComplete) - - // Consume the entire body, so the host isn't still writing to - // us when we close the socket below in the !keepConn case, - // otherwise we'd send a RST. (golang.org/issue/4183) - // TODO(bradfitz): also bound this copy in time. Or send - // some sort of abort request to the host, so the host - // can properly cut off the client sending all the data. - // For now just bound it a little and - io.CopyN(ioutil.Discard, body, 100<<20) - body.Close() - - if !req.keepConn { - c.conn.Close() - } -} - -// Serve accepts incoming FastCGI connections on the listener l, creating a new -// goroutine for each. The goroutine reads requests and then calls handler -// to reply to them. -// If l is nil, Serve accepts connections from os.Stdin. -// If handler is nil, http.DefaultServeMux is used. -func Serve(l net.Listener, handler http.Handler) error { - if l == nil { - var err error - l, err = net.FileListener(os.Stdin) - if err != nil { - return err - } - defer l.Close() - } - if handler == nil { - handler = http.DefaultServeMux - } - for { - rw, err := l.Accept() - if err != nil { - return err - } - c := newChild(rw, handler) - go c.serve() - } -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/fcgi/fcgi.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/fcgi/fcgi.go deleted file mode 100644 index 06bba0488a..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/fcgi/fcgi.go +++ /dev/null @@ -1,274 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package fcgi implements the FastCGI protocol. -// Currently only the responder role is supported. -// The protocol is defined at http://www.fastcgi.com/drupal/node/6?q=node/22 -package fcgi - -// This file defines the raw protocol and some utilities used by the child and -// the host. - -import ( - "bufio" - "bytes" - "encoding/binary" - "errors" - "io" - "sync" -) - -// recType is a record type, as defined by -// http://www.fastcgi.com/devkit/doc/fcgi-spec.html#S8 -type recType uint8 - -const ( - typeBeginRequest recType = 1 - typeAbortRequest recType = 2 - typeEndRequest recType = 3 - typeParams recType = 4 - typeStdin recType = 5 - typeStdout recType = 6 - typeStderr recType = 7 - typeData recType = 8 - typeGetValues recType = 9 - typeGetValuesResult recType = 10 - typeUnknownType recType = 11 -) - -// keep the connection between web-server and responder open after request -const flagKeepConn = 1 - -const ( - maxWrite = 65535 // maximum record body - maxPad = 255 -) - -const ( - roleResponder = iota + 1 // only Responders are implemented. - roleAuthorizer - roleFilter -) - -const ( - statusRequestComplete = iota - statusCantMultiplex - statusOverloaded - statusUnknownRole -) - -const headerLen = 8 - -type header struct { - Version uint8 - Type recType - Id uint16 - ContentLength uint16 - PaddingLength uint8 - Reserved uint8 -} - -type beginRequest struct { - role uint16 - flags uint8 - reserved [5]uint8 -} - -func (br *beginRequest) read(content []byte) error { - if len(content) != 8 { - return errors.New("fcgi: invalid begin request record") - } - br.role = binary.BigEndian.Uint16(content) - br.flags = content[2] - return nil -} - -// for padding so we don't have to allocate all the time -// not synchronized because we don't care what the contents are -var pad [maxPad]byte - -func (h *header) init(recType recType, reqId uint16, contentLength int) { - h.Version = 1 - h.Type = recType - h.Id = reqId - h.ContentLength = uint16(contentLength) - h.PaddingLength = uint8(-contentLength & 7) -} - -// conn sends records over rwc -type conn struct { - mutex sync.Mutex - rwc io.ReadWriteCloser - - // to avoid allocations - buf bytes.Buffer - h header -} - -func newConn(rwc io.ReadWriteCloser) *conn { - return &conn{rwc: rwc} -} - -func (c *conn) Close() error { - c.mutex.Lock() - defer c.mutex.Unlock() - return c.rwc.Close() -} - -type record struct { - h header - buf [maxWrite + maxPad]byte -} - -func (rec *record) read(r io.Reader) (err error) { - if err = binary.Read(r, binary.BigEndian, &rec.h); err != nil { - return err - } - if rec.h.Version != 1 { - return errors.New("fcgi: invalid header version") - } - n := int(rec.h.ContentLength) + int(rec.h.PaddingLength) - if _, err = io.ReadFull(r, rec.buf[:n]); err != nil { - return err - } - return nil -} - -func (r *record) content() []byte { - return r.buf[:r.h.ContentLength] -} - -// writeRecord writes and sends a single record. -func (c *conn) writeRecord(recType recType, reqId uint16, b []byte) error { - c.mutex.Lock() - defer c.mutex.Unlock() - c.buf.Reset() - c.h.init(recType, reqId, len(b)) - if err := binary.Write(&c.buf, binary.BigEndian, c.h); err != nil { - return err - } - if _, err := c.buf.Write(b); err != nil { - return err - } - if _, err := c.buf.Write(pad[:c.h.PaddingLength]); err != nil { - return err - } - _, err := c.rwc.Write(c.buf.Bytes()) - return err -} - -func (c *conn) writeBeginRequest(reqId uint16, role uint16, flags uint8) error { - b := [8]byte{byte(role >> 8), byte(role), flags} - return c.writeRecord(typeBeginRequest, reqId, b[:]) -} - -func (c *conn) writeEndRequest(reqId uint16, appStatus int, protocolStatus uint8) error { - b := make([]byte, 8) - binary.BigEndian.PutUint32(b, uint32(appStatus)) - b[4] = protocolStatus - return c.writeRecord(typeEndRequest, reqId, b) -} - -func (c *conn) writePairs(recType recType, reqId uint16, pairs map[string]string) error { - w := newWriter(c, recType, reqId) - b := make([]byte, 8) - for k, v := range pairs { - n := encodeSize(b, uint32(len(k))) - n += encodeSize(b[n:], uint32(len(v))) - if _, err := w.Write(b[:n]); err != nil { - return err - } - if _, err := w.WriteString(k); err != nil { - return err - } - if _, err := w.WriteString(v); err != nil { - return err - } - } - w.Close() - return nil -} - -func readSize(s []byte) (uint32, int) { - if len(s) == 0 { - return 0, 0 - } - size, n := uint32(s[0]), 1 - if size&(1<<7) != 0 { - if len(s) < 4 { - return 0, 0 - } - n = 4 - size = binary.BigEndian.Uint32(s) - size &^= 1 << 31 - } - return size, n -} - -func readString(s []byte, size uint32) string { - if size > uint32(len(s)) { - return "" - } - return string(s[:size]) -} - -func encodeSize(b []byte, size uint32) int { - if size > 127 { - size |= 1 << 31 - binary.BigEndian.PutUint32(b, size) - return 4 - } - b[0] = byte(size) - return 1 -} - -// bufWriter encapsulates bufio.Writer but also closes the underlying stream when -// Closed. -type bufWriter struct { - closer io.Closer - *bufio.Writer -} - -func (w *bufWriter) Close() error { - if err := w.Writer.Flush(); err != nil { - w.closer.Close() - return err - } - return w.closer.Close() -} - -func newWriter(c *conn, recType recType, reqId uint16) *bufWriter { - s := &streamWriter{c: c, recType: recType, reqId: reqId} - w := bufio.NewWriterSize(s, maxWrite) - return &bufWriter{s, w} -} - -// streamWriter abstracts out the separation of a stream into discrete records. -// It only writes maxWrite bytes at a time. -type streamWriter struct { - c *conn - recType recType - reqId uint16 -} - -func (w *streamWriter) Write(p []byte) (int, error) { - nn := 0 - for len(p) > 0 { - n := len(p) - if n > maxWrite { - n = maxWrite - } - if err := w.c.writeRecord(w.recType, w.reqId, p[:n]); err != nil { - return nn, err - } - nn += n - p = p[n:] - } - return nn, nil -} - -func (w *streamWriter) Close() error { - // send empty record to close the stream - return w.c.writeRecord(w.recType, w.reqId, nil) -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/fcgi/fcgi_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/fcgi/fcgi_test.go deleted file mode 100644 index 6c7e1a9ce8..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/fcgi/fcgi_test.go +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package fcgi - -import ( - "bytes" - "errors" - "io" - "testing" -) - -var sizeTests = []struct { - size uint32 - bytes []byte -}{ - {0, []byte{0x00}}, - {127, []byte{0x7F}}, - {128, []byte{0x80, 0x00, 0x00, 0x80}}, - {1000, []byte{0x80, 0x00, 0x03, 0xE8}}, - {33554431, []byte{0x81, 0xFF, 0xFF, 0xFF}}, -} - -func TestSize(t *testing.T) { - b := make([]byte, 4) - for i, test := range sizeTests { - n := encodeSize(b, test.size) - if !bytes.Equal(b[:n], test.bytes) { - t.Errorf("%d expected %x, encoded %x", i, test.bytes, b) - } - size, n := readSize(test.bytes) - if size != test.size { - t.Errorf("%d expected %d, read %d", i, test.size, size) - } - if len(test.bytes) != n { - t.Errorf("%d did not consume all the bytes", i) - } - } -} - -var streamTests = []struct { - desc string - recType recType - reqId uint16 - content []byte - raw []byte -}{ - {"single record", typeStdout, 1, nil, - []byte{1, byte(typeStdout), 0, 1, 0, 0, 0, 0}, - }, - // this data will have to be split into two records - {"two records", typeStdin, 300, make([]byte, 66000), - bytes.Join([][]byte{ - // header for the first record - {1, byte(typeStdin), 0x01, 0x2C, 0xFF, 0xFF, 1, 0}, - make([]byte, 65536), - // header for the second - {1, byte(typeStdin), 0x01, 0x2C, 0x01, 0xD1, 7, 0}, - make([]byte, 472), - // header for the empty record - {1, byte(typeStdin), 0x01, 0x2C, 0, 0, 0, 0}, - }, - nil), - }, -} - -type nilCloser struct { - io.ReadWriter -} - -func (c *nilCloser) Close() error { return nil } - -func TestStreams(t *testing.T) { - var rec record -outer: - for _, test := range streamTests { - buf := bytes.NewBuffer(test.raw) - var content []byte - for buf.Len() > 0 { - if err := rec.read(buf); err != nil { - t.Errorf("%s: error reading record: %v", test.desc, err) - continue outer - } - content = append(content, rec.content()...) - } - if rec.h.Type != test.recType { - t.Errorf("%s: got type %d expected %d", test.desc, rec.h.Type, test.recType) - continue - } - if rec.h.Id != test.reqId { - t.Errorf("%s: got request ID %d expected %d", test.desc, rec.h.Id, test.reqId) - continue - } - if !bytes.Equal(content, test.content) { - t.Errorf("%s: read wrong content", test.desc) - continue - } - buf.Reset() - c := newConn(&nilCloser{buf}) - w := newWriter(c, test.recType, test.reqId) - if _, err := w.Write(test.content); err != nil { - t.Errorf("%s: error writing record: %v", test.desc, err) - continue - } - if err := w.Close(); err != nil { - t.Errorf("%s: error closing stream: %v", test.desc, err) - continue - } - if !bytes.Equal(buf.Bytes(), test.raw) { - t.Errorf("%s: wrote wrong content", test.desc) - } - } -} - -type writeOnlyConn struct { - buf []byte -} - -func (c *writeOnlyConn) Write(p []byte) (int, error) { - c.buf = append(c.buf, p...) - return len(p), nil -} - -func (c *writeOnlyConn) Read(p []byte) (int, error) { - return 0, errors.New("conn is write-only") -} - -func (c *writeOnlyConn) Close() error { - return nil -} - -func TestGetValues(t *testing.T) { - var rec record - rec.h.Type = typeGetValues - - wc := new(writeOnlyConn) - c := newChild(wc, nil) - err := c.handleRecord(&rec) - if err != nil { - t.Fatalf("handleRecord: %v", err) - } - - const want = "\x01\n\x00\x00\x00\x12\x06\x00" + - "\x0f\x01FCGI_MPXS_CONNS1" + - "\x00\x00\x00\x00\x00\x00\x01\n\x00\x00\x00\x00\x00\x00" - if got := string(wc.buf); got != want { - t.Errorf(" got: %q\nwant: %q\n", got, want) - } -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/filetransport_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/filetransport_test.go deleted file mode 100644 index 6f1a537e2e..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/filetransport_test.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http - -import ( - "io/ioutil" - "os" - "path/filepath" - "testing" -) - -func checker(t *testing.T) func(string, error) { - return func(call string, err error) { - if err == nil { - return - } - t.Fatalf("%s: %v", call, err) - } -} - -func TestFileTransport(t *testing.T) { - check := checker(t) - - dname, err := ioutil.TempDir("", "") - check("TempDir", err) - fname := filepath.Join(dname, "foo.txt") - err = ioutil.WriteFile(fname, []byte("Bar"), 0644) - check("WriteFile", err) - defer os.Remove(dname) - defer os.Remove(fname) - - tr := &Transport{} - tr.RegisterProtocol("file", NewFileTransport(Dir(dname))) - c := &Client{Transport: tr} - - fooURLs := []string{"file:///foo.txt", "file://../foo.txt"} - for _, urlstr := range fooURLs { - res, err := c.Get(urlstr) - check("Get "+urlstr, err) - if res.StatusCode != 200 { - t.Errorf("for %s, StatusCode = %d, want 200", urlstr, res.StatusCode) - } - if res.ContentLength != -1 { - t.Errorf("for %s, ContentLength = %d, want -1", urlstr, res.ContentLength) - } - if res.Body == nil { - t.Fatalf("for %s, nil Body", urlstr) - } - slurp, err := ioutil.ReadAll(res.Body) - check("ReadAll "+urlstr, err) - if string(slurp) != "Bar" { - t.Errorf("for %s, got content %q, want %q", urlstr, string(slurp), "Bar") - } - } - - const badURL = "file://../no-exist.txt" - res, err := c.Get(badURL) - check("Get "+badURL, err) - if res.StatusCode != 404 { - t.Errorf("for %s, StatusCode = %d, want 404", badURL, res.StatusCode) - } - res.Body.Close() -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/fs_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/fs_test.go deleted file mode 100644 index f968565f9b..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/fs_test.go +++ /dev/null @@ -1,858 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http_test - -import ( - "bytes" - "errors" - "fmt" - "io" - "io/ioutil" - "mime" - "mime/multipart" - "net" - . "net/http" - "net/http/httptest" - "net/url" - "os" - "os/exec" - "path" - "path/filepath" - "reflect" - "regexp" - "runtime" - "strconv" - "strings" - "testing" - "time" -) - -const ( - testFile = "testdata/file" - testFileLen = 11 -) - -type wantRange struct { - start, end int64 // range [start,end) -} - -var itoa = strconv.Itoa - -var ServeFileRangeTests = []struct { - r string - code int - ranges []wantRange -}{ - {r: "", code: StatusOK}, - {r: "bytes=0-4", code: StatusPartialContent, ranges: []wantRange{{0, 5}}}, - {r: "bytes=2-", code: StatusPartialContent, ranges: []wantRange{{2, testFileLen}}}, - {r: "bytes=-5", code: StatusPartialContent, ranges: []wantRange{{testFileLen - 5, testFileLen}}}, - {r: "bytes=3-7", code: StatusPartialContent, ranges: []wantRange{{3, 8}}}, - {r: "bytes=20-", code: StatusRequestedRangeNotSatisfiable}, - {r: "bytes=0-0,-2", code: StatusPartialContent, ranges: []wantRange{{0, 1}, {testFileLen - 2, testFileLen}}}, - {r: "bytes=0-1,5-8", code: StatusPartialContent, ranges: []wantRange{{0, 2}, {5, 9}}}, - {r: "bytes=0-1,5-", code: StatusPartialContent, ranges: []wantRange{{0, 2}, {5, testFileLen}}}, - {r: "bytes=5-1000", code: StatusPartialContent, ranges: []wantRange{{5, testFileLen}}}, - {r: "bytes=0-,1-,2-,3-,4-", code: StatusOK}, // ignore wasteful range request - {r: "bytes=0-" + itoa(testFileLen-2), code: StatusPartialContent, ranges: []wantRange{{0, testFileLen - 1}}}, - {r: "bytes=0-" + itoa(testFileLen-1), code: StatusPartialContent, ranges: []wantRange{{0, testFileLen}}}, - {r: "bytes=0-" + itoa(testFileLen), code: StatusPartialContent, ranges: []wantRange{{0, testFileLen}}}, -} - -func TestServeFile(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - ServeFile(w, r, "testdata/file") - })) - defer ts.Close() - - var err error - - file, err := ioutil.ReadFile(testFile) - if err != nil { - t.Fatal("reading file:", err) - } - - // set up the Request (re-used for all tests) - var req Request - req.Header = make(Header) - if req.URL, err = url.Parse(ts.URL); err != nil { - t.Fatal("ParseURL:", err) - } - req.Method = "GET" - - // straight GET - _, body := getBody(t, "straight get", req) - if !bytes.Equal(body, file) { - t.Fatalf("body mismatch: got %q, want %q", body, file) - } - - // Range tests -Cases: - for _, rt := range ServeFileRangeTests { - if rt.r != "" { - req.Header.Set("Range", rt.r) - } - resp, body := getBody(t, fmt.Sprintf("range test %q", rt.r), req) - if resp.StatusCode != rt.code { - t.Errorf("range=%q: StatusCode=%d, want %d", rt.r, resp.StatusCode, rt.code) - } - if rt.code == StatusRequestedRangeNotSatisfiable { - continue - } - wantContentRange := "" - if len(rt.ranges) == 1 { - rng := rt.ranges[0] - wantContentRange = fmt.Sprintf("bytes %d-%d/%d", rng.start, rng.end-1, testFileLen) - } - cr := resp.Header.Get("Content-Range") - if cr != wantContentRange { - t.Errorf("range=%q: Content-Range = %q, want %q", rt.r, cr, wantContentRange) - } - ct := resp.Header.Get("Content-Type") - if len(rt.ranges) == 1 { - rng := rt.ranges[0] - wantBody := file[rng.start:rng.end] - if !bytes.Equal(body, wantBody) { - t.Errorf("range=%q: body = %q, want %q", rt.r, body, wantBody) - } - if strings.HasPrefix(ct, "multipart/byteranges") { - t.Errorf("range=%q content-type = %q; unexpected multipart/byteranges", rt.r, ct) - } - } - if len(rt.ranges) > 1 { - typ, params, err := mime.ParseMediaType(ct) - if err != nil { - t.Errorf("range=%q content-type = %q; %v", rt.r, ct, err) - continue - } - if typ != "multipart/byteranges" { - t.Errorf("range=%q content-type = %q; want multipart/byteranges", rt.r, typ) - continue - } - if params["boundary"] == "" { - t.Errorf("range=%q content-type = %q; lacks boundary", rt.r, ct) - continue - } - if g, w := resp.ContentLength, int64(len(body)); g != w { - t.Errorf("range=%q Content-Length = %d; want %d", rt.r, g, w) - continue - } - mr := multipart.NewReader(bytes.NewReader(body), params["boundary"]) - for ri, rng := range rt.ranges { - part, err := mr.NextPart() - if err != nil { - t.Errorf("range=%q, reading part index %d: %v", rt.r, ri, err) - continue Cases - } - wantContentRange = fmt.Sprintf("bytes %d-%d/%d", rng.start, rng.end-1, testFileLen) - if g, w := part.Header.Get("Content-Range"), wantContentRange; g != w { - t.Errorf("range=%q: part Content-Range = %q; want %q", rt.r, g, w) - } - body, err := ioutil.ReadAll(part) - if err != nil { - t.Errorf("range=%q, reading part index %d body: %v", rt.r, ri, err) - continue Cases - } - wantBody := file[rng.start:rng.end] - if !bytes.Equal(body, wantBody) { - t.Errorf("range=%q: body = %q, want %q", rt.r, body, wantBody) - } - } - _, err = mr.NextPart() - if err != io.EOF { - t.Errorf("range=%q; expected final error io.EOF; got %v", rt.r, err) - } - } - } -} - -var fsRedirectTestData = []struct { - original, redirect string -}{ - {"/test/index.html", "/test/"}, - {"/test/testdata", "/test/testdata/"}, - {"/test/testdata/file/", "/test/testdata/file"}, -} - -func TestFSRedirect(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(StripPrefix("/test", FileServer(Dir(".")))) - defer ts.Close() - - for _, data := range fsRedirectTestData { - res, err := Get(ts.URL + data.original) - if err != nil { - t.Fatal(err) - } - res.Body.Close() - if g, e := res.Request.URL.Path, data.redirect; g != e { - t.Errorf("redirect from %s: got %s, want %s", data.original, g, e) - } - } -} - -type testFileSystem struct { - open func(name string) (File, error) -} - -func (fs *testFileSystem) Open(name string) (File, error) { - return fs.open(name) -} - -func TestFileServerCleans(t *testing.T) { - defer afterTest(t) - ch := make(chan string, 1) - fs := FileServer(&testFileSystem{func(name string) (File, error) { - ch <- name - return nil, errors.New("file does not exist") - }}) - tests := []struct { - reqPath, openArg string - }{ - {"/foo.txt", "/foo.txt"}, - {"//foo.txt", "/foo.txt"}, - {"/../foo.txt", "/foo.txt"}, - } - req, _ := NewRequest("GET", "http://example.com", nil) - for n, test := range tests { - rec := httptest.NewRecorder() - req.URL.Path = test.reqPath - fs.ServeHTTP(rec, req) - if got := <-ch; got != test.openArg { - t.Errorf("test %d: got %q, want %q", n, got, test.openArg) - } - } -} - -func TestFileServerEscapesNames(t *testing.T) { - defer afterTest(t) - const dirListPrefix = "
\n"
-	const dirListSuffix = "\n
\n" - tests := []struct { - name, escaped string - }{ - {`simple_name`, `simple_name`}, - {`"'<>&`, `"'<>&`}, - {`?foo=bar#baz`, `?foo=bar#baz`}, - {`?foo`, `<combo>?foo`}, - } - - // We put each test file in its own directory in the fakeFS so we can look at it in isolation. - fs := make(fakeFS) - for i, test := range tests { - testFile := &fakeFileInfo{basename: test.name} - fs[fmt.Sprintf("/%d", i)] = &fakeFileInfo{ - dir: true, - modtime: time.Unix(1000000000, 0).UTC(), - ents: []*fakeFileInfo{testFile}, - } - fs[fmt.Sprintf("/%d/%s", i, test.name)] = testFile - } - - ts := httptest.NewServer(FileServer(&fs)) - defer ts.Close() - for i, test := range tests { - url := fmt.Sprintf("%s/%d", ts.URL, i) - res, err := Get(url) - if err != nil { - t.Fatalf("test %q: Get: %v", test.name, err) - } - b, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatalf("test %q: read Body: %v", test.name, err) - } - s := string(b) - if !strings.HasPrefix(s, dirListPrefix) || !strings.HasSuffix(s, dirListSuffix) { - t.Errorf("test %q: listing dir, full output is %q, want prefix %q and suffix %q", test.name, s, dirListPrefix, dirListSuffix) - } - if trimmed := strings.TrimSuffix(strings.TrimPrefix(s, dirListPrefix), dirListSuffix); trimmed != test.escaped { - t.Errorf("test %q: listing dir, filename escaped to %q, want %q", test.name, trimmed, test.escaped) - } - res.Body.Close() - } -} - -func mustRemoveAll(dir string) { - err := os.RemoveAll(dir) - if err != nil { - panic(err) - } -} - -func TestFileServerImplicitLeadingSlash(t *testing.T) { - defer afterTest(t) - tempDir, err := ioutil.TempDir("", "") - if err != nil { - t.Fatalf("TempDir: %v", err) - } - defer mustRemoveAll(tempDir) - if err := ioutil.WriteFile(filepath.Join(tempDir, "foo.txt"), []byte("Hello world"), 0644); err != nil { - t.Fatalf("WriteFile: %v", err) - } - ts := httptest.NewServer(StripPrefix("/bar/", FileServer(Dir(tempDir)))) - defer ts.Close() - get := func(suffix string) string { - res, err := Get(ts.URL + suffix) - if err != nil { - t.Fatalf("Get %s: %v", suffix, err) - } - b, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatalf("ReadAll %s: %v", suffix, err) - } - res.Body.Close() - return string(b) - } - if s := get("/bar/"); !strings.Contains(s, ">foo.txt<") { - t.Logf("expected a directory listing with foo.txt, got %q", s) - } - if s := get("/bar/foo.txt"); s != "Hello world" { - t.Logf("expected %q, got %q", "Hello world", s) - } -} - -func TestDirJoin(t *testing.T) { - if runtime.GOOS == "windows" { - t.Skip("skipping test on windows") - } - wfi, err := os.Stat("/etc/hosts") - if err != nil { - t.Skip("skipping test; no /etc/hosts file") - } - test := func(d Dir, name string) { - f, err := d.Open(name) - if err != nil { - t.Fatalf("open of %s: %v", name, err) - } - defer f.Close() - gfi, err := f.Stat() - if err != nil { - t.Fatalf("stat of %s: %v", name, err) - } - if !os.SameFile(gfi, wfi) { - t.Errorf("%s got different file", name) - } - } - test(Dir("/etc/"), "/hosts") - test(Dir("/etc/"), "hosts") - test(Dir("/etc/"), "../../../../hosts") - test(Dir("/etc"), "/hosts") - test(Dir("/etc"), "hosts") - test(Dir("/etc"), "../../../../hosts") - - // Not really directories, but since we use this trick in - // ServeFile, test it: - test(Dir("/etc/hosts"), "") - test(Dir("/etc/hosts"), "/") - test(Dir("/etc/hosts"), "../") -} - -func TestEmptyDirOpenCWD(t *testing.T) { - test := func(d Dir) { - name := "fs_test.go" - f, err := d.Open(name) - if err != nil { - t.Fatalf("open of %s: %v", name, err) - } - defer f.Close() - } - test(Dir("")) - test(Dir(".")) - test(Dir("./")) -} - -func TestServeFileContentType(t *testing.T) { - defer afterTest(t) - const ctype = "icecream/chocolate" - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - switch r.FormValue("override") { - case "1": - w.Header().Set("Content-Type", ctype) - case "2": - // Explicitly inhibit sniffing. - w.Header()["Content-Type"] = []string{} - } - ServeFile(w, r, "testdata/file") - })) - defer ts.Close() - get := func(override string, want []string) { - resp, err := Get(ts.URL + "?override=" + override) - if err != nil { - t.Fatal(err) - } - if h := resp.Header["Content-Type"]; !reflect.DeepEqual(h, want) { - t.Errorf("Content-Type mismatch: got %v, want %v", h, want) - } - resp.Body.Close() - } - get("0", []string{"text/plain; charset=utf-8"}) - get("1", []string{ctype}) - get("2", nil) -} - -func TestServeFileMimeType(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - ServeFile(w, r, "testdata/style.css") - })) - defer ts.Close() - resp, err := Get(ts.URL) - if err != nil { - t.Fatal(err) - } - resp.Body.Close() - want := "text/css; charset=utf-8" - if h := resp.Header.Get("Content-Type"); h != want { - t.Errorf("Content-Type mismatch: got %q, want %q", h, want) - } -} - -func TestServeFileFromCWD(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - ServeFile(w, r, "fs_test.go") - })) - defer ts.Close() - r, err := Get(ts.URL) - if err != nil { - t.Fatal(err) - } - r.Body.Close() - if r.StatusCode != 200 { - t.Fatalf("expected 200 OK, got %s", r.Status) - } -} - -func TestServeFileWithContentEncoding(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - w.Header().Set("Content-Encoding", "foo") - ServeFile(w, r, "testdata/file") - })) - defer ts.Close() - resp, err := Get(ts.URL) - if err != nil { - t.Fatal(err) - } - resp.Body.Close() - if g, e := resp.ContentLength, int64(-1); g != e { - t.Errorf("Content-Length mismatch: got %d, want %d", g, e) - } -} - -func TestServeIndexHtml(t *testing.T) { - defer afterTest(t) - const want = "index.html says hello\n" - ts := httptest.NewServer(FileServer(Dir("."))) - defer ts.Close() - - for _, path := range []string{"/testdata/", "/testdata/index.html"} { - res, err := Get(ts.URL + path) - if err != nil { - t.Fatal(err) - } - b, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatal("reading Body:", err) - } - if s := string(b); s != want { - t.Errorf("for path %q got %q, want %q", path, s, want) - } - res.Body.Close() - } -} - -func TestFileServerZeroByte(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(FileServer(Dir("."))) - defer ts.Close() - - res, err := Get(ts.URL + "/..\x00") - if err != nil { - t.Fatal(err) - } - b, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatal("reading Body:", err) - } - if res.StatusCode == 200 { - t.Errorf("got status 200; want an error. Body is:\n%s", string(b)) - } -} - -type fakeFileInfo struct { - dir bool - basename string - modtime time.Time - ents []*fakeFileInfo - contents string -} - -func (f *fakeFileInfo) Name() string { return f.basename } -func (f *fakeFileInfo) Sys() interface{} { return nil } -func (f *fakeFileInfo) ModTime() time.Time { return f.modtime } -func (f *fakeFileInfo) IsDir() bool { return f.dir } -func (f *fakeFileInfo) Size() int64 { return int64(len(f.contents)) } -func (f *fakeFileInfo) Mode() os.FileMode { - if f.dir { - return 0755 | os.ModeDir - } - return 0644 -} - -type fakeFile struct { - io.ReadSeeker - fi *fakeFileInfo - path string // as opened - entpos int -} - -func (f *fakeFile) Close() error { return nil } -func (f *fakeFile) Stat() (os.FileInfo, error) { return f.fi, nil } -func (f *fakeFile) Readdir(count int) ([]os.FileInfo, error) { - if !f.fi.dir { - return nil, os.ErrInvalid - } - var fis []os.FileInfo - - limit := f.entpos + count - if count <= 0 || limit > len(f.fi.ents) { - limit = len(f.fi.ents) - } - for ; f.entpos < limit; f.entpos++ { - fis = append(fis, f.fi.ents[f.entpos]) - } - - if len(fis) == 0 && count > 0 { - return fis, io.EOF - } else { - return fis, nil - } -} - -type fakeFS map[string]*fakeFileInfo - -func (fs fakeFS) Open(name string) (File, error) { - name = path.Clean(name) - f, ok := fs[name] - if !ok { - return nil, os.ErrNotExist - } - return &fakeFile{ReadSeeker: strings.NewReader(f.contents), fi: f, path: name}, nil -} - -func TestDirectoryIfNotModified(t *testing.T) { - defer afterTest(t) - const indexContents = "I am a fake index.html file" - fileMod := time.Unix(1000000000, 0).UTC() - fileModStr := fileMod.Format(TimeFormat) - dirMod := time.Unix(123, 0).UTC() - indexFile := &fakeFileInfo{ - basename: "index.html", - modtime: fileMod, - contents: indexContents, - } - fs := fakeFS{ - "/": &fakeFileInfo{ - dir: true, - modtime: dirMod, - ents: []*fakeFileInfo{indexFile}, - }, - "/index.html": indexFile, - } - - ts := httptest.NewServer(FileServer(fs)) - defer ts.Close() - - res, err := Get(ts.URL) - if err != nil { - t.Fatal(err) - } - b, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatal(err) - } - if string(b) != indexContents { - t.Fatalf("Got body %q; want %q", b, indexContents) - } - res.Body.Close() - - lastMod := res.Header.Get("Last-Modified") - if lastMod != fileModStr { - t.Fatalf("initial Last-Modified = %q; want %q", lastMod, fileModStr) - } - - req, _ := NewRequest("GET", ts.URL, nil) - req.Header.Set("If-Modified-Since", lastMod) - - res, err = DefaultClient.Do(req) - if err != nil { - t.Fatal(err) - } - if res.StatusCode != 304 { - t.Fatalf("Code after If-Modified-Since request = %v; want 304", res.StatusCode) - } - res.Body.Close() - - // Advance the index.html file's modtime, but not the directory's. - indexFile.modtime = indexFile.modtime.Add(1 * time.Hour) - - res, err = DefaultClient.Do(req) - if err != nil { - t.Fatal(err) - } - if res.StatusCode != 200 { - t.Fatalf("Code after second If-Modified-Since request = %v; want 200; res is %#v", res.StatusCode, res) - } - res.Body.Close() -} - -func mustStat(t *testing.T, fileName string) os.FileInfo { - fi, err := os.Stat(fileName) - if err != nil { - t.Fatal(err) - } - return fi -} - -func TestServeContent(t *testing.T) { - defer afterTest(t) - type serveParam struct { - name string - modtime time.Time - content io.ReadSeeker - contentType string - etag string - } - servec := make(chan serveParam, 1) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - p := <-servec - if p.etag != "" { - w.Header().Set("ETag", p.etag) - } - if p.contentType != "" { - w.Header().Set("Content-Type", p.contentType) - } - ServeContent(w, r, p.name, p.modtime, p.content) - })) - defer ts.Close() - - type testCase struct { - // One of file or content must be set: - file string - content io.ReadSeeker - - modtime time.Time - serveETag string // optional - serveContentType string // optional - reqHeader map[string]string - wantLastMod string - wantContentType string - wantStatus int - } - htmlModTime := mustStat(t, "testdata/index.html").ModTime() - tests := map[string]testCase{ - "no_last_modified": { - file: "testdata/style.css", - wantContentType: "text/css; charset=utf-8", - wantStatus: 200, - }, - "with_last_modified": { - file: "testdata/index.html", - wantContentType: "text/html; charset=utf-8", - modtime: htmlModTime, - wantLastMod: htmlModTime.UTC().Format(TimeFormat), - wantStatus: 200, - }, - "not_modified_modtime": { - file: "testdata/style.css", - modtime: htmlModTime, - reqHeader: map[string]string{ - "If-Modified-Since": htmlModTime.UTC().Format(TimeFormat), - }, - wantStatus: 304, - }, - "not_modified_modtime_with_contenttype": { - file: "testdata/style.css", - serveContentType: "text/css", // explicit content type - modtime: htmlModTime, - reqHeader: map[string]string{ - "If-Modified-Since": htmlModTime.UTC().Format(TimeFormat), - }, - wantStatus: 304, - }, - "not_modified_etag": { - file: "testdata/style.css", - serveETag: `"foo"`, - reqHeader: map[string]string{ - "If-None-Match": `"foo"`, - }, - wantStatus: 304, - }, - "not_modified_etag_no_seek": { - content: panicOnSeek{nil}, // should never be called - serveETag: `"foo"`, - reqHeader: map[string]string{ - "If-None-Match": `"foo"`, - }, - wantStatus: 304, - }, - "range_good": { - file: "testdata/style.css", - serveETag: `"A"`, - reqHeader: map[string]string{ - "Range": "bytes=0-4", - }, - wantStatus: StatusPartialContent, - wantContentType: "text/css; charset=utf-8", - }, - // An If-Range resource for entity "A", but entity "B" is now current. - // The Range request should be ignored. - "range_no_match": { - file: "testdata/style.css", - serveETag: `"A"`, - reqHeader: map[string]string{ - "Range": "bytes=0-4", - "If-Range": `"B"`, - }, - wantStatus: 200, - wantContentType: "text/css; charset=utf-8", - }, - } - for testName, tt := range tests { - var content io.ReadSeeker - if tt.file != "" { - f, err := os.Open(tt.file) - if err != nil { - t.Fatalf("test %q: %v", testName, err) - } - defer f.Close() - content = f - } else { - content = tt.content - } - - servec <- serveParam{ - name: filepath.Base(tt.file), - content: content, - modtime: tt.modtime, - etag: tt.serveETag, - contentType: tt.serveContentType, - } - req, err := NewRequest("GET", ts.URL, nil) - if err != nil { - t.Fatal(err) - } - for k, v := range tt.reqHeader { - req.Header.Set(k, v) - } - res, err := DefaultClient.Do(req) - if err != nil { - t.Fatal(err) - } - io.Copy(ioutil.Discard, res.Body) - res.Body.Close() - if res.StatusCode != tt.wantStatus { - t.Errorf("test %q: status = %d; want %d", testName, res.StatusCode, tt.wantStatus) - } - if g, e := res.Header.Get("Content-Type"), tt.wantContentType; g != e { - t.Errorf("test %q: content-type = %q, want %q", testName, g, e) - } - if g, e := res.Header.Get("Last-Modified"), tt.wantLastMod; g != e { - t.Errorf("test %q: last-modified = %q, want %q", testName, g, e) - } - } -} - -// verifies that sendfile is being used on Linux -func TestLinuxSendfile(t *testing.T) { - defer afterTest(t) - if runtime.GOOS != "linux" { - t.Skip("skipping; linux-only test") - } - if _, err := exec.LookPath("strace"); err != nil { - t.Skip("skipping; strace not found in path") - } - - ln, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - t.Fatal(err) - } - lnf, err := ln.(*net.TCPListener).File() - if err != nil { - t.Fatal(err) - } - defer ln.Close() - - var buf bytes.Buffer - child := exec.Command("strace", "-f", "-q", "-e", "trace=sendfile,sendfile64", os.Args[0], "-test.run=TestLinuxSendfileChild") - child.ExtraFiles = append(child.ExtraFiles, lnf) - child.Env = append([]string{"GO_WANT_HELPER_PROCESS=1"}, os.Environ()...) - child.Stdout = &buf - child.Stderr = &buf - if err := child.Start(); err != nil { - t.Skipf("skipping; failed to start straced child: %v", err) - } - - res, err := Get(fmt.Sprintf("http://%s/", ln.Addr())) - if err != nil { - t.Fatalf("http client error: %v", err) - } - _, err = io.Copy(ioutil.Discard, res.Body) - if err != nil { - t.Fatalf("client body read error: %v", err) - } - res.Body.Close() - - // Force child to exit cleanly. - Get(fmt.Sprintf("http://%s/quit", ln.Addr())) - child.Wait() - - rx := regexp.MustCompile(`sendfile(64)?\(\d+,\s*\d+,\s*NULL,\s*\d+\)\s*=\s*\d+\s*\n`) - rxResume := regexp.MustCompile(`<\.\.\. sendfile(64)? resumed> \)\s*=\s*\d+\s*\n`) - out := buf.String() - if !rx.MatchString(out) && !rxResume.MatchString(out) { - t.Errorf("no sendfile system call found in:\n%s", out) - } -} - -func getBody(t *testing.T, testName string, req Request) (*Response, []byte) { - r, err := DefaultClient.Do(&req) - if err != nil { - t.Fatalf("%s: for URL %q, send error: %v", testName, req.URL.String(), err) - } - b, err := ioutil.ReadAll(r.Body) - if err != nil { - t.Fatalf("%s: for URL %q, reading body: %v", testName, req.URL.String(), err) - } - return r, b -} - -// TestLinuxSendfileChild isn't a real test. It's used as a helper process -// for TestLinuxSendfile. -func TestLinuxSendfileChild(*testing.T) { - if os.Getenv("GO_WANT_HELPER_PROCESS") != "1" { - return - } - defer os.Exit(0) - fd3 := os.NewFile(3, "ephemeral-port-listener") - ln, err := net.FileListener(fd3) - if err != nil { - panic(err) - } - mux := NewServeMux() - mux.Handle("/", FileServer(Dir("testdata"))) - mux.HandleFunc("/quit", func(ResponseWriter, *Request) { - os.Exit(0) - }) - s := &Server{Handler: mux} - err = s.Serve(ln) - if err != nil { - panic(err) - } -} - -type panicOnSeek struct{ io.ReadSeeker } diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/header_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/header_test.go deleted file mode 100644 index 9dcd591fa0..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/header_test.go +++ /dev/null @@ -1,212 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http - -import ( - "bytes" - "runtime" - "testing" - "time" -) - -var headerWriteTests = []struct { - h Header - exclude map[string]bool - expected string -}{ - {Header{}, nil, ""}, - { - Header{ - "Content-Type": {"text/html; charset=UTF-8"}, - "Content-Length": {"0"}, - }, - nil, - "Content-Length: 0\r\nContent-Type: text/html; charset=UTF-8\r\n", - }, - { - Header{ - "Content-Length": {"0", "1", "2"}, - }, - nil, - "Content-Length: 0\r\nContent-Length: 1\r\nContent-Length: 2\r\n", - }, - { - Header{ - "Expires": {"-1"}, - "Content-Length": {"0"}, - "Content-Encoding": {"gzip"}, - }, - map[string]bool{"Content-Length": true}, - "Content-Encoding: gzip\r\nExpires: -1\r\n", - }, - { - Header{ - "Expires": {"-1"}, - "Content-Length": {"0", "1", "2"}, - "Content-Encoding": {"gzip"}, - }, - map[string]bool{"Content-Length": true}, - "Content-Encoding: gzip\r\nExpires: -1\r\n", - }, - { - Header{ - "Expires": {"-1"}, - "Content-Length": {"0"}, - "Content-Encoding": {"gzip"}, - }, - map[string]bool{"Content-Length": true, "Expires": true, "Content-Encoding": true}, - "", - }, - { - Header{ - "Nil": nil, - "Empty": {}, - "Blank": {""}, - "Double-Blank": {"", ""}, - }, - nil, - "Blank: \r\nDouble-Blank: \r\nDouble-Blank: \r\n", - }, - // Tests header sorting when over the insertion sort threshold side: - { - Header{ - "k1": {"1a", "1b"}, - "k2": {"2a", "2b"}, - "k3": {"3a", "3b"}, - "k4": {"4a", "4b"}, - "k5": {"5a", "5b"}, - "k6": {"6a", "6b"}, - "k7": {"7a", "7b"}, - "k8": {"8a", "8b"}, - "k9": {"9a", "9b"}, - }, - map[string]bool{"k5": true}, - "k1: 1a\r\nk1: 1b\r\nk2: 2a\r\nk2: 2b\r\nk3: 3a\r\nk3: 3b\r\n" + - "k4: 4a\r\nk4: 4b\r\nk6: 6a\r\nk6: 6b\r\n" + - "k7: 7a\r\nk7: 7b\r\nk8: 8a\r\nk8: 8b\r\nk9: 9a\r\nk9: 9b\r\n", - }, -} - -func TestHeaderWrite(t *testing.T) { - var buf bytes.Buffer - for i, test := range headerWriteTests { - test.h.WriteSubset(&buf, test.exclude) - if buf.String() != test.expected { - t.Errorf("#%d:\n got: %q\nwant: %q", i, buf.String(), test.expected) - } - buf.Reset() - } -} - -var parseTimeTests = []struct { - h Header - err bool -}{ - {Header{"Date": {""}}, true}, - {Header{"Date": {"invalid"}}, true}, - {Header{"Date": {"1994-11-06T08:49:37Z00:00"}}, true}, - {Header{"Date": {"Sun, 06 Nov 1994 08:49:37 GMT"}}, false}, - {Header{"Date": {"Sunday, 06-Nov-94 08:49:37 GMT"}}, false}, - {Header{"Date": {"Sun Nov 6 08:49:37 1994"}}, false}, -} - -func TestParseTime(t *testing.T) { - expect := time.Date(1994, 11, 6, 8, 49, 37, 0, time.UTC) - for i, test := range parseTimeTests { - d, err := ParseTime(test.h.Get("Date")) - if err != nil { - if !test.err { - t.Errorf("#%d:\n got err: %v", i, err) - } - continue - } - if test.err { - t.Errorf("#%d:\n should err", i) - continue - } - if !expect.Equal(d) { - t.Errorf("#%d:\n got: %v\nwant: %v", i, d, expect) - } - } -} - -type hasTokenTest struct { - header string - token string - want bool -} - -var hasTokenTests = []hasTokenTest{ - {"", "", false}, - {"", "foo", false}, - {"foo", "foo", true}, - {"foo ", "foo", true}, - {" foo", "foo", true}, - {" foo ", "foo", true}, - {"foo,bar", "foo", true}, - {"bar,foo", "foo", true}, - {"bar, foo", "foo", true}, - {"bar,foo, baz", "foo", true}, - {"bar, foo,baz", "foo", true}, - {"bar,foo, baz", "foo", true}, - {"bar, foo, baz", "foo", true}, - {"FOO", "foo", true}, - {"FOO ", "foo", true}, - {" FOO", "foo", true}, - {" FOO ", "foo", true}, - {"FOO,BAR", "foo", true}, - {"BAR,FOO", "foo", true}, - {"BAR, FOO", "foo", true}, - {"BAR,FOO, baz", "foo", true}, - {"BAR, FOO,BAZ", "foo", true}, - {"BAR,FOO, BAZ", "foo", true}, - {"BAR, FOO, BAZ", "foo", true}, - {"foobar", "foo", false}, - {"barfoo ", "foo", false}, -} - -func TestHasToken(t *testing.T) { - for _, tt := range hasTokenTests { - if hasToken(tt.header, tt.token) != tt.want { - t.Errorf("hasToken(%q, %q) = %v; want %v", tt.header, tt.token, !tt.want, tt.want) - } - } -} - -var testHeader = Header{ - "Content-Length": {"123"}, - "Content-Type": {"text/plain"}, - "Date": {"some date at some time Z"}, - "Server": {DefaultUserAgent}, -} - -var buf bytes.Buffer - -func BenchmarkHeaderWriteSubset(b *testing.B) { - b.ReportAllocs() - for i := 0; i < b.N; i++ { - buf.Reset() - testHeader.WriteSubset(&buf, nil) - } -} - -func TestHeaderWriteSubsetAllocs(t *testing.T) { - if testing.Short() { - t.Skip("skipping alloc test in short mode") - } - if raceEnabled { - t.Skip("skipping test under race detector") - } - if runtime.GOMAXPROCS(0) > 1 { - t.Skip("skipping; GOMAXPROCS>1") - } - n := testing.AllocsPerRun(100, func() { - buf.Reset() - testHeader.WriteSubset(&buf, nil) - }) - if n > 0 { - t.Errorf("allocs = %g; want 0", n) - } -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httptest/example_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httptest/example_test.go deleted file mode 100644 index 42a0ec953b..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httptest/example_test.go +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package httptest_test - -import ( - "fmt" - "io/ioutil" - "log" - "net/http" - "net/http/httptest" -) - -func ExampleResponseRecorder() { - handler := func(w http.ResponseWriter, r *http.Request) { - http.Error(w, "something failed", http.StatusInternalServerError) - } - - req, err := http.NewRequest("GET", "http://example.com/foo", nil) - if err != nil { - log.Fatal(err) - } - - w := httptest.NewRecorder() - handler(w, req) - - fmt.Printf("%d - %s", w.Code, w.Body.String()) - // Output: 500 - something failed -} - -func ExampleServer() { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - fmt.Fprintln(w, "Hello, client") - })) - defer ts.Close() - - res, err := http.Get(ts.URL) - if err != nil { - log.Fatal(err) - } - greeting, err := ioutil.ReadAll(res.Body) - res.Body.Close() - if err != nil { - log.Fatal(err) - } - - fmt.Printf("%s", greeting) - // Output: Hello, client -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httptest/recorder.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httptest/recorder.go deleted file mode 100644 index 5451f54234..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httptest/recorder.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package httptest provides utilities for HTTP testing. -package httptest - -import ( - "bytes" - "net/http" -) - -// ResponseRecorder is an implementation of http.ResponseWriter that -// records its mutations for later inspection in tests. -type ResponseRecorder struct { - Code int // the HTTP response code from WriteHeader - HeaderMap http.Header // the HTTP response headers - Body *bytes.Buffer // if non-nil, the bytes.Buffer to append written data to - Flushed bool - - wroteHeader bool -} - -// NewRecorder returns an initialized ResponseRecorder. -func NewRecorder() *ResponseRecorder { - return &ResponseRecorder{ - HeaderMap: make(http.Header), - Body: new(bytes.Buffer), - Code: 200, - } -} - -// DefaultRemoteAddr is the default remote address to return in RemoteAddr if -// an explicit DefaultRemoteAddr isn't set on ResponseRecorder. -const DefaultRemoteAddr = "1.2.3.4" - -// Header returns the response headers. -func (rw *ResponseRecorder) Header() http.Header { - m := rw.HeaderMap - if m == nil { - m = make(http.Header) - rw.HeaderMap = m - } - return m -} - -// Write always succeeds and writes to rw.Body, if not nil. -func (rw *ResponseRecorder) Write(buf []byte) (int, error) { - if !rw.wroteHeader { - rw.WriteHeader(200) - } - if rw.Body != nil { - rw.Body.Write(buf) - } - return len(buf), nil -} - -// WriteHeader sets rw.Code. -func (rw *ResponseRecorder) WriteHeader(code int) { - if !rw.wroteHeader { - rw.Code = code - } - rw.wroteHeader = true -} - -// Flush sets rw.Flushed to true. -func (rw *ResponseRecorder) Flush() { - if !rw.wroteHeader { - rw.WriteHeader(200) - } - rw.Flushed = true -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httptest/recorder_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httptest/recorder_test.go deleted file mode 100644 index 2b563260c7..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httptest/recorder_test.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package httptest - -import ( - "fmt" - "net/http" - "testing" -) - -func TestRecorder(t *testing.T) { - type checkFunc func(*ResponseRecorder) error - check := func(fns ...checkFunc) []checkFunc { return fns } - - hasStatus := func(wantCode int) checkFunc { - return func(rec *ResponseRecorder) error { - if rec.Code != wantCode { - return fmt.Errorf("Status = %d; want %d", rec.Code, wantCode) - } - return nil - } - } - hasContents := func(want string) checkFunc { - return func(rec *ResponseRecorder) error { - if rec.Body.String() != want { - return fmt.Errorf("wrote = %q; want %q", rec.Body.String(), want) - } - return nil - } - } - hasFlush := func(want bool) checkFunc { - return func(rec *ResponseRecorder) error { - if rec.Flushed != want { - return fmt.Errorf("Flushed = %v; want %v", rec.Flushed, want) - } - return nil - } - } - - tests := []struct { - name string - h func(w http.ResponseWriter, r *http.Request) - checks []checkFunc - }{ - { - "200 default", - func(w http.ResponseWriter, r *http.Request) {}, - check(hasStatus(200), hasContents("")), - }, - { - "first code only", - func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(201) - w.WriteHeader(202) - w.Write([]byte("hi")) - }, - check(hasStatus(201), hasContents("hi")), - }, - { - "write sends 200", - func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte("hi first")) - w.WriteHeader(201) - w.WriteHeader(202) - }, - check(hasStatus(200), hasContents("hi first"), hasFlush(false)), - }, - { - "flush", - func(w http.ResponseWriter, r *http.Request) { - w.(http.Flusher).Flush() // also sends a 200 - w.WriteHeader(201) - }, - check(hasStatus(200), hasFlush(true)), - }, - } - r, _ := http.NewRequest("GET", "http://foo.com/", nil) - for _, tt := range tests { - h := http.HandlerFunc(tt.h) - rec := NewRecorder() - h.ServeHTTP(rec, r) - for _, check := range tt.checks { - if err := check(rec); err != nil { - t.Errorf("%s: %v", tt.name, err) - } - } - } -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httptest/server.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httptest/server.go deleted file mode 100644 index 7f265552f5..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httptest/server.go +++ /dev/null @@ -1,228 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Implementation of Server - -package httptest - -import ( - "crypto/tls" - "flag" - "fmt" - "net" - "net/http" - "os" - "sync" -) - -// A Server is an HTTP server listening on a system-chosen port on the -// local loopback interface, for use in end-to-end HTTP tests. -type Server struct { - URL string // base URL of form http://ipaddr:port with no trailing slash - Listener net.Listener - - // TLS is the optional TLS configuration, populated with a new config - // after TLS is started. If set on an unstarted server before StartTLS - // is called, existing fields are copied into the new config. - TLS *tls.Config - - // Config may be changed after calling NewUnstartedServer and - // before Start or StartTLS. - Config *http.Server - - // wg counts the number of outstanding HTTP requests on this server. - // Close blocks until all requests are finished. - wg sync.WaitGroup -} - -// historyListener keeps track of all connections that it's ever -// accepted. -type historyListener struct { - net.Listener - sync.Mutex // protects history - history []net.Conn -} - -func (hs *historyListener) Accept() (c net.Conn, err error) { - c, err = hs.Listener.Accept() - if err == nil { - hs.Lock() - hs.history = append(hs.history, c) - hs.Unlock() - } - return -} - -func newLocalListener() net.Listener { - if *serve != "" { - l, err := net.Listen("tcp", *serve) - if err != nil { - panic(fmt.Sprintf("httptest: failed to listen on %v: %v", *serve, err)) - } - return l - } - l, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - if l, err = net.Listen("tcp6", "[::1]:0"); err != nil { - panic(fmt.Sprintf("httptest: failed to listen on a port: %v", err)) - } - } - return l -} - -// When debugging a particular http server-based test, -// this flag lets you run -// go test -run=BrokenTest -httptest.serve=127.0.0.1:8000 -// to start the broken server so you can interact with it manually. -var serve = flag.String("httptest.serve", "", "if non-empty, httptest.NewServer serves on this address and blocks") - -// NewServer starts and returns a new Server. -// The caller should call Close when finished, to shut it down. -func NewServer(handler http.Handler) *Server { - ts := NewUnstartedServer(handler) - ts.Start() - return ts -} - -// NewUnstartedServer returns a new Server but doesn't start it. -// -// After changing its configuration, the caller should call Start or -// StartTLS. -// -// The caller should call Close when finished, to shut it down. -func NewUnstartedServer(handler http.Handler) *Server { - return &Server{ - Listener: newLocalListener(), - Config: &http.Server{Handler: handler}, - } -} - -// Start starts a server from NewUnstartedServer. -func (s *Server) Start() { - if s.URL != "" { - panic("Server already started") - } - s.Listener = &historyListener{Listener: s.Listener} - s.URL = "http://" + s.Listener.Addr().String() - s.wrapHandler() - go s.Config.Serve(s.Listener) - if *serve != "" { - fmt.Fprintln(os.Stderr, "httptest: serving on", s.URL) - select {} - } -} - -// StartTLS starts TLS on a server from NewUnstartedServer. -func (s *Server) StartTLS() { - if s.URL != "" { - panic("Server already started") - } - cert, err := tls.X509KeyPair(localhostCert, localhostKey) - if err != nil { - panic(fmt.Sprintf("httptest: NewTLSServer: %v", err)) - } - - existingConfig := s.TLS - s.TLS = new(tls.Config) - if existingConfig != nil { - *s.TLS = *existingConfig - } - if s.TLS.NextProtos == nil { - s.TLS.NextProtos = []string{"http/1.1"} - } - if len(s.TLS.Certificates) == 0 { - s.TLS.Certificates = []tls.Certificate{cert} - } - tlsListener := tls.NewListener(s.Listener, s.TLS) - - s.Listener = &historyListener{Listener: tlsListener} - s.URL = "https://" + s.Listener.Addr().String() - s.wrapHandler() - go s.Config.Serve(s.Listener) -} - -func (s *Server) wrapHandler() { - h := s.Config.Handler - if h == nil { - h = http.DefaultServeMux - } - s.Config.Handler = &waitGroupHandler{ - s: s, - h: h, - } -} - -// NewTLSServer starts and returns a new Server using TLS. -// The caller should call Close when finished, to shut it down. -func NewTLSServer(handler http.Handler) *Server { - ts := NewUnstartedServer(handler) - ts.StartTLS() - return ts -} - -// Close shuts down the server and blocks until all outstanding -// requests on this server have completed. -func (s *Server) Close() { - s.Listener.Close() - s.wg.Wait() - s.CloseClientConnections() - if t, ok := http.DefaultTransport.(*http.Transport); ok { - t.CloseIdleConnections() - } -} - -// CloseClientConnections closes any currently open HTTP connections -// to the test Server. -func (s *Server) CloseClientConnections() { - hl, ok := s.Listener.(*historyListener) - if !ok { - return - } - hl.Lock() - for _, conn := range hl.history { - conn.Close() - } - hl.Unlock() -} - -// waitGroupHandler wraps a handler, incrementing and decrementing a -// sync.WaitGroup on each request, to enable Server.Close to block -// until outstanding requests are finished. -type waitGroupHandler struct { - s *Server - h http.Handler // non-nil -} - -func (h *waitGroupHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - h.s.wg.Add(1) - defer h.s.wg.Done() // a defer, in case ServeHTTP below panics - h.h.ServeHTTP(w, r) -} - -// localhostCert is a PEM-encoded TLS cert with SAN IPs -// "127.0.0.1" and "[::1]", expiring at the last second of 2049 (the end -// of ASN.1 time). -// generated from src/pkg/crypto/tls: -// go run generate_cert.go --rsa-bits 512 --host 127.0.0.1,::1,example.com --ca --start-date "Jan 1 00:00:00 1970" --duration=1000000h -var localhostCert = []byte(`-----BEGIN CERTIFICATE----- -MIIBdzCCASOgAwIBAgIBADALBgkqhkiG9w0BAQUwEjEQMA4GA1UEChMHQWNtZSBD -bzAeFw03MDAxMDEwMDAwMDBaFw00OTEyMzEyMzU5NTlaMBIxEDAOBgNVBAoTB0Fj -bWUgQ28wWjALBgkqhkiG9w0BAQEDSwAwSAJBAN55NcYKZeInyTuhcCwFMhDHCmwa -IUSdtXdcbItRB/yfXGBhiex00IaLXQnSU+QZPRZWYqeTEbFSgihqi1PUDy8CAwEA -AaNoMGYwDgYDVR0PAQH/BAQDAgCkMBMGA1UdJQQMMAoGCCsGAQUFBwMBMA8GA1Ud -EwEB/wQFMAMBAf8wLgYDVR0RBCcwJYILZXhhbXBsZS5jb22HBH8AAAGHEAAAAAAA -AAAAAAAAAAAAAAEwCwYJKoZIhvcNAQEFA0EAAoQn/ytgqpiLcZu9XKbCJsJcvkgk -Se6AbGXgSlq+ZCEVo0qIwSgeBqmsJxUu7NCSOwVJLYNEBO2DtIxoYVk+MA== ------END CERTIFICATE-----`) - -// localhostKey is the private key for localhostCert. -var localhostKey = []byte(`-----BEGIN RSA PRIVATE KEY----- -MIIBPAIBAAJBAN55NcYKZeInyTuhcCwFMhDHCmwaIUSdtXdcbItRB/yfXGBhiex0 -0IaLXQnSU+QZPRZWYqeTEbFSgihqi1PUDy8CAwEAAQJBAQdUx66rfh8sYsgfdcvV -NoafYpnEcB5s4m/vSVe6SU7dCK6eYec9f9wpT353ljhDUHq3EbmE4foNzJngh35d -AekCIQDhRQG5Li0Wj8TM4obOnnXUXf1jRv0UkzE9AHWLG5q3AwIhAPzSjpYUDjVW -MCUXgckTpKCuGwbJk7424Nb8bLzf3kllAiA5mUBgjfr/WtFSJdWcPQ4Zt9KTMNKD -EUO0ukpTwEIl6wIhAMbGqZK3zAAFdq8DD2jPx+UJXnh0rnOkZBzDtJ6/iN69AiEA -1Aq8MJgTaYsDQWyU/hDq5YkDJc9e9DSCvUIzqxQWMQE= ------END RSA PRIVATE KEY-----`) diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httptest/server_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httptest/server_test.go deleted file mode 100644 index 501cc8a999..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httptest/server_test.go +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package httptest - -import ( - "io/ioutil" - "net/http" - "testing" - "time" -) - -func TestServer(t *testing.T) { - ts := NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte("hello")) - })) - defer ts.Close() - res, err := http.Get(ts.URL) - if err != nil { - t.Fatal(err) - } - got, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatal(err) - } - if string(got) != "hello" { - t.Errorf("got %q, want hello", string(got)) - } -} - -func TestIssue7264(t *testing.T) { - for i := 0; i < 1000; i++ { - func() { - inHandler := make(chan bool, 1) - ts := NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - inHandler <- true - })) - defer ts.Close() - tr := &http.Transport{ - ResponseHeaderTimeout: time.Nanosecond, - } - defer tr.CloseIdleConnections() - c := &http.Client{Transport: tr} - res, err := c.Get(ts.URL) - <-inHandler - if err == nil { - res.Body.Close() - } - }() - } -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/chunked.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/chunked.go deleted file mode 100644 index 9632bfd19d..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/chunked.go +++ /dev/null @@ -1,203 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// The wire protocol for HTTP's "chunked" Transfer-Encoding. - -// This code is duplicated in net/http and net/http/httputil. -// Please make any changes in both files. - -package httputil - -import ( - "bufio" - "bytes" - "errors" - "fmt" - "io" -) - -const maxLineLength = 4096 // assumed <= bufio.defaultBufSize - -var ErrLineTooLong = errors.New("header line too long") - -// newChunkedReader returns a new chunkedReader that translates the data read from r -// out of HTTP "chunked" format before returning it. -// The chunkedReader returns io.EOF when the final 0-length chunk is read. -// -// newChunkedReader is not needed by normal applications. The http package -// automatically decodes chunking when reading response bodies. -func newChunkedReader(r io.Reader) io.Reader { - br, ok := r.(*bufio.Reader) - if !ok { - br = bufio.NewReader(r) - } - return &chunkedReader{r: br} -} - -type chunkedReader struct { - r *bufio.Reader - n uint64 // unread bytes in chunk - err error - buf [2]byte -} - -func (cr *chunkedReader) beginChunk() { - // chunk-size CRLF - var line []byte - line, cr.err = readLine(cr.r) - if cr.err != nil { - return - } - cr.n, cr.err = parseHexUint(line) - if cr.err != nil { - return - } - if cr.n == 0 { - cr.err = io.EOF - } -} - -func (cr *chunkedReader) chunkHeaderAvailable() bool { - n := cr.r.Buffered() - if n > 0 { - peek, _ := cr.r.Peek(n) - return bytes.IndexByte(peek, '\n') >= 0 - } - return false -} - -func (cr *chunkedReader) Read(b []uint8) (n int, err error) { - for cr.err == nil { - if cr.n == 0 { - if n > 0 && !cr.chunkHeaderAvailable() { - // We've read enough. Don't potentially block - // reading a new chunk header. - break - } - cr.beginChunk() - continue - } - if len(b) == 0 { - break - } - rbuf := b - if uint64(len(rbuf)) > cr.n { - rbuf = rbuf[:cr.n] - } - var n0 int - n0, cr.err = cr.r.Read(rbuf) - n += n0 - b = b[n0:] - cr.n -= uint64(n0) - // If we're at the end of a chunk, read the next two - // bytes to verify they are "\r\n". - if cr.n == 0 && cr.err == nil { - if _, cr.err = io.ReadFull(cr.r, cr.buf[:2]); cr.err == nil { - if cr.buf[0] != '\r' || cr.buf[1] != '\n' { - cr.err = errors.New("malformed chunked encoding") - } - } - } - } - return n, cr.err -} - -// Read a line of bytes (up to \n) from b. -// Give up if the line exceeds maxLineLength. -// The returned bytes are a pointer into storage in -// the bufio, so they are only valid until the next bufio read. -func readLine(b *bufio.Reader) (p []byte, err error) { - if p, err = b.ReadSlice('\n'); err != nil { - // We always know when EOF is coming. - // If the caller asked for a line, there should be a line. - if err == io.EOF { - err = io.ErrUnexpectedEOF - } else if err == bufio.ErrBufferFull { - err = ErrLineTooLong - } - return nil, err - } - if len(p) >= maxLineLength { - return nil, ErrLineTooLong - } - return trimTrailingWhitespace(p), nil -} - -func trimTrailingWhitespace(b []byte) []byte { - for len(b) > 0 && isASCIISpace(b[len(b)-1]) { - b = b[:len(b)-1] - } - return b -} - -func isASCIISpace(b byte) bool { - return b == ' ' || b == '\t' || b == '\n' || b == '\r' -} - -// newChunkedWriter returns a new chunkedWriter that translates writes into HTTP -// "chunked" format before writing them to w. Closing the returned chunkedWriter -// sends the final 0-length chunk that marks the end of the stream. -// -// newChunkedWriter is not needed by normal applications. The http -// package adds chunking automatically if handlers don't set a -// Content-Length header. Using newChunkedWriter inside a handler -// would result in double chunking or chunking with a Content-Length -// length, both of which are wrong. -func newChunkedWriter(w io.Writer) io.WriteCloser { - return &chunkedWriter{w} -} - -// Writing to chunkedWriter translates to writing in HTTP chunked Transfer -// Encoding wire format to the underlying Wire chunkedWriter. -type chunkedWriter struct { - Wire io.Writer -} - -// Write the contents of data as one chunk to Wire. -// NOTE: Note that the corresponding chunk-writing procedure in Conn.Write has -// a bug since it does not check for success of io.WriteString -func (cw *chunkedWriter) Write(data []byte) (n int, err error) { - - // Don't send 0-length data. It looks like EOF for chunked encoding. - if len(data) == 0 { - return 0, nil - } - - if _, err = fmt.Fprintf(cw.Wire, "%x\r\n", len(data)); err != nil { - return 0, err - } - if n, err = cw.Wire.Write(data); err != nil { - return - } - if n != len(data) { - err = io.ErrShortWrite - return - } - _, err = io.WriteString(cw.Wire, "\r\n") - - return -} - -func (cw *chunkedWriter) Close() error { - _, err := io.WriteString(cw.Wire, "0\r\n") - return err -} - -func parseHexUint(v []byte) (n uint64, err error) { - for _, b := range v { - n <<= 4 - switch { - case '0' <= b && b <= '9': - b = b - '0' - case 'a' <= b && b <= 'f': - b = b - 'a' + 10 - case 'A' <= b && b <= 'F': - b = b - 'A' + 10 - default: - return 0, errors.New("invalid byte in chunk length") - } - n |= uint64(b) - } - return -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/chunked_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/chunked_test.go deleted file mode 100644 index a7a5774688..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/chunked_test.go +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This code is duplicated in net/http and net/http/httputil. -// Please make any changes in both files. - -package httputil - -import ( - "bufio" - "bytes" - "fmt" - "io" - "io/ioutil" - "strings" - "testing" -) - -func TestChunk(t *testing.T) { - var b bytes.Buffer - - w := newChunkedWriter(&b) - const chunk1 = "hello, " - const chunk2 = "world! 0123456789abcdef" - w.Write([]byte(chunk1)) - w.Write([]byte(chunk2)) - w.Close() - - if g, e := b.String(), "7\r\nhello, \r\n17\r\nworld! 0123456789abcdef\r\n0\r\n"; g != e { - t.Fatalf("chunk writer wrote %q; want %q", g, e) - } - - r := newChunkedReader(&b) - data, err := ioutil.ReadAll(r) - if err != nil { - t.Logf(`data: "%s"`, data) - t.Fatalf("ReadAll from reader: %v", err) - } - if g, e := string(data), chunk1+chunk2; g != e { - t.Errorf("chunk reader read %q; want %q", g, e) - } -} - -func TestChunkReadMultiple(t *testing.T) { - // Bunch of small chunks, all read together. - { - var b bytes.Buffer - w := newChunkedWriter(&b) - w.Write([]byte("foo")) - w.Write([]byte("bar")) - w.Close() - - r := newChunkedReader(&b) - buf := make([]byte, 10) - n, err := r.Read(buf) - if n != 6 || err != io.EOF { - t.Errorf("Read = %d, %v; want 6, EOF", n, err) - } - buf = buf[:n] - if string(buf) != "foobar" { - t.Errorf("Read = %q; want %q", buf, "foobar") - } - } - - // One big chunk followed by a little chunk, but the small bufio.Reader size - // should prevent the second chunk header from being read. - { - var b bytes.Buffer - w := newChunkedWriter(&b) - // fillBufChunk is 11 bytes + 3 bytes header + 2 bytes footer = 16 bytes, - // the same as the bufio ReaderSize below (the minimum), so even - // though we're going to try to Read with a buffer larger enough to also - // receive "foo", the second chunk header won't be read yet. - const fillBufChunk = "0123456789a" - const shortChunk = "foo" - w.Write([]byte(fillBufChunk)) - w.Write([]byte(shortChunk)) - w.Close() - - r := newChunkedReader(bufio.NewReaderSize(&b, 16)) - buf := make([]byte, len(fillBufChunk)+len(shortChunk)) - n, err := r.Read(buf) - if n != len(fillBufChunk) || err != nil { - t.Errorf("Read = %d, %v; want %d, nil", n, err, len(fillBufChunk)) - } - buf = buf[:n] - if string(buf) != fillBufChunk { - t.Errorf("Read = %q; want %q", buf, fillBufChunk) - } - - n, err = r.Read(buf) - if n != len(shortChunk) || err != io.EOF { - t.Errorf("Read = %d, %v; want %d, EOF", n, err, len(shortChunk)) - } - } - - // And test that we see an EOF chunk, even though our buffer is already full: - { - r := newChunkedReader(bufio.NewReader(strings.NewReader("3\r\nfoo\r\n0\r\n"))) - buf := make([]byte, 3) - n, err := r.Read(buf) - if n != 3 || err != io.EOF { - t.Errorf("Read = %d, %v; want 3, EOF", n, err) - } - if string(buf) != "foo" { - t.Errorf("buf = %q; want foo", buf) - } - } -} - -func TestChunkReaderAllocs(t *testing.T) { - if testing.Short() { - t.Skip("skipping in short mode") - } - var buf bytes.Buffer - w := newChunkedWriter(&buf) - a, b, c := []byte("aaaaaa"), []byte("bbbbbbbbbbbb"), []byte("cccccccccccccccccccccccc") - w.Write(a) - w.Write(b) - w.Write(c) - w.Close() - - readBuf := make([]byte, len(a)+len(b)+len(c)+1) - byter := bytes.NewReader(buf.Bytes()) - bufr := bufio.NewReader(byter) - mallocs := testing.AllocsPerRun(100, func() { - byter.Seek(0, 0) - bufr.Reset(byter) - r := newChunkedReader(bufr) - n, err := io.ReadFull(r, readBuf) - if n != len(readBuf)-1 { - t.Fatalf("read %d bytes; want %d", n, len(readBuf)-1) - } - if err != io.ErrUnexpectedEOF { - t.Fatalf("read error = %v; want ErrUnexpectedEOF", err) - } - }) - if mallocs > 1.5 { - t.Errorf("mallocs = %v; want 1", mallocs) - } -} - -func TestParseHexUint(t *testing.T) { - for i := uint64(0); i <= 1234; i++ { - line := []byte(fmt.Sprintf("%x", i)) - got, err := parseHexUint(line) - if err != nil { - t.Fatalf("on %d: %v", i, err) - } - if got != i { - t.Errorf("for input %q = %d; want %d", line, got, i) - } - } - _, err := parseHexUint([]byte("bogus")) - if err == nil { - t.Error("expected error on bogus input") - } -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/dump.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/dump.go deleted file mode 100644 index 2a7a413d01..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/dump.go +++ /dev/null @@ -1,276 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package httputil - -import ( - "bufio" - "bytes" - "errors" - "fmt" - "io" - "io/ioutil" - "net" - "net/http" - "net/url" - "strings" - "time" -) - -// One of the copies, say from b to r2, could be avoided by using a more -// elaborate trick where the other copy is made during Request/Response.Write. -// This would complicate things too much, given that these functions are for -// debugging only. -func drainBody(b io.ReadCloser) (r1, r2 io.ReadCloser, err error) { - var buf bytes.Buffer - if _, err = buf.ReadFrom(b); err != nil { - return nil, nil, err - } - if err = b.Close(); err != nil { - return nil, nil, err - } - return ioutil.NopCloser(&buf), ioutil.NopCloser(bytes.NewReader(buf.Bytes())), nil -} - -// dumpConn is a net.Conn which writes to Writer and reads from Reader -type dumpConn struct { - io.Writer - io.Reader -} - -func (c *dumpConn) Close() error { return nil } -func (c *dumpConn) LocalAddr() net.Addr { return nil } -func (c *dumpConn) RemoteAddr() net.Addr { return nil } -func (c *dumpConn) SetDeadline(t time.Time) error { return nil } -func (c *dumpConn) SetReadDeadline(t time.Time) error { return nil } -func (c *dumpConn) SetWriteDeadline(t time.Time) error { return nil } - -type neverEnding byte - -func (b neverEnding) Read(p []byte) (n int, err error) { - for i := range p { - p[i] = byte(b) - } - return len(p), nil -} - -// DumpRequestOut is like DumpRequest but includes -// headers that the standard http.Transport adds, -// such as User-Agent. -func DumpRequestOut(req *http.Request, body bool) ([]byte, error) { - save := req.Body - dummyBody := false - if !body || req.Body == nil { - req.Body = nil - if req.ContentLength != 0 { - req.Body = ioutil.NopCloser(io.LimitReader(neverEnding('x'), req.ContentLength)) - dummyBody = true - } - } else { - var err error - save, req.Body, err = drainBody(req.Body) - if err != nil { - return nil, err - } - } - - // Since we're using the actual Transport code to write the request, - // switch to http so the Transport doesn't try to do an SSL - // negotiation with our dumpConn and its bytes.Buffer & pipe. - // The wire format for https and http are the same, anyway. - reqSend := req - if req.URL.Scheme == "https" { - reqSend = new(http.Request) - *reqSend = *req - reqSend.URL = new(url.URL) - *reqSend.URL = *req.URL - reqSend.URL.Scheme = "http" - } - - // Use the actual Transport code to record what we would send - // on the wire, but not using TCP. Use a Transport with a - // custom dialer that returns a fake net.Conn that waits - // for the full input (and recording it), and then responds - // with a dummy response. - var buf bytes.Buffer // records the output - pr, pw := io.Pipe() - dr := &delegateReader{c: make(chan io.Reader)} - // Wait for the request before replying with a dummy response: - go func() { - http.ReadRequest(bufio.NewReader(pr)) - dr.c <- strings.NewReader("HTTP/1.1 204 No Content\r\n\r\n") - }() - - t := &http.Transport{ - Dial: func(net, addr string) (net.Conn, error) { - return &dumpConn{io.MultiWriter(&buf, pw), dr}, nil - }, - } - defer t.CloseIdleConnections() - - _, err := t.RoundTrip(reqSend) - - req.Body = save - if err != nil { - return nil, err - } - dump := buf.Bytes() - - // If we used a dummy body above, remove it now. - // TODO: if the req.ContentLength is large, we allocate memory - // unnecessarily just to slice it off here. But this is just - // a debug function, so this is acceptable for now. We could - // discard the body earlier if this matters. - if dummyBody { - if i := bytes.Index(dump, []byte("\r\n\r\n")); i >= 0 { - dump = dump[:i+4] - } - } - return dump, nil -} - -// delegateReader is a reader that delegates to another reader, -// once it arrives on a channel. -type delegateReader struct { - c chan io.Reader - r io.Reader // nil until received from c -} - -func (r *delegateReader) Read(p []byte) (int, error) { - if r.r == nil { - r.r = <-r.c - } - return r.r.Read(p) -} - -// Return value if nonempty, def otherwise. -func valueOrDefault(value, def string) string { - if value != "" { - return value - } - return def -} - -var reqWriteExcludeHeaderDump = map[string]bool{ - "Host": true, // not in Header map anyway - "Content-Length": true, - "Transfer-Encoding": true, - "Trailer": true, -} - -// dumpAsReceived writes req to w in the form as it was received, or -// at least as accurately as possible from the information retained in -// the request. -func dumpAsReceived(req *http.Request, w io.Writer) error { - return nil -} - -// DumpRequest returns the as-received wire representation of req, -// optionally including the request body, for debugging. -// DumpRequest is semantically a no-op, but in order to -// dump the body, it reads the body data into memory and -// changes req.Body to refer to the in-memory copy. -// The documentation for http.Request.Write details which fields -// of req are used. -func DumpRequest(req *http.Request, body bool) (dump []byte, err error) { - save := req.Body - if !body || req.Body == nil { - req.Body = nil - } else { - save, req.Body, err = drainBody(req.Body) - if err != nil { - return - } - } - - var b bytes.Buffer - - fmt.Fprintf(&b, "%s %s HTTP/%d.%d\r\n", valueOrDefault(req.Method, "GET"), - req.URL.RequestURI(), req.ProtoMajor, req.ProtoMinor) - - host := req.Host - if host == "" && req.URL != nil { - host = req.URL.Host - } - if host != "" { - fmt.Fprintf(&b, "Host: %s\r\n", host) - } - - chunked := len(req.TransferEncoding) > 0 && req.TransferEncoding[0] == "chunked" - if len(req.TransferEncoding) > 0 { - fmt.Fprintf(&b, "Transfer-Encoding: %s\r\n", strings.Join(req.TransferEncoding, ",")) - } - if req.Close { - fmt.Fprintf(&b, "Connection: close\r\n") - } - - err = req.Header.WriteSubset(&b, reqWriteExcludeHeaderDump) - if err != nil { - return - } - - io.WriteString(&b, "\r\n") - - if req.Body != nil { - var dest io.Writer = &b - if chunked { - dest = NewChunkedWriter(dest) - } - _, err = io.Copy(dest, req.Body) - if chunked { - dest.(io.Closer).Close() - io.WriteString(&b, "\r\n") - } - } - - req.Body = save - if err != nil { - return - } - dump = b.Bytes() - return -} - -// errNoBody is a sentinel error value used by failureToReadBody so we can detect -// that the lack of body was intentional. -var errNoBody = errors.New("sentinel error value") - -// failureToReadBody is a io.ReadCloser that just returns errNoBody on -// Read. It's swapped in when we don't actually want to consume the -// body, but need a non-nil one, and want to distinguish the error -// from reading the dummy body. -type failureToReadBody struct{} - -func (failureToReadBody) Read([]byte) (int, error) { return 0, errNoBody } -func (failureToReadBody) Close() error { return nil } - -var emptyBody = ioutil.NopCloser(strings.NewReader("")) - -// DumpResponse is like DumpRequest but dumps a response. -func DumpResponse(resp *http.Response, body bool) (dump []byte, err error) { - var b bytes.Buffer - save := resp.Body - savecl := resp.ContentLength - - if !body { - resp.Body = failureToReadBody{} - } else if resp.Body == nil { - resp.Body = emptyBody - } else { - save, resp.Body, err = drainBody(resp.Body) - if err != nil { - return - } - } - err = resp.Write(&b) - if err == errNoBody { - err = nil - } - resp.Body = save - resp.ContentLength = savecl - if err != nil { - return nil, err - } - return b.Bytes(), nil -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/dump_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/dump_test.go deleted file mode 100644 index e1ffb3935a..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/dump_test.go +++ /dev/null @@ -1,263 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package httputil - -import ( - "bytes" - "fmt" - "io" - "io/ioutil" - "net/http" - "net/url" - "runtime" - "strings" - "testing" -) - -type dumpTest struct { - Req http.Request - Body interface{} // optional []byte or func() io.ReadCloser to populate Req.Body - - WantDump string - WantDumpOut string - NoBody bool // if true, set DumpRequest{,Out} body to false -} - -var dumpTests = []dumpTest{ - - // HTTP/1.1 => chunked coding; body; empty trailer - { - Req: http.Request{ - Method: "GET", - URL: &url.URL{ - Scheme: "http", - Host: "www.google.com", - Path: "/search", - }, - ProtoMajor: 1, - ProtoMinor: 1, - TransferEncoding: []string{"chunked"}, - }, - - Body: []byte("abcdef"), - - WantDump: "GET /search HTTP/1.1\r\n" + - "Host: www.google.com\r\n" + - "Transfer-Encoding: chunked\r\n\r\n" + - chunk("abcdef") + chunk(""), - }, - - // Verify that DumpRequest preserves the HTTP version number, doesn't add a Host, - // and doesn't add a User-Agent. - { - Req: http.Request{ - Method: "GET", - URL: mustParseURL("/foo"), - ProtoMajor: 1, - ProtoMinor: 0, - Header: http.Header{ - "X-Foo": []string{"X-Bar"}, - }, - }, - - WantDump: "GET /foo HTTP/1.0\r\n" + - "X-Foo: X-Bar\r\n\r\n", - }, - - { - Req: *mustNewRequest("GET", "http://example.com/foo", nil), - - WantDumpOut: "GET /foo HTTP/1.1\r\n" + - "Host: example.com\r\n" + - "User-Agent: Go 1.1 package http\r\n" + - "Accept-Encoding: gzip\r\n\r\n", - }, - - // Test that an https URL doesn't try to do an SSL negotiation - // with a bytes.Buffer and hang with all goroutines not - // runnable. - { - Req: *mustNewRequest("GET", "https://example.com/foo", nil), - - WantDumpOut: "GET /foo HTTP/1.1\r\n" + - "Host: example.com\r\n" + - "User-Agent: Go 1.1 package http\r\n" + - "Accept-Encoding: gzip\r\n\r\n", - }, - - // Request with Body, but Dump requested without it. - { - Req: http.Request{ - Method: "POST", - URL: &url.URL{ - Scheme: "http", - Host: "post.tld", - Path: "/", - }, - ContentLength: 6, - ProtoMajor: 1, - ProtoMinor: 1, - }, - - Body: []byte("abcdef"), - - WantDumpOut: "POST / HTTP/1.1\r\n" + - "Host: post.tld\r\n" + - "User-Agent: Go 1.1 package http\r\n" + - "Content-Length: 6\r\n" + - "Accept-Encoding: gzip\r\n\r\n", - - NoBody: true, - }, -} - -func TestDumpRequest(t *testing.T) { - numg0 := runtime.NumGoroutine() - for i, tt := range dumpTests { - setBody := func() { - if tt.Body == nil { - return - } - switch b := tt.Body.(type) { - case []byte: - tt.Req.Body = ioutil.NopCloser(bytes.NewReader(b)) - case func() io.ReadCloser: - tt.Req.Body = b() - } - } - setBody() - if tt.Req.Header == nil { - tt.Req.Header = make(http.Header) - } - - if tt.WantDump != "" { - setBody() - dump, err := DumpRequest(&tt.Req, !tt.NoBody) - if err != nil { - t.Errorf("DumpRequest #%d: %s", i, err) - continue - } - if string(dump) != tt.WantDump { - t.Errorf("DumpRequest %d, expecting:\n%s\nGot:\n%s\n", i, tt.WantDump, string(dump)) - continue - } - } - - if tt.WantDumpOut != "" { - setBody() - dump, err := DumpRequestOut(&tt.Req, !tt.NoBody) - if err != nil { - t.Errorf("DumpRequestOut #%d: %s", i, err) - continue - } - if string(dump) != tt.WantDumpOut { - t.Errorf("DumpRequestOut %d, expecting:\n%s\nGot:\n%s\n", i, tt.WantDumpOut, string(dump)) - continue - } - } - } - if dg := runtime.NumGoroutine() - numg0; dg > 4 { - t.Errorf("Unexpectedly large number of new goroutines: %d new", dg) - } -} - -func chunk(s string) string { - return fmt.Sprintf("%x\r\n%s\r\n", len(s), s) -} - -func mustParseURL(s string) *url.URL { - u, err := url.Parse(s) - if err != nil { - panic(fmt.Sprintf("Error parsing URL %q: %v", s, err)) - } - return u -} - -func mustNewRequest(method, url string, body io.Reader) *http.Request { - req, err := http.NewRequest(method, url, body) - if err != nil { - panic(fmt.Sprintf("NewRequest(%q, %q, %p) err = %v", method, url, body, err)) - } - return req -} - -var dumpResTests = []struct { - res *http.Response - body bool - want string -}{ - { - res: &http.Response{ - Status: "200 OK", - StatusCode: 200, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - ContentLength: 50, - Header: http.Header{ - "Foo": []string{"Bar"}, - }, - Body: ioutil.NopCloser(strings.NewReader("foo")), // shouldn't be used - }, - body: false, // to verify we see 50, not empty or 3. - want: `HTTP/1.1 200 OK -Content-Length: 50 -Foo: Bar`, - }, - - { - res: &http.Response{ - Status: "200 OK", - StatusCode: 200, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - ContentLength: 3, - Body: ioutil.NopCloser(strings.NewReader("foo")), - }, - body: true, - want: `HTTP/1.1 200 OK -Content-Length: 3 - -foo`, - }, - - { - res: &http.Response{ - Status: "200 OK", - StatusCode: 200, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - ContentLength: -1, - Body: ioutil.NopCloser(strings.NewReader("foo")), - TransferEncoding: []string{"chunked"}, - }, - body: true, - want: `HTTP/1.1 200 OK -Transfer-Encoding: chunked - -3 -foo -0`, - }, -} - -func TestDumpResponse(t *testing.T) { - for i, tt := range dumpResTests { - gotb, err := DumpResponse(tt.res, tt.body) - if err != nil { - t.Errorf("%d. DumpResponse = %v", i, err) - continue - } - got := string(gotb) - got = strings.TrimSpace(got) - got = strings.Replace(got, "\r", "", -1) - - if got != tt.want { - t.Errorf("%d.\nDumpResponse got:\n%s\n\nWant:\n%s\n", i, got, tt.want) - } - } -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/httputil.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/httputil.go deleted file mode 100644 index 74fb6c6556..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/httputil.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package httputil provides HTTP utility functions, complementing the -// more common ones in the net/http package. -package httputil - -import "io" - -// NewChunkedReader returns a new chunkedReader that translates the data read from r -// out of HTTP "chunked" format before returning it. -// The chunkedReader returns io.EOF when the final 0-length chunk is read. -// -// NewChunkedReader is not needed by normal applications. The http package -// automatically decodes chunking when reading response bodies. -func NewChunkedReader(r io.Reader) io.Reader { - return newChunkedReader(r) -} - -// NewChunkedWriter returns a new chunkedWriter that translates writes into HTTP -// "chunked" format before writing them to w. Closing the returned chunkedWriter -// sends the final 0-length chunk that marks the end of the stream. -// -// NewChunkedWriter is not needed by normal applications. The http -// package adds chunking automatically if handlers don't set a -// Content-Length header. Using NewChunkedWriter inside a handler -// would result in double chunking or chunking with a Content-Length -// length, both of which are wrong. -func NewChunkedWriter(w io.Writer) io.WriteCloser { - return newChunkedWriter(w) -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/persist.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/persist.go deleted file mode 100644 index 987bcc96ba..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/persist.go +++ /dev/null @@ -1,429 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package httputil - -import ( - "bufio" - "errors" - "io" - "net" - "net/http" - "net/textproto" - "sync" -) - -var ( - ErrPersistEOF = &http.ProtocolError{ErrorString: "persistent connection closed"} - ErrClosed = &http.ProtocolError{ErrorString: "connection closed by user"} - ErrPipeline = &http.ProtocolError{ErrorString: "pipeline error"} -) - -// This is an API usage error - the local side is closed. -// ErrPersistEOF (above) reports that the remote side is closed. -var errClosed = errors.New("i/o operation on closed connection") - -// A ServerConn reads requests and sends responses over an underlying -// connection, until the HTTP keepalive logic commands an end. ServerConn -// also allows hijacking the underlying connection by calling Hijack -// to regain control over the connection. ServerConn supports pipe-lining, -// i.e. requests can be read out of sync (but in the same order) while the -// respective responses are sent. -// -// ServerConn is low-level and old. Applications should instead use Server -// in the net/http package. -type ServerConn struct { - lk sync.Mutex // read-write protects the following fields - c net.Conn - r *bufio.Reader - re, we error // read/write errors - lastbody io.ReadCloser - nread, nwritten int - pipereq map[*http.Request]uint - - pipe textproto.Pipeline -} - -// NewServerConn returns a new ServerConn reading and writing c. If r is not -// nil, it is the buffer to use when reading c. -// -// ServerConn is low-level and old. Applications should instead use Server -// in the net/http package. -func NewServerConn(c net.Conn, r *bufio.Reader) *ServerConn { - if r == nil { - r = bufio.NewReader(c) - } - return &ServerConn{c: c, r: r, pipereq: make(map[*http.Request]uint)} -} - -// Hijack detaches the ServerConn and returns the underlying connection as well -// as the read-side bufio which may have some left over data. Hijack may be -// called before Read has signaled the end of the keep-alive logic. The user -// should not call Hijack while Read or Write is in progress. -func (sc *ServerConn) Hijack() (c net.Conn, r *bufio.Reader) { - sc.lk.Lock() - defer sc.lk.Unlock() - c = sc.c - r = sc.r - sc.c = nil - sc.r = nil - return -} - -// Close calls Hijack and then also closes the underlying connection -func (sc *ServerConn) Close() error { - c, _ := sc.Hijack() - if c != nil { - return c.Close() - } - return nil -} - -// Read returns the next request on the wire. An ErrPersistEOF is returned if -// it is gracefully determined that there are no more requests (e.g. after the -// first request on an HTTP/1.0 connection, or after a Connection:close on a -// HTTP/1.1 connection). -func (sc *ServerConn) Read() (req *http.Request, err error) { - - // Ensure ordered execution of Reads and Writes - id := sc.pipe.Next() - sc.pipe.StartRequest(id) - defer func() { - sc.pipe.EndRequest(id) - if req == nil { - sc.pipe.StartResponse(id) - sc.pipe.EndResponse(id) - } else { - // Remember the pipeline id of this request - sc.lk.Lock() - sc.pipereq[req] = id - sc.lk.Unlock() - } - }() - - sc.lk.Lock() - if sc.we != nil { // no point receiving if write-side broken or closed - defer sc.lk.Unlock() - return nil, sc.we - } - if sc.re != nil { - defer sc.lk.Unlock() - return nil, sc.re - } - if sc.r == nil { // connection closed by user in the meantime - defer sc.lk.Unlock() - return nil, errClosed - } - r := sc.r - lastbody := sc.lastbody - sc.lastbody = nil - sc.lk.Unlock() - - // Make sure body is fully consumed, even if user does not call body.Close - if lastbody != nil { - // body.Close is assumed to be idempotent and multiple calls to - // it should return the error that its first invocation - // returned. - err = lastbody.Close() - if err != nil { - sc.lk.Lock() - defer sc.lk.Unlock() - sc.re = err - return nil, err - } - } - - req, err = http.ReadRequest(r) - sc.lk.Lock() - defer sc.lk.Unlock() - if err != nil { - if err == io.ErrUnexpectedEOF { - // A close from the opposing client is treated as a - // graceful close, even if there was some unparse-able - // data before the close. - sc.re = ErrPersistEOF - return nil, sc.re - } else { - sc.re = err - return req, err - } - } - sc.lastbody = req.Body - sc.nread++ - if req.Close { - sc.re = ErrPersistEOF - return req, sc.re - } - return req, err -} - -// Pending returns the number of unanswered requests -// that have been received on the connection. -func (sc *ServerConn) Pending() int { - sc.lk.Lock() - defer sc.lk.Unlock() - return sc.nread - sc.nwritten -} - -// Write writes resp in response to req. To close the connection gracefully, set the -// Response.Close field to true. Write should be considered operational until -// it returns an error, regardless of any errors returned on the Read side. -func (sc *ServerConn) Write(req *http.Request, resp *http.Response) error { - - // Retrieve the pipeline ID of this request/response pair - sc.lk.Lock() - id, ok := sc.pipereq[req] - delete(sc.pipereq, req) - if !ok { - sc.lk.Unlock() - return ErrPipeline - } - sc.lk.Unlock() - - // Ensure pipeline order - sc.pipe.StartResponse(id) - defer sc.pipe.EndResponse(id) - - sc.lk.Lock() - if sc.we != nil { - defer sc.lk.Unlock() - return sc.we - } - if sc.c == nil { // connection closed by user in the meantime - defer sc.lk.Unlock() - return ErrClosed - } - c := sc.c - if sc.nread <= sc.nwritten { - defer sc.lk.Unlock() - return errors.New("persist server pipe count") - } - if resp.Close { - // After signaling a keep-alive close, any pipelined unread - // requests will be lost. It is up to the user to drain them - // before signaling. - sc.re = ErrPersistEOF - } - sc.lk.Unlock() - - err := resp.Write(c) - sc.lk.Lock() - defer sc.lk.Unlock() - if err != nil { - sc.we = err - return err - } - sc.nwritten++ - - return nil -} - -// A ClientConn sends request and receives headers over an underlying -// connection, while respecting the HTTP keepalive logic. ClientConn -// supports hijacking the connection calling Hijack to -// regain control of the underlying net.Conn and deal with it as desired. -// -// ClientConn is low-level and old. Applications should instead use -// Client or Transport in the net/http package. -type ClientConn struct { - lk sync.Mutex // read-write protects the following fields - c net.Conn - r *bufio.Reader - re, we error // read/write errors - lastbody io.ReadCloser - nread, nwritten int - pipereq map[*http.Request]uint - - pipe textproto.Pipeline - writeReq func(*http.Request, io.Writer) error -} - -// NewClientConn returns a new ClientConn reading and writing c. If r is not -// nil, it is the buffer to use when reading c. -// -// ClientConn is low-level and old. Applications should use Client or -// Transport in the net/http package. -func NewClientConn(c net.Conn, r *bufio.Reader) *ClientConn { - if r == nil { - r = bufio.NewReader(c) - } - return &ClientConn{ - c: c, - r: r, - pipereq: make(map[*http.Request]uint), - writeReq: (*http.Request).Write, - } -} - -// NewProxyClientConn works like NewClientConn but writes Requests -// using Request's WriteProxy method. -// -// New code should not use NewProxyClientConn. See Client or -// Transport in the net/http package instead. -func NewProxyClientConn(c net.Conn, r *bufio.Reader) *ClientConn { - cc := NewClientConn(c, r) - cc.writeReq = (*http.Request).WriteProxy - return cc -} - -// Hijack detaches the ClientConn and returns the underlying connection as well -// as the read-side bufio which may have some left over data. Hijack may be -// called before the user or Read have signaled the end of the keep-alive -// logic. The user should not call Hijack while Read or Write is in progress. -func (cc *ClientConn) Hijack() (c net.Conn, r *bufio.Reader) { - cc.lk.Lock() - defer cc.lk.Unlock() - c = cc.c - r = cc.r - cc.c = nil - cc.r = nil - return -} - -// Close calls Hijack and then also closes the underlying connection -func (cc *ClientConn) Close() error { - c, _ := cc.Hijack() - if c != nil { - return c.Close() - } - return nil -} - -// Write writes a request. An ErrPersistEOF error is returned if the connection -// has been closed in an HTTP keepalive sense. If req.Close equals true, the -// keepalive connection is logically closed after this request and the opposing -// server is informed. An ErrUnexpectedEOF indicates the remote closed the -// underlying TCP connection, which is usually considered as graceful close. -func (cc *ClientConn) Write(req *http.Request) (err error) { - - // Ensure ordered execution of Writes - id := cc.pipe.Next() - cc.pipe.StartRequest(id) - defer func() { - cc.pipe.EndRequest(id) - if err != nil { - cc.pipe.StartResponse(id) - cc.pipe.EndResponse(id) - } else { - // Remember the pipeline id of this request - cc.lk.Lock() - cc.pipereq[req] = id - cc.lk.Unlock() - } - }() - - cc.lk.Lock() - if cc.re != nil { // no point sending if read-side closed or broken - defer cc.lk.Unlock() - return cc.re - } - if cc.we != nil { - defer cc.lk.Unlock() - return cc.we - } - if cc.c == nil { // connection closed by user in the meantime - defer cc.lk.Unlock() - return errClosed - } - c := cc.c - if req.Close { - // We write the EOF to the write-side error, because there - // still might be some pipelined reads - cc.we = ErrPersistEOF - } - cc.lk.Unlock() - - err = cc.writeReq(req, c) - cc.lk.Lock() - defer cc.lk.Unlock() - if err != nil { - cc.we = err - return err - } - cc.nwritten++ - - return nil -} - -// Pending returns the number of unanswered requests -// that have been sent on the connection. -func (cc *ClientConn) Pending() int { - cc.lk.Lock() - defer cc.lk.Unlock() - return cc.nwritten - cc.nread -} - -// Read reads the next response from the wire. A valid response might be -// returned together with an ErrPersistEOF, which means that the remote -// requested that this be the last request serviced. Read can be called -// concurrently with Write, but not with another Read. -func (cc *ClientConn) Read(req *http.Request) (resp *http.Response, err error) { - // Retrieve the pipeline ID of this request/response pair - cc.lk.Lock() - id, ok := cc.pipereq[req] - delete(cc.pipereq, req) - if !ok { - cc.lk.Unlock() - return nil, ErrPipeline - } - cc.lk.Unlock() - - // Ensure pipeline order - cc.pipe.StartResponse(id) - defer cc.pipe.EndResponse(id) - - cc.lk.Lock() - if cc.re != nil { - defer cc.lk.Unlock() - return nil, cc.re - } - if cc.r == nil { // connection closed by user in the meantime - defer cc.lk.Unlock() - return nil, errClosed - } - r := cc.r - lastbody := cc.lastbody - cc.lastbody = nil - cc.lk.Unlock() - - // Make sure body is fully consumed, even if user does not call body.Close - if lastbody != nil { - // body.Close is assumed to be idempotent and multiple calls to - // it should return the error that its first invocation - // returned. - err = lastbody.Close() - if err != nil { - cc.lk.Lock() - defer cc.lk.Unlock() - cc.re = err - return nil, err - } - } - - resp, err = http.ReadResponse(r, req) - cc.lk.Lock() - defer cc.lk.Unlock() - if err != nil { - cc.re = err - return resp, err - } - cc.lastbody = resp.Body - - cc.nread++ - - if resp.Close { - cc.re = ErrPersistEOF // don't send any more requests - return resp, cc.re - } - return resp, err -} - -// Do is convenience method that writes a request and reads a response. -func (cc *ClientConn) Do(req *http.Request) (resp *http.Response, err error) { - err = cc.Write(req) - if err != nil { - return - } - return cc.Read(req) -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/reverseproxy.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/reverseproxy.go deleted file mode 100644 index 48ada5f5fd..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/reverseproxy.go +++ /dev/null @@ -1,211 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// HTTP reverse proxy handler - -package httputil - -import ( - "io" - "log" - "net" - "net/http" - "net/url" - "strings" - "sync" - "time" -) - -// onExitFlushLoop is a callback set by tests to detect the state of the -// flushLoop() goroutine. -var onExitFlushLoop func() - -// ReverseProxy is an HTTP Handler that takes an incoming request and -// sends it to another server, proxying the response back to the -// client. -type ReverseProxy struct { - // Director must be a function which modifies - // the request into a new request to be sent - // using Transport. Its response is then copied - // back to the original client unmodified. - Director func(*http.Request) - - // The transport used to perform proxy requests. - // If nil, http.DefaultTransport is used. - Transport http.RoundTripper - - // FlushInterval specifies the flush interval - // to flush to the client while copying the - // response body. - // If zero, no periodic flushing is done. - FlushInterval time.Duration -} - -func singleJoiningSlash(a, b string) string { - aslash := strings.HasSuffix(a, "/") - bslash := strings.HasPrefix(b, "/") - switch { - case aslash && bslash: - return a + b[1:] - case !aslash && !bslash: - return a + "/" + b - } - return a + b -} - -// NewSingleHostReverseProxy returns a new ReverseProxy that rewrites -// URLs to the scheme, host, and base path provided in target. If the -// target's path is "/base" and the incoming request was for "/dir", -// the target request will be for /base/dir. -func NewSingleHostReverseProxy(target *url.URL) *ReverseProxy { - targetQuery := target.RawQuery - director := func(req *http.Request) { - req.URL.Scheme = target.Scheme - req.URL.Host = target.Host - req.URL.Path = singleJoiningSlash(target.Path, req.URL.Path) - if targetQuery == "" || req.URL.RawQuery == "" { - req.URL.RawQuery = targetQuery + req.URL.RawQuery - } else { - req.URL.RawQuery = targetQuery + "&" + req.URL.RawQuery - } - } - return &ReverseProxy{Director: director} -} - -func copyHeader(dst, src http.Header) { - for k, vv := range src { - for _, v := range vv { - dst.Add(k, v) - } - } -} - -// Hop-by-hop headers. These are removed when sent to the backend. -// http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html -var hopHeaders = []string{ - "Connection", - "Keep-Alive", - "Proxy-Authenticate", - "Proxy-Authorization", - "Te", // canonicalized version of "TE" - "Trailers", - "Transfer-Encoding", - "Upgrade", -} - -func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) { - transport := p.Transport - if transport == nil { - transport = http.DefaultTransport - } - - outreq := new(http.Request) - *outreq = *req // includes shallow copies of maps, but okay - - p.Director(outreq) - outreq.Proto = "HTTP/1.1" - outreq.ProtoMajor = 1 - outreq.ProtoMinor = 1 - outreq.Close = false - - // Remove hop-by-hop headers to the backend. Especially - // important is "Connection" because we want a persistent - // connection, regardless of what the client sent to us. This - // is modifying the same underlying map from req (shallow - // copied above) so we only copy it if necessary. - copiedHeaders := false - for _, h := range hopHeaders { - if outreq.Header.Get(h) != "" { - if !copiedHeaders { - outreq.Header = make(http.Header) - copyHeader(outreq.Header, req.Header) - copiedHeaders = true - } - outreq.Header.Del(h) - } - } - - if clientIP, _, err := net.SplitHostPort(req.RemoteAddr); err == nil { - // If we aren't the first proxy retain prior - // X-Forwarded-For information as a comma+space - // separated list and fold multiple headers into one. - if prior, ok := outreq.Header["X-Forwarded-For"]; ok { - clientIP = strings.Join(prior, ", ") + ", " + clientIP - } - outreq.Header.Set("X-Forwarded-For", clientIP) - } - - res, err := transport.RoundTrip(outreq) - if err != nil { - log.Printf("http: proxy error: %v", err) - rw.WriteHeader(http.StatusInternalServerError) - return - } - defer res.Body.Close() - - for _, h := range hopHeaders { - res.Header.Del(h) - } - - copyHeader(rw.Header(), res.Header) - - rw.WriteHeader(res.StatusCode) - p.copyResponse(rw, res.Body) -} - -func (p *ReverseProxy) copyResponse(dst io.Writer, src io.Reader) { - if p.FlushInterval != 0 { - if wf, ok := dst.(writeFlusher); ok { - mlw := &maxLatencyWriter{ - dst: wf, - latency: p.FlushInterval, - done: make(chan bool), - } - go mlw.flushLoop() - defer mlw.stop() - dst = mlw - } - } - - io.Copy(dst, src) -} - -type writeFlusher interface { - io.Writer - http.Flusher -} - -type maxLatencyWriter struct { - dst writeFlusher - latency time.Duration - - lk sync.Mutex // protects Write + Flush - done chan bool -} - -func (m *maxLatencyWriter) Write(p []byte) (int, error) { - m.lk.Lock() - defer m.lk.Unlock() - return m.dst.Write(p) -} - -func (m *maxLatencyWriter) flushLoop() { - t := time.NewTicker(m.latency) - defer t.Stop() - for { - select { - case <-m.done: - if onExitFlushLoop != nil { - onExitFlushLoop() - } - return - case <-t.C: - m.lk.Lock() - m.dst.Flush() - m.lk.Unlock() - } - } -} - -func (m *maxLatencyWriter) stop() { m.done <- true } diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/reverseproxy_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/reverseproxy_test.go deleted file mode 100644 index e9539b44b6..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/httputil/reverseproxy_test.go +++ /dev/null @@ -1,213 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Reverse proxy tests. - -package httputil - -import ( - "io/ioutil" - "net/http" - "net/http/httptest" - "net/url" - "strings" - "testing" - "time" -) - -const fakeHopHeader = "X-Fake-Hop-Header-For-Test" - -func init() { - hopHeaders = append(hopHeaders, fakeHopHeader) -} - -func TestReverseProxy(t *testing.T) { - const backendResponse = "I am the backend" - const backendStatus = 404 - backend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if len(r.TransferEncoding) > 0 { - t.Errorf("backend got unexpected TransferEncoding: %v", r.TransferEncoding) - } - if r.Header.Get("X-Forwarded-For") == "" { - t.Errorf("didn't get X-Forwarded-For header") - } - if c := r.Header.Get("Connection"); c != "" { - t.Errorf("handler got Connection header value %q", c) - } - if c := r.Header.Get("Upgrade"); c != "" { - t.Errorf("handler got Upgrade header value %q", c) - } - if g, e := r.Host, "some-name"; g != e { - t.Errorf("backend got Host header %q, want %q", g, e) - } - w.Header().Set("X-Foo", "bar") - w.Header().Set("Upgrade", "foo") - w.Header().Set(fakeHopHeader, "foo") - w.Header().Add("X-Multi-Value", "foo") - w.Header().Add("X-Multi-Value", "bar") - http.SetCookie(w, &http.Cookie{Name: "flavor", Value: "chocolateChip"}) - w.WriteHeader(backendStatus) - w.Write([]byte(backendResponse)) - })) - defer backend.Close() - backendURL, err := url.Parse(backend.URL) - if err != nil { - t.Fatal(err) - } - proxyHandler := NewSingleHostReverseProxy(backendURL) - frontend := httptest.NewServer(proxyHandler) - defer frontend.Close() - - getReq, _ := http.NewRequest("GET", frontend.URL, nil) - getReq.Host = "some-name" - getReq.Header.Set("Connection", "close") - getReq.Header.Set("Upgrade", "foo") - getReq.Close = true - res, err := http.DefaultClient.Do(getReq) - if err != nil { - t.Fatalf("Get: %v", err) - } - if g, e := res.StatusCode, backendStatus; g != e { - t.Errorf("got res.StatusCode %d; expected %d", g, e) - } - if g, e := res.Header.Get("X-Foo"), "bar"; g != e { - t.Errorf("got X-Foo %q; expected %q", g, e) - } - if c := res.Header.Get(fakeHopHeader); c != "" { - t.Errorf("got %s header value %q", fakeHopHeader, c) - } - if g, e := len(res.Header["X-Multi-Value"]), 2; g != e { - t.Errorf("got %d X-Multi-Value header values; expected %d", g, e) - } - if g, e := len(res.Header["Set-Cookie"]), 1; g != e { - t.Fatalf("got %d SetCookies, want %d", g, e) - } - if cookie := res.Cookies()[0]; cookie.Name != "flavor" { - t.Errorf("unexpected cookie %q", cookie.Name) - } - bodyBytes, _ := ioutil.ReadAll(res.Body) - if g, e := string(bodyBytes), backendResponse; g != e { - t.Errorf("got body %q; expected %q", g, e) - } -} - -func TestXForwardedFor(t *testing.T) { - const prevForwardedFor = "client ip" - const backendResponse = "I am the backend" - const backendStatus = 404 - backend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if r.Header.Get("X-Forwarded-For") == "" { - t.Errorf("didn't get X-Forwarded-For header") - } - if !strings.Contains(r.Header.Get("X-Forwarded-For"), prevForwardedFor) { - t.Errorf("X-Forwarded-For didn't contain prior data") - } - w.WriteHeader(backendStatus) - w.Write([]byte(backendResponse)) - })) - defer backend.Close() - backendURL, err := url.Parse(backend.URL) - if err != nil { - t.Fatal(err) - } - proxyHandler := NewSingleHostReverseProxy(backendURL) - frontend := httptest.NewServer(proxyHandler) - defer frontend.Close() - - getReq, _ := http.NewRequest("GET", frontend.URL, nil) - getReq.Host = "some-name" - getReq.Header.Set("Connection", "close") - getReq.Header.Set("X-Forwarded-For", prevForwardedFor) - getReq.Close = true - res, err := http.DefaultClient.Do(getReq) - if err != nil { - t.Fatalf("Get: %v", err) - } - if g, e := res.StatusCode, backendStatus; g != e { - t.Errorf("got res.StatusCode %d; expected %d", g, e) - } - bodyBytes, _ := ioutil.ReadAll(res.Body) - if g, e := string(bodyBytes), backendResponse; g != e { - t.Errorf("got body %q; expected %q", g, e) - } -} - -var proxyQueryTests = []struct { - baseSuffix string // suffix to add to backend URL - reqSuffix string // suffix to add to frontend's request URL - want string // what backend should see for final request URL (without ?) -}{ - {"", "", ""}, - {"?sta=tic", "?us=er", "sta=tic&us=er"}, - {"", "?us=er", "us=er"}, - {"?sta=tic", "", "sta=tic"}, -} - -func TestReverseProxyQuery(t *testing.T) { - backend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("X-Got-Query", r.URL.RawQuery) - w.Write([]byte("hi")) - })) - defer backend.Close() - - for i, tt := range proxyQueryTests { - backendURL, err := url.Parse(backend.URL + tt.baseSuffix) - if err != nil { - t.Fatal(err) - } - frontend := httptest.NewServer(NewSingleHostReverseProxy(backendURL)) - req, _ := http.NewRequest("GET", frontend.URL+tt.reqSuffix, nil) - req.Close = true - res, err := http.DefaultClient.Do(req) - if err != nil { - t.Fatalf("%d. Get: %v", i, err) - } - if g, e := res.Header.Get("X-Got-Query"), tt.want; g != e { - t.Errorf("%d. got query %q; expected %q", i, g, e) - } - res.Body.Close() - frontend.Close() - } -} - -func TestReverseProxyFlushInterval(t *testing.T) { - const expected = "hi" - backend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte(expected)) - })) - defer backend.Close() - - backendURL, err := url.Parse(backend.URL) - if err != nil { - t.Fatal(err) - } - - proxyHandler := NewSingleHostReverseProxy(backendURL) - proxyHandler.FlushInterval = time.Microsecond - - done := make(chan bool) - onExitFlushLoop = func() { done <- true } - defer func() { onExitFlushLoop = nil }() - - frontend := httptest.NewServer(proxyHandler) - defer frontend.Close() - - req, _ := http.NewRequest("GET", frontend.URL, nil) - req.Close = true - res, err := http.DefaultClient.Do(req) - if err != nil { - t.Fatalf("Get: %v", err) - } - defer res.Body.Close() - if bodyBytes, _ := ioutil.ReadAll(res.Body); string(bodyBytes) != expected { - t.Errorf("got body %q; expected %q", bodyBytes, expected) - } - - select { - case <-done: - // OK - case <-time.After(5 * time.Second): - t.Error("maxLatencyWriter flushLoop() never exited") - } -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/lex_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/lex_test.go deleted file mode 100644 index 6d9d294f70..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/lex_test.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http - -import ( - "testing" -) - -func isChar(c rune) bool { return c <= 127 } - -func isCtl(c rune) bool { return c <= 31 || c == 127 } - -func isSeparator(c rune) bool { - switch c { - case '(', ')', '<', '>', '@', ',', ';', ':', '\\', '"', '/', '[', ']', '?', '=', '{', '}', ' ', '\t': - return true - } - return false -} - -func TestIsToken(t *testing.T) { - for i := 0; i <= 130; i++ { - r := rune(i) - expected := isChar(r) && !isCtl(r) && !isSeparator(r) - if isToken(r) != expected { - t.Errorf("isToken(0x%x) = %v", r, !expected) - } - } -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/npn_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/npn_test.go deleted file mode 100644 index 98b8930d06..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/npn_test.go +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http_test - -import ( - "bufio" - "crypto/tls" - "fmt" - "io" - "io/ioutil" - . "net/http" - "net/http/httptest" - "strings" - "testing" -) - -func TestNextProtoUpgrade(t *testing.T) { - ts := httptest.NewUnstartedServer(HandlerFunc(func(w ResponseWriter, r *Request) { - fmt.Fprintf(w, "path=%s,proto=", r.URL.Path) - if r.TLS != nil { - w.Write([]byte(r.TLS.NegotiatedProtocol)) - } - if r.RemoteAddr == "" { - t.Error("request with no RemoteAddr") - } - if r.Body == nil { - t.Errorf("request with nil Body") - } - })) - ts.TLS = &tls.Config{ - NextProtos: []string{"unhandled-proto", "tls-0.9"}, - } - ts.Config.TLSNextProto = map[string]func(*Server, *tls.Conn, Handler){ - "tls-0.9": handleTLSProtocol09, - } - ts.StartTLS() - defer ts.Close() - - tr := newTLSTransport(t, ts) - defer tr.CloseIdleConnections() - c := &Client{Transport: tr} - - // Normal request, without NPN. - { - res, err := c.Get(ts.URL) - if err != nil { - t.Fatal(err) - } - body, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatal(err) - } - if want := "path=/,proto="; string(body) != want { - t.Errorf("plain request = %q; want %q", body, want) - } - } - - // Request to an advertised but unhandled NPN protocol. - // Server will hang up. - { - tr.CloseIdleConnections() - tr.TLSClientConfig.NextProtos = []string{"unhandled-proto"} - _, err := c.Get(ts.URL) - if err == nil { - t.Errorf("expected error on unhandled-proto request") - } - } - - // Request using the "tls-0.9" protocol, which we register here. - // It is HTTP/0.9 over TLS. - { - tlsConfig := newTLSTransport(t, ts).TLSClientConfig - tlsConfig.NextProtos = []string{"tls-0.9"} - conn, err := tls.Dial("tcp", ts.Listener.Addr().String(), tlsConfig) - if err != nil { - t.Fatal(err) - } - conn.Write([]byte("GET /foo\n")) - body, err := ioutil.ReadAll(conn) - if err != nil { - t.Fatal(err) - } - if want := "path=/foo,proto=tls-0.9"; string(body) != want { - t.Errorf("plain request = %q; want %q", body, want) - } - } -} - -// handleTLSProtocol09 implements the HTTP/0.9 protocol over TLS, for the -// TestNextProtoUpgrade test. -func handleTLSProtocol09(srv *Server, conn *tls.Conn, h Handler) { - br := bufio.NewReader(conn) - line, err := br.ReadString('\n') - if err != nil { - return - } - line = strings.TrimSpace(line) - path := strings.TrimPrefix(line, "GET ") - if path == line { - return - } - req, _ := NewRequest("GET", path, nil) - req.Proto = "HTTP/0.9" - req.ProtoMajor = 0 - req.ProtoMinor = 9 - rw := &http09Writer{conn, make(Header)} - h.ServeHTTP(rw, req) -} - -type http09Writer struct { - io.Writer - h Header -} - -func (w http09Writer) Header() Header { return w.h } -func (w http09Writer) WriteHeader(int) {} // no headers diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/pprof/pprof.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/pprof/pprof.go deleted file mode 100644 index 0c7548e3ef..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/pprof/pprof.go +++ /dev/null @@ -1,205 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package pprof serves via its HTTP server runtime profiling data -// in the format expected by the pprof visualization tool. -// For more information about pprof, see -// http://code.google.com/p/google-perftools/. -// -// The package is typically only imported for the side effect of -// registering its HTTP handlers. -// The handled paths all begin with /debug/pprof/. -// -// To use pprof, link this package into your program: -// import _ "net/http/pprof" -// -// If your application is not already running an http server, you -// need to start one. Add "net/http" and "log" to your imports and -// the following code to your main function: -// -// go func() { -// log.Println(http.ListenAndServe("localhost:6060", nil)) -// }() -// -// Then use the pprof tool to look at the heap profile: -// -// go tool pprof http://localhost:6060/debug/pprof/heap -// -// Or to look at a 30-second CPU profile: -// -// go tool pprof http://localhost:6060/debug/pprof/profile -// -// Or to look at the goroutine blocking profile: -// -// go tool pprof http://localhost:6060/debug/pprof/block -// -// To view all available profiles, open http://localhost:6060/debug/pprof/ -// in your browser. -// -// For a study of the facility in action, visit -// -// http://blog.golang.org/2011/06/profiling-go-programs.html -// -package pprof - -import ( - "bufio" - "bytes" - "fmt" - "html/template" - "io" - "log" - "net/http" - "os" - "runtime" - "runtime/pprof" - "strconv" - "strings" - "time" -) - -func init() { - http.Handle("/debug/pprof/", http.HandlerFunc(Index)) - http.Handle("/debug/pprof/cmdline", http.HandlerFunc(Cmdline)) - http.Handle("/debug/pprof/profile", http.HandlerFunc(Profile)) - http.Handle("/debug/pprof/symbol", http.HandlerFunc(Symbol)) -} - -// Cmdline responds with the running program's -// command line, with arguments separated by NUL bytes. -// The package initialization registers it as /debug/pprof/cmdline. -func Cmdline(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "text/plain; charset=utf-8") - fmt.Fprintf(w, strings.Join(os.Args, "\x00")) -} - -// Profile responds with the pprof-formatted cpu profile. -// The package initialization registers it as /debug/pprof/profile. -func Profile(w http.ResponseWriter, r *http.Request) { - sec, _ := strconv.ParseInt(r.FormValue("seconds"), 10, 64) - if sec == 0 { - sec = 30 - } - - // Set Content Type assuming StartCPUProfile will work, - // because if it does it starts writing. - w.Header().Set("Content-Type", "application/octet-stream") - if err := pprof.StartCPUProfile(w); err != nil { - // StartCPUProfile failed, so no writes yet. - // Can change header back to text content - // and send error code. - w.Header().Set("Content-Type", "text/plain; charset=utf-8") - w.WriteHeader(http.StatusInternalServerError) - fmt.Fprintf(w, "Could not enable CPU profiling: %s\n", err) - return - } - time.Sleep(time.Duration(sec) * time.Second) - pprof.StopCPUProfile() -} - -// Symbol looks up the program counters listed in the request, -// responding with a table mapping program counters to function names. -// The package initialization registers it as /debug/pprof/symbol. -func Symbol(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "text/plain; charset=utf-8") - - // We have to read the whole POST body before - // writing any output. Buffer the output here. - var buf bytes.Buffer - - // We don't know how many symbols we have, but we - // do have symbol information. Pprof only cares whether - // this number is 0 (no symbols available) or > 0. - fmt.Fprintf(&buf, "num_symbols: 1\n") - - var b *bufio.Reader - if r.Method == "POST" { - b = bufio.NewReader(r.Body) - } else { - b = bufio.NewReader(strings.NewReader(r.URL.RawQuery)) - } - - for { - word, err := b.ReadSlice('+') - if err == nil { - word = word[0 : len(word)-1] // trim + - } - pc, _ := strconv.ParseUint(string(word), 0, 64) - if pc != 0 { - f := runtime.FuncForPC(uintptr(pc)) - if f != nil { - fmt.Fprintf(&buf, "%#x %s\n", pc, f.Name()) - } - } - - // Wait until here to check for err; the last - // symbol will have an err because it doesn't end in +. - if err != nil { - if err != io.EOF { - fmt.Fprintf(&buf, "reading request: %v\n", err) - } - break - } - } - - w.Write(buf.Bytes()) -} - -// Handler returns an HTTP handler that serves the named profile. -func Handler(name string) http.Handler { - return handler(name) -} - -type handler string - -func (name handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "text/plain; charset=utf-8") - debug, _ := strconv.Atoi(r.FormValue("debug")) - p := pprof.Lookup(string(name)) - if p == nil { - w.WriteHeader(404) - fmt.Fprintf(w, "Unknown profile: %s\n", name) - return - } - p.WriteTo(w, debug) - return -} - -// Index responds with the pprof-formatted profile named by the request. -// For example, "/debug/pprof/heap" serves the "heap" profile. -// Index responds to a request for "/debug/pprof/" with an HTML page -// listing the available profiles. -func Index(w http.ResponseWriter, r *http.Request) { - if strings.HasPrefix(r.URL.Path, "/debug/pprof/") { - name := strings.TrimPrefix(r.URL.Path, "/debug/pprof/") - if name != "" { - handler(name).ServeHTTP(w, r) - return - } - } - - profiles := pprof.Profiles() - if err := indexTmpl.Execute(w, profiles); err != nil { - log.Print(err) - } -} - -var indexTmpl = template.Must(template.New("index").Parse(` - -/debug/pprof/ - -/debug/pprof/
-
- -profiles:
- -{{range .}} -
{{.Count}}{{.Name}} -{{end}} -
-
-full goroutine stack dump
- - -`)) diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/proxy_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/proxy_test.go deleted file mode 100644 index b6aed3792b..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/proxy_test.go +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http - -import ( - "net/url" - "os" - "testing" -) - -// TODO(mattn): -// test ProxyAuth - -var UseProxyTests = []struct { - host string - match bool -}{ - // Never proxy localhost: - {"localhost:80", false}, - {"127.0.0.1", false}, - {"127.0.0.2", false}, - {"[::1]", false}, - {"[::2]", true}, // not a loopback address - - {"barbaz.net", false}, // match as .barbaz.net - {"foobar.com", false}, // have a port but match - {"foofoobar.com", true}, // not match as a part of foobar.com - {"baz.com", true}, // not match as a part of barbaz.com - {"localhost.net", true}, // not match as suffix of address - {"local.localhost", true}, // not match as prefix as address - {"barbarbaz.net", true}, // not match because NO_PROXY have a '.' - {"www.foobar.com", false}, // match because NO_PROXY includes "foobar.com" -} - -func TestUseProxy(t *testing.T) { - ResetProxyEnv() - os.Setenv("NO_PROXY", "foobar.com, .barbaz.net") - for _, test := range UseProxyTests { - if useProxy(test.host+":80") != test.match { - t.Errorf("useProxy(%v) = %v, want %v", test.host, !test.match, test.match) - } - } -} - -var cacheKeysTests = []struct { - proxy string - scheme string - addr string - key string -}{ - {"", "http", "foo.com", "|http|foo.com"}, - {"", "https", "foo.com", "|https|foo.com"}, - {"http://foo.com", "http", "foo.com", "http://foo.com|http|"}, - {"http://foo.com", "https", "foo.com", "http://foo.com|https|foo.com"}, -} - -func TestCacheKeys(t *testing.T) { - for _, tt := range cacheKeysTests { - var proxy *url.URL - if tt.proxy != "" { - u, err := url.Parse(tt.proxy) - if err != nil { - t.Fatal(err) - } - proxy = u - } - cm := connectMethod{proxy, tt.scheme, tt.addr} - if got := cm.key().String(); got != tt.key { - t.Fatalf("{%q, %q, %q} cache key = %q; want %q", tt.proxy, tt.scheme, tt.addr, got, tt.key) - } - } -} - -func ResetProxyEnv() { - for _, v := range []string{"HTTP_PROXY", "http_proxy", "NO_PROXY", "no_proxy"} { - os.Setenv(v, "") - } - ResetCachedEnvironment() -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/range_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/range_test.go deleted file mode 100644 index ef911af7b0..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/range_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http - -import ( - "testing" -) - -var ParseRangeTests = []struct { - s string - length int64 - r []httpRange -}{ - {"", 0, nil}, - {"", 1000, nil}, - {"foo", 0, nil}, - {"bytes=", 0, nil}, - {"bytes=7", 10, nil}, - {"bytes= 7 ", 10, nil}, - {"bytes=1-", 0, nil}, - {"bytes=5-4", 10, nil}, - {"bytes=0-2,5-4", 10, nil}, - {"bytes=2-5,4-3", 10, nil}, - {"bytes=--5,4--3", 10, nil}, - {"bytes=A-", 10, nil}, - {"bytes=A- ", 10, nil}, - {"bytes=A-Z", 10, nil}, - {"bytes= -Z", 10, nil}, - {"bytes=5-Z", 10, nil}, - {"bytes=Ran-dom, garbage", 10, nil}, - {"bytes=0x01-0x02", 10, nil}, - {"bytes= ", 10, nil}, - {"bytes= , , , ", 10, nil}, - - {"bytes=0-9", 10, []httpRange{{0, 10}}}, - {"bytes=0-", 10, []httpRange{{0, 10}}}, - {"bytes=5-", 10, []httpRange{{5, 5}}}, - {"bytes=0-20", 10, []httpRange{{0, 10}}}, - {"bytes=15-,0-5", 10, nil}, - {"bytes=1-2,5-", 10, []httpRange{{1, 2}, {5, 5}}}, - {"bytes=-2 , 7-", 11, []httpRange{{9, 2}, {7, 4}}}, - {"bytes=0-0 ,2-2, 7-", 11, []httpRange{{0, 1}, {2, 1}, {7, 4}}}, - {"bytes=-5", 10, []httpRange{{5, 5}}}, - {"bytes=-15", 10, []httpRange{{0, 10}}}, - {"bytes=0-499", 10000, []httpRange{{0, 500}}}, - {"bytes=500-999", 10000, []httpRange{{500, 500}}}, - {"bytes=-500", 10000, []httpRange{{9500, 500}}}, - {"bytes=9500-", 10000, []httpRange{{9500, 500}}}, - {"bytes=0-0,-1", 10000, []httpRange{{0, 1}, {9999, 1}}}, - {"bytes=500-600,601-999", 10000, []httpRange{{500, 101}, {601, 399}}}, - {"bytes=500-700,601-999", 10000, []httpRange{{500, 201}, {601, 399}}}, - - // Match Apache laxity: - {"bytes= 1 -2 , 4- 5, 7 - 8 , ,,", 11, []httpRange{{1, 2}, {4, 2}, {7, 2}}}, -} - -func TestParseRange(t *testing.T) { - for _, test := range ParseRangeTests { - r := test.r - ranges, err := parseRange(test.s, test.length) - if err != nil && r != nil { - t.Errorf("parseRange(%q) returned error %q", test.s, err) - } - if len(ranges) != len(r) { - t.Errorf("len(parseRange(%q)) = %d, want %d", test.s, len(ranges), len(r)) - continue - } - for i := range r { - if ranges[i].start != r[i].start { - t.Errorf("parseRange(%q)[%d].start = %d, want %d", test.s, i, ranges[i].start, r[i].start) - } - if ranges[i].length != r[i].length { - t.Errorf("parseRange(%q)[%d].length = %d, want %d", test.s, i, ranges[i].length, r[i].length) - } - } - } -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/readrequest_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/readrequest_test.go deleted file mode 100644 index ffdd6a892d..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/readrequest_test.go +++ /dev/null @@ -1,331 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http - -import ( - "bufio" - "bytes" - "fmt" - "io" - "net/url" - "reflect" - "testing" -) - -type reqTest struct { - Raw string - Req *Request - Body string - Trailer Header - Error string -} - -var noError = "" -var noBody = "" -var noTrailer Header = nil - -var reqTests = []reqTest{ - // Baseline test; All Request fields included for template use - { - "GET http://www.techcrunch.com/ HTTP/1.1\r\n" + - "Host: www.techcrunch.com\r\n" + - "User-Agent: Fake\r\n" + - "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" + - "Accept-Language: en-us,en;q=0.5\r\n" + - "Accept-Encoding: gzip,deflate\r\n" + - "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n" + - "Keep-Alive: 300\r\n" + - "Content-Length: 7\r\n" + - "Proxy-Connection: keep-alive\r\n\r\n" + - "abcdef\n???", - - &Request{ - Method: "GET", - URL: &url.URL{ - Scheme: "http", - Host: "www.techcrunch.com", - Path: "/", - }, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - Header: Header{ - "Accept": {"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"}, - "Accept-Language": {"en-us,en;q=0.5"}, - "Accept-Encoding": {"gzip,deflate"}, - "Accept-Charset": {"ISO-8859-1,utf-8;q=0.7,*;q=0.7"}, - "Keep-Alive": {"300"}, - "Proxy-Connection": {"keep-alive"}, - "Content-Length": {"7"}, - "User-Agent": {"Fake"}, - }, - Close: false, - ContentLength: 7, - Host: "www.techcrunch.com", - RequestURI: "http://www.techcrunch.com/", - }, - - "abcdef\n", - - noTrailer, - noError, - }, - - // GET request with no body (the normal case) - { - "GET / HTTP/1.1\r\n" + - "Host: foo.com\r\n\r\n", - - &Request{ - Method: "GET", - URL: &url.URL{ - Path: "/", - }, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - Header: Header{}, - Close: false, - ContentLength: 0, - Host: "foo.com", - RequestURI: "/", - }, - - noBody, - noTrailer, - noError, - }, - - // Tests that we don't parse a path that looks like a - // scheme-relative URI as a scheme-relative URI. - { - "GET //user@host/is/actually/a/path/ HTTP/1.1\r\n" + - "Host: test\r\n\r\n", - - &Request{ - Method: "GET", - URL: &url.URL{ - Path: "//user@host/is/actually/a/path/", - }, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - Header: Header{}, - Close: false, - ContentLength: 0, - Host: "test", - RequestURI: "//user@host/is/actually/a/path/", - }, - - noBody, - noTrailer, - noError, - }, - - // Tests a bogus abs_path on the Request-Line (RFC 2616 section 5.1.2) - { - "GET ../../../../etc/passwd HTTP/1.1\r\n" + - "Host: test\r\n\r\n", - nil, - noBody, - noTrailer, - "parse ../../../../etc/passwd: invalid URI for request", - }, - - // Tests missing URL: - { - "GET HTTP/1.1\r\n" + - "Host: test\r\n\r\n", - nil, - noBody, - noTrailer, - "parse : empty url", - }, - - // Tests chunked body with trailer: - { - "POST / HTTP/1.1\r\n" + - "Host: foo.com\r\n" + - "Transfer-Encoding: chunked\r\n\r\n" + - "3\r\nfoo\r\n" + - "3\r\nbar\r\n" + - "0\r\n" + - "Trailer-Key: Trailer-Value\r\n" + - "\r\n", - &Request{ - Method: "POST", - URL: &url.URL{ - Path: "/", - }, - TransferEncoding: []string{"chunked"}, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - Header: Header{}, - ContentLength: -1, - Host: "foo.com", - RequestURI: "/", - }, - - "foobar", - Header{ - "Trailer-Key": {"Trailer-Value"}, - }, - noError, - }, - - // CONNECT request with domain name: - { - "CONNECT www.google.com:443 HTTP/1.1\r\n\r\n", - - &Request{ - Method: "CONNECT", - URL: &url.URL{ - Host: "www.google.com:443", - }, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - Header: Header{}, - Close: false, - ContentLength: 0, - Host: "www.google.com:443", - RequestURI: "www.google.com:443", - }, - - noBody, - noTrailer, - noError, - }, - - // CONNECT request with IP address: - { - "CONNECT 127.0.0.1:6060 HTTP/1.1\r\n\r\n", - - &Request{ - Method: "CONNECT", - URL: &url.URL{ - Host: "127.0.0.1:6060", - }, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - Header: Header{}, - Close: false, - ContentLength: 0, - Host: "127.0.0.1:6060", - RequestURI: "127.0.0.1:6060", - }, - - noBody, - noTrailer, - noError, - }, - - // CONNECT request for RPC: - { - "CONNECT /_goRPC_ HTTP/1.1\r\n\r\n", - - &Request{ - Method: "CONNECT", - URL: &url.URL{ - Path: "/_goRPC_", - }, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - Header: Header{}, - Close: false, - ContentLength: 0, - Host: "", - RequestURI: "/_goRPC_", - }, - - noBody, - noTrailer, - noError, - }, - - // SSDP Notify request. golang.org/issue/3692 - { - "NOTIFY * HTTP/1.1\r\nServer: foo\r\n\r\n", - &Request{ - Method: "NOTIFY", - URL: &url.URL{ - Path: "*", - }, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - Header: Header{ - "Server": []string{"foo"}, - }, - Close: false, - ContentLength: 0, - RequestURI: "*", - }, - - noBody, - noTrailer, - noError, - }, - - // OPTIONS request. Similar to golang.org/issue/3692 - { - "OPTIONS * HTTP/1.1\r\nServer: foo\r\n\r\n", - &Request{ - Method: "OPTIONS", - URL: &url.URL{ - Path: "*", - }, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - Header: Header{ - "Server": []string{"foo"}, - }, - Close: false, - ContentLength: 0, - RequestURI: "*", - }, - - noBody, - noTrailer, - noError, - }, -} - -func TestReadRequest(t *testing.T) { - for i := range reqTests { - tt := &reqTests[i] - var braw bytes.Buffer - braw.WriteString(tt.Raw) - req, err := ReadRequest(bufio.NewReader(&braw)) - if err != nil { - if err.Error() != tt.Error { - t.Errorf("#%d: error %q, want error %q", i, err.Error(), tt.Error) - } - continue - } - rbody := req.Body - req.Body = nil - diff(t, fmt.Sprintf("#%d Request", i), req, tt.Req) - var bout bytes.Buffer - if rbody != nil { - _, err := io.Copy(&bout, rbody) - if err != nil { - t.Fatalf("#%d. copying body: %v", i, err) - } - rbody.Close() - } - body := bout.String() - if body != tt.Body { - t.Errorf("#%d: Body = %q want %q", i, body, tt.Body) - } - if !reflect.DeepEqual(tt.Trailer, req.Trailer) { - t.Errorf("#%d. Trailers differ.\n got: %v\nwant: %v", i, req.Trailer, tt.Trailer) - } - } -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/request_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/request_test.go deleted file mode 100644 index b9fa3c2bfc..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/request_test.go +++ /dev/null @@ -1,610 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http_test - -import ( - "bufio" - "bytes" - "fmt" - "io" - "io/ioutil" - "mime/multipart" - . "net/http" - "net/http/httptest" - "net/url" - "os" - "reflect" - "regexp" - "strings" - "testing" -) - -func TestQuery(t *testing.T) { - req := &Request{Method: "GET"} - req.URL, _ = url.Parse("http://www.google.com/search?q=foo&q=bar") - if q := req.FormValue("q"); q != "foo" { - t.Errorf(`req.FormValue("q") = %q, want "foo"`, q) - } -} - -func TestPostQuery(t *testing.T) { - req, _ := NewRequest("POST", "http://www.google.com/search?q=foo&q=bar&both=x&prio=1&empty=not", - strings.NewReader("z=post&both=y&prio=2&empty=")) - req.Header.Set("Content-Type", "application/x-www-form-urlencoded; param=value") - - if q := req.FormValue("q"); q != "foo" { - t.Errorf(`req.FormValue("q") = %q, want "foo"`, q) - } - if z := req.FormValue("z"); z != "post" { - t.Errorf(`req.FormValue("z") = %q, want "post"`, z) - } - if bq, found := req.PostForm["q"]; found { - t.Errorf(`req.PostForm["q"] = %q, want no entry in map`, bq) - } - if bz := req.PostFormValue("z"); bz != "post" { - t.Errorf(`req.PostFormValue("z") = %q, want "post"`, bz) - } - if qs := req.Form["q"]; !reflect.DeepEqual(qs, []string{"foo", "bar"}) { - t.Errorf(`req.Form["q"] = %q, want ["foo", "bar"]`, qs) - } - if both := req.Form["both"]; !reflect.DeepEqual(both, []string{"y", "x"}) { - t.Errorf(`req.Form["both"] = %q, want ["y", "x"]`, both) - } - if prio := req.FormValue("prio"); prio != "2" { - t.Errorf(`req.FormValue("prio") = %q, want "2" (from body)`, prio) - } - if empty := req.FormValue("empty"); empty != "" { - t.Errorf(`req.FormValue("empty") = %q, want "" (from body)`, empty) - } -} - -func TestPatchQuery(t *testing.T) { - req, _ := NewRequest("PATCH", "http://www.google.com/search?q=foo&q=bar&both=x&prio=1&empty=not", - strings.NewReader("z=post&both=y&prio=2&empty=")) - req.Header.Set("Content-Type", "application/x-www-form-urlencoded; param=value") - - if q := req.FormValue("q"); q != "foo" { - t.Errorf(`req.FormValue("q") = %q, want "foo"`, q) - } - if z := req.FormValue("z"); z != "post" { - t.Errorf(`req.FormValue("z") = %q, want "post"`, z) - } - if bq, found := req.PostForm["q"]; found { - t.Errorf(`req.PostForm["q"] = %q, want no entry in map`, bq) - } - if bz := req.PostFormValue("z"); bz != "post" { - t.Errorf(`req.PostFormValue("z") = %q, want "post"`, bz) - } - if qs := req.Form["q"]; !reflect.DeepEqual(qs, []string{"foo", "bar"}) { - t.Errorf(`req.Form["q"] = %q, want ["foo", "bar"]`, qs) - } - if both := req.Form["both"]; !reflect.DeepEqual(both, []string{"y", "x"}) { - t.Errorf(`req.Form["both"] = %q, want ["y", "x"]`, both) - } - if prio := req.FormValue("prio"); prio != "2" { - t.Errorf(`req.FormValue("prio") = %q, want "2" (from body)`, prio) - } - if empty := req.FormValue("empty"); empty != "" { - t.Errorf(`req.FormValue("empty") = %q, want "" (from body)`, empty) - } -} - -type stringMap map[string][]string -type parseContentTypeTest struct { - shouldError bool - contentType stringMap -} - -var parseContentTypeTests = []parseContentTypeTest{ - {false, stringMap{"Content-Type": {"text/plain"}}}, - // Empty content type is legal - shoult be treated as - // application/octet-stream (RFC 2616, section 7.2.1) - {false, stringMap{}}, - {true, stringMap{"Content-Type": {"text/plain; boundary="}}}, - {false, stringMap{"Content-Type": {"application/unknown"}}}, -} - -func TestParseFormUnknownContentType(t *testing.T) { - for i, test := range parseContentTypeTests { - req := &Request{ - Method: "POST", - Header: Header(test.contentType), - Body: ioutil.NopCloser(strings.NewReader("body")), - } - err := req.ParseForm() - switch { - case err == nil && test.shouldError: - t.Errorf("test %d should have returned error", i) - case err != nil && !test.shouldError: - t.Errorf("test %d should not have returned error, got %v", i, err) - } - } -} - -func TestParseFormInitializeOnError(t *testing.T) { - nilBody, _ := NewRequest("POST", "http://www.google.com/search?q=foo", nil) - tests := []*Request{ - nilBody, - {Method: "GET", URL: nil}, - } - for i, req := range tests { - err := req.ParseForm() - if req.Form == nil { - t.Errorf("%d. Form not initialized, error %v", i, err) - } - if req.PostForm == nil { - t.Errorf("%d. PostForm not initialized, error %v", i, err) - } - } -} - -func TestMultipartReader(t *testing.T) { - req := &Request{ - Method: "POST", - Header: Header{"Content-Type": {`multipart/form-data; boundary="foo123"`}}, - Body: ioutil.NopCloser(new(bytes.Buffer)), - } - multipart, err := req.MultipartReader() - if multipart == nil { - t.Errorf("expected multipart; error: %v", err) - } - - req.Header = Header{"Content-Type": {"text/plain"}} - multipart, err = req.MultipartReader() - if multipart != nil { - t.Error("unexpected multipart for text/plain") - } -} - -func TestParseMultipartForm(t *testing.T) { - req := &Request{ - Method: "POST", - Header: Header{"Content-Type": {`multipart/form-data; boundary="foo123"`}}, - Body: ioutil.NopCloser(new(bytes.Buffer)), - } - err := req.ParseMultipartForm(25) - if err == nil { - t.Error("expected multipart EOF, got nil") - } - - req.Header = Header{"Content-Type": {"text/plain"}} - err = req.ParseMultipartForm(25) - if err != ErrNotMultipart { - t.Error("expected ErrNotMultipart for text/plain") - } -} - -func TestRedirect(t *testing.T) { - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - switch r.URL.Path { - case "/": - w.Header().Set("Location", "/foo/") - w.WriteHeader(StatusSeeOther) - case "/foo/": - fmt.Fprintf(w, "foo") - default: - w.WriteHeader(StatusBadRequest) - } - })) - defer ts.Close() - - var end = regexp.MustCompile("/foo/$") - r, err := Get(ts.URL) - if err != nil { - t.Fatal(err) - } - r.Body.Close() - url := r.Request.URL.String() - if r.StatusCode != 200 || !end.MatchString(url) { - t.Fatalf("Get got status %d at %q, want 200 matching /foo/$", r.StatusCode, url) - } -} - -func TestSetBasicAuth(t *testing.T) { - r, _ := NewRequest("GET", "http://example.com/", nil) - r.SetBasicAuth("Aladdin", "open sesame") - if g, e := r.Header.Get("Authorization"), "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="; g != e { - t.Errorf("got header %q, want %q", g, e) - } -} - -func TestMultipartRequest(t *testing.T) { - // Test that we can read the values and files of a - // multipart request with FormValue and FormFile, - // and that ParseMultipartForm can be called multiple times. - req := newTestMultipartRequest(t) - if err := req.ParseMultipartForm(25); err != nil { - t.Fatal("ParseMultipartForm first call:", err) - } - defer req.MultipartForm.RemoveAll() - validateTestMultipartContents(t, req, false) - if err := req.ParseMultipartForm(25); err != nil { - t.Fatal("ParseMultipartForm second call:", err) - } - validateTestMultipartContents(t, req, false) -} - -func TestMultipartRequestAuto(t *testing.T) { - // Test that FormValue and FormFile automatically invoke - // ParseMultipartForm and return the right values. - req := newTestMultipartRequest(t) - defer func() { - if req.MultipartForm != nil { - req.MultipartForm.RemoveAll() - } - }() - validateTestMultipartContents(t, req, true) -} - -func TestMissingFileMultipartRequest(t *testing.T) { - // Test that FormFile returns an error if - // the named file is missing. - req := newTestMultipartRequest(t) - testMissingFile(t, req) -} - -// Test that FormValue invokes ParseMultipartForm. -func TestFormValueCallsParseMultipartForm(t *testing.T) { - req, _ := NewRequest("POST", "http://www.google.com/", strings.NewReader("z=post")) - req.Header.Set("Content-Type", "application/x-www-form-urlencoded; param=value") - if req.Form != nil { - t.Fatal("Unexpected request Form, want nil") - } - req.FormValue("z") - if req.Form == nil { - t.Fatal("ParseMultipartForm not called by FormValue") - } -} - -// Test that FormFile invokes ParseMultipartForm. -func TestFormFileCallsParseMultipartForm(t *testing.T) { - req := newTestMultipartRequest(t) - if req.Form != nil { - t.Fatal("Unexpected request Form, want nil") - } - req.FormFile("") - if req.Form == nil { - t.Fatal("ParseMultipartForm not called by FormFile") - } -} - -// Test that ParseMultipartForm errors if called -// after MultipartReader on the same request. -func TestParseMultipartFormOrder(t *testing.T) { - req := newTestMultipartRequest(t) - if _, err := req.MultipartReader(); err != nil { - t.Fatalf("MultipartReader: %v", err) - } - if err := req.ParseMultipartForm(1024); err == nil { - t.Fatal("expected an error from ParseMultipartForm after call to MultipartReader") - } -} - -// Test that MultipartReader errors if called -// after ParseMultipartForm on the same request. -func TestMultipartReaderOrder(t *testing.T) { - req := newTestMultipartRequest(t) - if err := req.ParseMultipartForm(25); err != nil { - t.Fatalf("ParseMultipartForm: %v", err) - } - defer req.MultipartForm.RemoveAll() - if _, err := req.MultipartReader(); err == nil { - t.Fatal("expected an error from MultipartReader after call to ParseMultipartForm") - } -} - -// Test that FormFile errors if called after -// MultipartReader on the same request. -func TestFormFileOrder(t *testing.T) { - req := newTestMultipartRequest(t) - if _, err := req.MultipartReader(); err != nil { - t.Fatalf("MultipartReader: %v", err) - } - if _, _, err := req.FormFile(""); err == nil { - t.Fatal("expected an error from FormFile after call to MultipartReader") - } -} - -var readRequestErrorTests = []struct { - in string - err error -}{ - {"GET / HTTP/1.1\r\nheader:foo\r\n\r\n", nil}, - {"GET / HTTP/1.1\r\nheader:foo\r\n", io.ErrUnexpectedEOF}, - {"", io.EOF}, -} - -func TestReadRequestErrors(t *testing.T) { - for i, tt := range readRequestErrorTests { - _, err := ReadRequest(bufio.NewReader(strings.NewReader(tt.in))) - if err != tt.err { - t.Errorf("%d. got error = %v; want %v", i, err, tt.err) - } - } -} - -func TestNewRequestHost(t *testing.T) { - req, err := NewRequest("GET", "http://localhost:1234/", nil) - if err != nil { - t.Fatal(err) - } - if req.Host != "localhost:1234" { - t.Errorf("Host = %q; want localhost:1234", req.Host) - } -} - -func TestNewRequestContentLength(t *testing.T) { - readByte := func(r io.Reader) io.Reader { - var b [1]byte - r.Read(b[:]) - return r - } - tests := []struct { - r io.Reader - want int64 - }{ - {bytes.NewReader([]byte("123")), 3}, - {bytes.NewBuffer([]byte("1234")), 4}, - {strings.NewReader("12345"), 5}, - // Not detected: - {struct{ io.Reader }{strings.NewReader("xyz")}, 0}, - {io.NewSectionReader(strings.NewReader("x"), 0, 6), 0}, - {readByte(io.NewSectionReader(strings.NewReader("xy"), 0, 6)), 0}, - } - for _, tt := range tests { - req, err := NewRequest("POST", "http://localhost/", tt.r) - if err != nil { - t.Fatal(err) - } - if req.ContentLength != tt.want { - t.Errorf("ContentLength(%T) = %d; want %d", tt.r, req.ContentLength, tt.want) - } - } -} - -var parseHTTPVersionTests = []struct { - vers string - major, minor int - ok bool -}{ - {"HTTP/0.9", 0, 9, true}, - {"HTTP/1.0", 1, 0, true}, - {"HTTP/1.1", 1, 1, true}, - {"HTTP/3.14", 3, 14, true}, - - {"HTTP", 0, 0, false}, - {"HTTP/one.one", 0, 0, false}, - {"HTTP/1.1/", 0, 0, false}, - {"HTTP/-1,0", 0, 0, false}, - {"HTTP/0,-1", 0, 0, false}, - {"HTTP/", 0, 0, false}, - {"HTTP/1,1", 0, 0, false}, -} - -func TestParseHTTPVersion(t *testing.T) { - for _, tt := range parseHTTPVersionTests { - major, minor, ok := ParseHTTPVersion(tt.vers) - if ok != tt.ok || major != tt.major || minor != tt.minor { - type version struct { - major, minor int - ok bool - } - t.Errorf("failed to parse %q, expected: %#v, got %#v", tt.vers, version{tt.major, tt.minor, tt.ok}, version{major, minor, ok}) - } - } -} - -type logWrites struct { - t *testing.T - dst *[]string -} - -func (l logWrites) WriteByte(c byte) error { - l.t.Fatalf("unexpected WriteByte call") - return nil -} - -func (l logWrites) Write(p []byte) (n int, err error) { - *l.dst = append(*l.dst, string(p)) - return len(p), nil -} - -func TestRequestWriteBufferedWriter(t *testing.T) { - got := []string{} - req, _ := NewRequest("GET", "http://foo.com/", nil) - req.Write(logWrites{t, &got}) - want := []string{ - "GET / HTTP/1.1\r\n", - "Host: foo.com\r\n", - "User-Agent: " + DefaultUserAgent + "\r\n", - "\r\n", - } - if !reflect.DeepEqual(got, want) { - t.Errorf("Writes = %q\n Want = %q", got, want) - } -} - -func testMissingFile(t *testing.T, req *Request) { - f, fh, err := req.FormFile("missing") - if f != nil { - t.Errorf("FormFile file = %v, want nil", f) - } - if fh != nil { - t.Errorf("FormFile file header = %q, want nil", fh) - } - if err != ErrMissingFile { - t.Errorf("FormFile err = %q, want ErrMissingFile", err) - } -} - -func newTestMultipartRequest(t *testing.T) *Request { - b := strings.NewReader(strings.Replace(message, "\n", "\r\n", -1)) - req, err := NewRequest("POST", "/", b) - if err != nil { - t.Fatal("NewRequest:", err) - } - ctype := fmt.Sprintf(`multipart/form-data; boundary="%s"`, boundary) - req.Header.Set("Content-type", ctype) - return req -} - -func validateTestMultipartContents(t *testing.T, req *Request, allMem bool) { - if g, e := req.FormValue("texta"), textaValue; g != e { - t.Errorf("texta value = %q, want %q", g, e) - } - if g, e := req.FormValue("textb"), textbValue; g != e { - t.Errorf("textb value = %q, want %q", g, e) - } - if g := req.FormValue("missing"); g != "" { - t.Errorf("missing value = %q, want empty string", g) - } - - assertMem := func(n string, fd multipart.File) { - if _, ok := fd.(*os.File); ok { - t.Error(n, " is *os.File, should not be") - } - } - fda := testMultipartFile(t, req, "filea", "filea.txt", fileaContents) - defer fda.Close() - assertMem("filea", fda) - fdb := testMultipartFile(t, req, "fileb", "fileb.txt", filebContents) - defer fdb.Close() - if allMem { - assertMem("fileb", fdb) - } else { - if _, ok := fdb.(*os.File); !ok { - t.Errorf("fileb has unexpected underlying type %T", fdb) - } - } - - testMissingFile(t, req) -} - -func testMultipartFile(t *testing.T, req *Request, key, expectFilename, expectContent string) multipart.File { - f, fh, err := req.FormFile(key) - if err != nil { - t.Fatalf("FormFile(%q): %q", key, err) - } - if fh.Filename != expectFilename { - t.Errorf("filename = %q, want %q", fh.Filename, expectFilename) - } - var b bytes.Buffer - _, err = io.Copy(&b, f) - if err != nil { - t.Fatal("copying contents:", err) - } - if g := b.String(); g != expectContent { - t.Errorf("contents = %q, want %q", g, expectContent) - } - return f -} - -const ( - fileaContents = "This is a test file." - filebContents = "Another test file." - textaValue = "foo" - textbValue = "bar" - boundary = `MyBoundary` -) - -const message = ` ---MyBoundary -Content-Disposition: form-data; name="filea"; filename="filea.txt" -Content-Type: text/plain - -` + fileaContents + ` ---MyBoundary -Content-Disposition: form-data; name="fileb"; filename="fileb.txt" -Content-Type: text/plain - -` + filebContents + ` ---MyBoundary -Content-Disposition: form-data; name="texta" - -` + textaValue + ` ---MyBoundary -Content-Disposition: form-data; name="textb" - -` + textbValue + ` ---MyBoundary-- -` - -func benchmarkReadRequest(b *testing.B, request string) { - request = request + "\n" // final \n - request = strings.Replace(request, "\n", "\r\n", -1) // expand \n to \r\n - b.SetBytes(int64(len(request))) - r := bufio.NewReader(&infiniteReader{buf: []byte(request)}) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, err := ReadRequest(r) - if err != nil { - b.Fatalf("failed to read request: %v", err) - } - } -} - -// infiniteReader satisfies Read requests as if the contents of buf -// loop indefinitely. -type infiniteReader struct { - buf []byte - offset int -} - -func (r *infiniteReader) Read(b []byte) (int, error) { - n := copy(b, r.buf[r.offset:]) - r.offset = (r.offset + n) % len(r.buf) - return n, nil -} - -func BenchmarkReadRequestChrome(b *testing.B) { - // https://github.com/felixge/node-http-perf/blob/master/fixtures/get.http - benchmarkReadRequest(b, `GET / HTTP/1.1 -Host: localhost:8080 -Connection: keep-alive -Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 -User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17 -Accept-Encoding: gzip,deflate,sdch -Accept-Language: en-US,en;q=0.8 -Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 -Cookie: __utma=1.1978842379.1323102373.1323102373.1323102373.1; EPi:NumberOfVisits=1,2012-02-28T13:42:18; CrmSession=5b707226b9563e1bc69084d07a107c98; plushContainerWidth=100%25; plushNoTopMenu=0; hudson_auto_refresh=false -`) -} - -func BenchmarkReadRequestCurl(b *testing.B) { - // curl http://localhost:8080/ - benchmarkReadRequest(b, `GET / HTTP/1.1 -User-Agent: curl/7.27.0 -Host: localhost:8080 -Accept: */* -`) -} - -func BenchmarkReadRequestApachebench(b *testing.B) { - // ab -n 1 -c 1 http://localhost:8080/ - benchmarkReadRequest(b, `GET / HTTP/1.0 -Host: localhost:8080 -User-Agent: ApacheBench/2.3 -Accept: */* -`) -} - -func BenchmarkReadRequestSiege(b *testing.B) { - // siege -r 1 -c 1 http://localhost:8080/ - benchmarkReadRequest(b, `GET / HTTP/1.1 -Host: localhost:8080 -Accept: */* -Accept-Encoding: gzip -User-Agent: JoeDog/1.00 [en] (X11; I; Siege 2.70) -Connection: keep-alive -`) -} - -func BenchmarkReadRequestWrk(b *testing.B) { - // wrk -t 1 -r 1 -c 1 http://localhost:8080/ - benchmarkReadRequest(b, `GET / HTTP/1.1 -Host: localhost:8080 -`) -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/requestwrite_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/requestwrite_test.go deleted file mode 100644 index dc0e204cac..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/requestwrite_test.go +++ /dev/null @@ -1,565 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http - -import ( - "bytes" - "errors" - "fmt" - "io" - "io/ioutil" - "net/url" - "strings" - "testing" -) - -type reqWriteTest struct { - Req Request - Body interface{} // optional []byte or func() io.ReadCloser to populate Req.Body - - // Any of these three may be empty to skip that test. - WantWrite string // Request.Write - WantProxy string // Request.WriteProxy - - WantError error // wanted error from Request.Write -} - -var reqWriteTests = []reqWriteTest{ - // HTTP/1.1 => chunked coding; no body; no trailer - { - Req: Request{ - Method: "GET", - URL: &url.URL{ - Scheme: "http", - Host: "www.techcrunch.com", - Path: "/", - }, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - Header: Header{ - "Accept": {"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"}, - "Accept-Charset": {"ISO-8859-1,utf-8;q=0.7,*;q=0.7"}, - "Accept-Encoding": {"gzip,deflate"}, - "Accept-Language": {"en-us,en;q=0.5"}, - "Keep-Alive": {"300"}, - "Proxy-Connection": {"keep-alive"}, - "User-Agent": {"Fake"}, - }, - Body: nil, - Close: false, - Host: "www.techcrunch.com", - Form: map[string][]string{}, - }, - - WantWrite: "GET / HTTP/1.1\r\n" + - "Host: www.techcrunch.com\r\n" + - "User-Agent: Fake\r\n" + - "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" + - "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n" + - "Accept-Encoding: gzip,deflate\r\n" + - "Accept-Language: en-us,en;q=0.5\r\n" + - "Keep-Alive: 300\r\n" + - "Proxy-Connection: keep-alive\r\n\r\n", - - WantProxy: "GET http://www.techcrunch.com/ HTTP/1.1\r\n" + - "Host: www.techcrunch.com\r\n" + - "User-Agent: Fake\r\n" + - "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" + - "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n" + - "Accept-Encoding: gzip,deflate\r\n" + - "Accept-Language: en-us,en;q=0.5\r\n" + - "Keep-Alive: 300\r\n" + - "Proxy-Connection: keep-alive\r\n\r\n", - }, - // HTTP/1.1 => chunked coding; body; empty trailer - { - Req: Request{ - Method: "GET", - URL: &url.URL{ - Scheme: "http", - Host: "www.google.com", - Path: "/search", - }, - ProtoMajor: 1, - ProtoMinor: 1, - Header: Header{}, - TransferEncoding: []string{"chunked"}, - }, - - Body: []byte("abcdef"), - - WantWrite: "GET /search HTTP/1.1\r\n" + - "Host: www.google.com\r\n" + - "User-Agent: Go 1.1 package http\r\n" + - "Transfer-Encoding: chunked\r\n\r\n" + - chunk("abcdef") + chunk(""), - - WantProxy: "GET http://www.google.com/search HTTP/1.1\r\n" + - "Host: www.google.com\r\n" + - "User-Agent: Go 1.1 package http\r\n" + - "Transfer-Encoding: chunked\r\n\r\n" + - chunk("abcdef") + chunk(""), - }, - // HTTP/1.1 POST => chunked coding; body; empty trailer - { - Req: Request{ - Method: "POST", - URL: &url.URL{ - Scheme: "http", - Host: "www.google.com", - Path: "/search", - }, - ProtoMajor: 1, - ProtoMinor: 1, - Header: Header{}, - Close: true, - TransferEncoding: []string{"chunked"}, - }, - - Body: []byte("abcdef"), - - WantWrite: "POST /search HTTP/1.1\r\n" + - "Host: www.google.com\r\n" + - "User-Agent: Go 1.1 package http\r\n" + - "Connection: close\r\n" + - "Transfer-Encoding: chunked\r\n\r\n" + - chunk("abcdef") + chunk(""), - - WantProxy: "POST http://www.google.com/search HTTP/1.1\r\n" + - "Host: www.google.com\r\n" + - "User-Agent: Go 1.1 package http\r\n" + - "Connection: close\r\n" + - "Transfer-Encoding: chunked\r\n\r\n" + - chunk("abcdef") + chunk(""), - }, - - // HTTP/1.1 POST with Content-Length, no chunking - { - Req: Request{ - Method: "POST", - URL: &url.URL{ - Scheme: "http", - Host: "www.google.com", - Path: "/search", - }, - ProtoMajor: 1, - ProtoMinor: 1, - Header: Header{}, - Close: true, - ContentLength: 6, - }, - - Body: []byte("abcdef"), - - WantWrite: "POST /search HTTP/1.1\r\n" + - "Host: www.google.com\r\n" + - "User-Agent: Go 1.1 package http\r\n" + - "Connection: close\r\n" + - "Content-Length: 6\r\n" + - "\r\n" + - "abcdef", - - WantProxy: "POST http://www.google.com/search HTTP/1.1\r\n" + - "Host: www.google.com\r\n" + - "User-Agent: Go 1.1 package http\r\n" + - "Connection: close\r\n" + - "Content-Length: 6\r\n" + - "\r\n" + - "abcdef", - }, - - // HTTP/1.1 POST with Content-Length in headers - { - Req: Request{ - Method: "POST", - URL: mustParseURL("http://example.com/"), - Host: "example.com", - Header: Header{ - "Content-Length": []string{"10"}, // ignored - }, - ContentLength: 6, - }, - - Body: []byte("abcdef"), - - WantWrite: "POST / HTTP/1.1\r\n" + - "Host: example.com\r\n" + - "User-Agent: Go 1.1 package http\r\n" + - "Content-Length: 6\r\n" + - "\r\n" + - "abcdef", - - WantProxy: "POST http://example.com/ HTTP/1.1\r\n" + - "Host: example.com\r\n" + - "User-Agent: Go 1.1 package http\r\n" + - "Content-Length: 6\r\n" + - "\r\n" + - "abcdef", - }, - - // default to HTTP/1.1 - { - Req: Request{ - Method: "GET", - URL: mustParseURL("/search"), - Host: "www.google.com", - }, - - WantWrite: "GET /search HTTP/1.1\r\n" + - "Host: www.google.com\r\n" + - "User-Agent: Go 1.1 package http\r\n" + - "\r\n", - }, - - // Request with a 0 ContentLength and a 0 byte body. - { - Req: Request{ - Method: "POST", - URL: mustParseURL("/"), - Host: "example.com", - ProtoMajor: 1, - ProtoMinor: 1, - ContentLength: 0, // as if unset by user - }, - - Body: func() io.ReadCloser { return ioutil.NopCloser(io.LimitReader(strings.NewReader("xx"), 0)) }, - - // RFC 2616 Section 14.13 says Content-Length should be specified - // unless body is prohibited by the request method. - // Also, nginx expects it for POST and PUT. - WantWrite: "POST / HTTP/1.1\r\n" + - "Host: example.com\r\n" + - "User-Agent: Go 1.1 package http\r\n" + - "Content-Length: 0\r\n" + - "\r\n", - - WantProxy: "POST / HTTP/1.1\r\n" + - "Host: example.com\r\n" + - "User-Agent: Go 1.1 package http\r\n" + - "Content-Length: 0\r\n" + - "\r\n", - }, - - // Request with a 0 ContentLength and a 1 byte body. - { - Req: Request{ - Method: "POST", - URL: mustParseURL("/"), - Host: "example.com", - ProtoMajor: 1, - ProtoMinor: 1, - ContentLength: 0, // as if unset by user - }, - - Body: func() io.ReadCloser { return ioutil.NopCloser(io.LimitReader(strings.NewReader("xx"), 1)) }, - - WantWrite: "POST / HTTP/1.1\r\n" + - "Host: example.com\r\n" + - "User-Agent: Go 1.1 package http\r\n" + - "Transfer-Encoding: chunked\r\n\r\n" + - chunk("x") + chunk(""), - - WantProxy: "POST / HTTP/1.1\r\n" + - "Host: example.com\r\n" + - "User-Agent: Go 1.1 package http\r\n" + - "Transfer-Encoding: chunked\r\n\r\n" + - chunk("x") + chunk(""), - }, - - // Request with a ContentLength of 10 but a 5 byte body. - { - Req: Request{ - Method: "POST", - URL: mustParseURL("/"), - Host: "example.com", - ProtoMajor: 1, - ProtoMinor: 1, - ContentLength: 10, // but we're going to send only 5 bytes - }, - Body: []byte("12345"), - WantError: errors.New("http: Request.ContentLength=10 with Body length 5"), - }, - - // Request with a ContentLength of 4 but an 8 byte body. - { - Req: Request{ - Method: "POST", - URL: mustParseURL("/"), - Host: "example.com", - ProtoMajor: 1, - ProtoMinor: 1, - ContentLength: 4, // but we're going to try to send 8 bytes - }, - Body: []byte("12345678"), - WantError: errors.New("http: Request.ContentLength=4 with Body length 8"), - }, - - // Request with a 5 ContentLength and nil body. - { - Req: Request{ - Method: "POST", - URL: mustParseURL("/"), - Host: "example.com", - ProtoMajor: 1, - ProtoMinor: 1, - ContentLength: 5, // but we'll omit the body - }, - WantError: errors.New("http: Request.ContentLength=5 with nil Body"), - }, - - // Request with a 0 ContentLength and a body with 1 byte content and an error. - { - Req: Request{ - Method: "POST", - URL: mustParseURL("/"), - Host: "example.com", - ProtoMajor: 1, - ProtoMinor: 1, - ContentLength: 0, // as if unset by user - }, - - Body: func() io.ReadCloser { - err := errors.New("Custom reader error") - errReader := &errorReader{err} - return ioutil.NopCloser(io.MultiReader(strings.NewReader("x"), errReader)) - }, - - WantError: errors.New("Custom reader error"), - }, - - // Request with a 0 ContentLength and a body without content and an error. - { - Req: Request{ - Method: "POST", - URL: mustParseURL("/"), - Host: "example.com", - ProtoMajor: 1, - ProtoMinor: 1, - ContentLength: 0, // as if unset by user - }, - - Body: func() io.ReadCloser { - err := errors.New("Custom reader error") - errReader := &errorReader{err} - return ioutil.NopCloser(errReader) - }, - - WantError: errors.New("Custom reader error"), - }, - - // Verify that DumpRequest preserves the HTTP version number, doesn't add a Host, - // and doesn't add a User-Agent. - { - Req: Request{ - Method: "GET", - URL: mustParseURL("/foo"), - ProtoMajor: 1, - ProtoMinor: 0, - Header: Header{ - "X-Foo": []string{"X-Bar"}, - }, - }, - - WantWrite: "GET /foo HTTP/1.1\r\n" + - "Host: \r\n" + - "User-Agent: Go 1.1 package http\r\n" + - "X-Foo: X-Bar\r\n\r\n", - }, - - // If no Request.Host and no Request.URL.Host, we send - // an empty Host header, and don't use - // Request.Header["Host"]. This is just testing that - // we don't change Go 1.0 behavior. - { - Req: Request{ - Method: "GET", - Host: "", - URL: &url.URL{ - Scheme: "http", - Host: "", - Path: "/search", - }, - ProtoMajor: 1, - ProtoMinor: 1, - Header: Header{ - "Host": []string{"bad.example.com"}, - }, - }, - - WantWrite: "GET /search HTTP/1.1\r\n" + - "Host: \r\n" + - "User-Agent: Go 1.1 package http\r\n\r\n", - }, - - // Opaque test #1 from golang.org/issue/4860 - { - Req: Request{ - Method: "GET", - URL: &url.URL{ - Scheme: "http", - Host: "www.google.com", - Opaque: "/%2F/%2F/", - }, - ProtoMajor: 1, - ProtoMinor: 1, - Header: Header{}, - }, - - WantWrite: "GET /%2F/%2F/ HTTP/1.1\r\n" + - "Host: www.google.com\r\n" + - "User-Agent: Go 1.1 package http\r\n\r\n", - }, - - // Opaque test #2 from golang.org/issue/4860 - { - Req: Request{ - Method: "GET", - URL: &url.URL{ - Scheme: "http", - Host: "x.google.com", - Opaque: "//y.google.com/%2F/%2F/", - }, - ProtoMajor: 1, - ProtoMinor: 1, - Header: Header{}, - }, - - WantWrite: "GET http://y.google.com/%2F/%2F/ HTTP/1.1\r\n" + - "Host: x.google.com\r\n" + - "User-Agent: Go 1.1 package http\r\n\r\n", - }, - - // Testing custom case in header keys. Issue 5022. - { - Req: Request{ - Method: "GET", - URL: &url.URL{ - Scheme: "http", - Host: "www.google.com", - Path: "/", - }, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - Header: Header{ - "ALL-CAPS": {"x"}, - }, - }, - - WantWrite: "GET / HTTP/1.1\r\n" + - "Host: www.google.com\r\n" + - "User-Agent: Go 1.1 package http\r\n" + - "ALL-CAPS: x\r\n" + - "\r\n", - }, -} - -func TestRequestWrite(t *testing.T) { - for i := range reqWriteTests { - tt := &reqWriteTests[i] - - setBody := func() { - if tt.Body == nil { - return - } - switch b := tt.Body.(type) { - case []byte: - tt.Req.Body = ioutil.NopCloser(bytes.NewReader(b)) - case func() io.ReadCloser: - tt.Req.Body = b() - } - } - setBody() - if tt.Req.Header == nil { - tt.Req.Header = make(Header) - } - - var braw bytes.Buffer - err := tt.Req.Write(&braw) - if g, e := fmt.Sprintf("%v", err), fmt.Sprintf("%v", tt.WantError); g != e { - t.Errorf("writing #%d, err = %q, want %q", i, g, e) - continue - } - if err != nil { - continue - } - - if tt.WantWrite != "" { - sraw := braw.String() - if sraw != tt.WantWrite { - t.Errorf("Test %d, expecting:\n%s\nGot:\n%s\n", i, tt.WantWrite, sraw) - continue - } - } - - if tt.WantProxy != "" { - setBody() - var praw bytes.Buffer - err = tt.Req.WriteProxy(&praw) - if err != nil { - t.Errorf("WriteProxy #%d: %s", i, err) - continue - } - sraw := praw.String() - if sraw != tt.WantProxy { - t.Errorf("Test Proxy %d, expecting:\n%s\nGot:\n%s\n", i, tt.WantProxy, sraw) - continue - } - } - } -} - -type closeChecker struct { - io.Reader - closed bool -} - -func (rc *closeChecker) Close() error { - rc.closed = true - return nil -} - -// TestRequestWriteClosesBody tests that Request.Write does close its request.Body. -// It also indirectly tests NewRequest and that it doesn't wrap an existing Closer -// inside a NopCloser, and that it serializes it correctly. -func TestRequestWriteClosesBody(t *testing.T) { - rc := &closeChecker{Reader: strings.NewReader("my body")} - req, _ := NewRequest("POST", "http://foo.com/", rc) - if req.ContentLength != 0 { - t.Errorf("got req.ContentLength %d, want 0", req.ContentLength) - } - buf := new(bytes.Buffer) - req.Write(buf) - if !rc.closed { - t.Error("body not closed after write") - } - expected := "POST / HTTP/1.1\r\n" + - "Host: foo.com\r\n" + - "User-Agent: Go 1.1 package http\r\n" + - "Transfer-Encoding: chunked\r\n\r\n" + - // TODO: currently we don't buffer before chunking, so we get a - // single "m" chunk before the other chunks, as this was the 1-byte - // read from our MultiReader where we stiched the Body back together - // after sniffing whether the Body was 0 bytes or not. - chunk("m") + - chunk("y body") + - chunk("") - if buf.String() != expected { - t.Errorf("write:\n got: %s\nwant: %s", buf.String(), expected) - } -} - -func chunk(s string) string { - return fmt.Sprintf("%x\r\n%s\r\n", len(s), s) -} - -func mustParseURL(s string) *url.URL { - u, err := url.Parse(s) - if err != nil { - panic(fmt.Sprintf("Error parsing URL %q: %v", s, err)) - } - return u -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/response_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/response_test.go deleted file mode 100644 index 4b8946f7ae..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/response_test.go +++ /dev/null @@ -1,645 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http - -import ( - "bufio" - "bytes" - "compress/gzip" - "crypto/rand" - "fmt" - "io" - "io/ioutil" - "net/url" - "reflect" - "regexp" - "strings" - "testing" -) - -type respTest struct { - Raw string - Resp Response - Body string -} - -func dummyReq(method string) *Request { - return &Request{Method: method} -} - -func dummyReq11(method string) *Request { - return &Request{Method: method, Proto: "HTTP/1.1", ProtoMajor: 1, ProtoMinor: 1} -} - -var respTests = []respTest{ - // Unchunked response without Content-Length. - { - "HTTP/1.0 200 OK\r\n" + - "Connection: close\r\n" + - "\r\n" + - "Body here\n", - - Response{ - Status: "200 OK", - StatusCode: 200, - Proto: "HTTP/1.0", - ProtoMajor: 1, - ProtoMinor: 0, - Request: dummyReq("GET"), - Header: Header{ - "Connection": {"close"}, // TODO(rsc): Delete? - }, - Close: true, - ContentLength: -1, - }, - - "Body here\n", - }, - - // Unchunked HTTP/1.1 response without Content-Length or - // Connection headers. - { - "HTTP/1.1 200 OK\r\n" + - "\r\n" + - "Body here\n", - - Response{ - Status: "200 OK", - StatusCode: 200, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - Header: Header{}, - Request: dummyReq("GET"), - Close: true, - ContentLength: -1, - }, - - "Body here\n", - }, - - // Unchunked HTTP/1.1 204 response without Content-Length. - { - "HTTP/1.1 204 No Content\r\n" + - "\r\n" + - "Body should not be read!\n", - - Response{ - Status: "204 No Content", - StatusCode: 204, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - Header: Header{}, - Request: dummyReq("GET"), - Close: false, - ContentLength: 0, - }, - - "", - }, - - // Unchunked response with Content-Length. - { - "HTTP/1.0 200 OK\r\n" + - "Content-Length: 10\r\n" + - "Connection: close\r\n" + - "\r\n" + - "Body here\n", - - Response{ - Status: "200 OK", - StatusCode: 200, - Proto: "HTTP/1.0", - ProtoMajor: 1, - ProtoMinor: 0, - Request: dummyReq("GET"), - Header: Header{ - "Connection": {"close"}, - "Content-Length": {"10"}, - }, - Close: true, - ContentLength: 10, - }, - - "Body here\n", - }, - - // Chunked response without Content-Length. - { - "HTTP/1.1 200 OK\r\n" + - "Transfer-Encoding: chunked\r\n" + - "\r\n" + - "0a\r\n" + - "Body here\n\r\n" + - "09\r\n" + - "continued\r\n" + - "0\r\n" + - "\r\n", - - Response{ - Status: "200 OK", - StatusCode: 200, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - Request: dummyReq("GET"), - Header: Header{}, - Close: false, - ContentLength: -1, - TransferEncoding: []string{"chunked"}, - }, - - "Body here\ncontinued", - }, - - // Chunked response with Content-Length. - { - "HTTP/1.1 200 OK\r\n" + - "Transfer-Encoding: chunked\r\n" + - "Content-Length: 10\r\n" + - "\r\n" + - "0a\r\n" + - "Body here\n\r\n" + - "0\r\n" + - "\r\n", - - Response{ - Status: "200 OK", - StatusCode: 200, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - Request: dummyReq("GET"), - Header: Header{}, - Close: false, - ContentLength: -1, - TransferEncoding: []string{"chunked"}, - }, - - "Body here\n", - }, - - // Chunked response in response to a HEAD request - { - "HTTP/1.1 200 OK\r\n" + - "Transfer-Encoding: chunked\r\n" + - "\r\n", - - Response{ - Status: "200 OK", - StatusCode: 200, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - Request: dummyReq("HEAD"), - Header: Header{}, - TransferEncoding: []string{"chunked"}, - Close: false, - ContentLength: -1, - }, - - "", - }, - - // Content-Length in response to a HEAD request - { - "HTTP/1.0 200 OK\r\n" + - "Content-Length: 256\r\n" + - "\r\n", - - Response{ - Status: "200 OK", - StatusCode: 200, - Proto: "HTTP/1.0", - ProtoMajor: 1, - ProtoMinor: 0, - Request: dummyReq("HEAD"), - Header: Header{"Content-Length": {"256"}}, - TransferEncoding: nil, - Close: true, - ContentLength: 256, - }, - - "", - }, - - // Content-Length in response to a HEAD request with HTTP/1.1 - { - "HTTP/1.1 200 OK\r\n" + - "Content-Length: 256\r\n" + - "\r\n", - - Response{ - Status: "200 OK", - StatusCode: 200, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - Request: dummyReq("HEAD"), - Header: Header{"Content-Length": {"256"}}, - TransferEncoding: nil, - Close: false, - ContentLength: 256, - }, - - "", - }, - - // No Content-Length or Chunked in response to a HEAD request - { - "HTTP/1.0 200 OK\r\n" + - "\r\n", - - Response{ - Status: "200 OK", - StatusCode: 200, - Proto: "HTTP/1.0", - ProtoMajor: 1, - ProtoMinor: 0, - Request: dummyReq("HEAD"), - Header: Header{}, - TransferEncoding: nil, - Close: true, - ContentLength: -1, - }, - - "", - }, - - // explicit Content-Length of 0. - { - "HTTP/1.1 200 OK\r\n" + - "Content-Length: 0\r\n" + - "\r\n", - - Response{ - Status: "200 OK", - StatusCode: 200, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - Request: dummyReq("GET"), - Header: Header{ - "Content-Length": {"0"}, - }, - Close: false, - ContentLength: 0, - }, - - "", - }, - - // Status line without a Reason-Phrase, but trailing space. - // (permitted by RFC 2616) - { - "HTTP/1.0 303 \r\n\r\n", - Response{ - Status: "303 ", - StatusCode: 303, - Proto: "HTTP/1.0", - ProtoMajor: 1, - ProtoMinor: 0, - Request: dummyReq("GET"), - Header: Header{}, - Close: true, - ContentLength: -1, - }, - - "", - }, - - // Status line without a Reason-Phrase, and no trailing space. - // (not permitted by RFC 2616, but we'll accept it anyway) - { - "HTTP/1.0 303\r\n\r\n", - Response{ - Status: "303 ", - StatusCode: 303, - Proto: "HTTP/1.0", - ProtoMajor: 1, - ProtoMinor: 0, - Request: dummyReq("GET"), - Header: Header{}, - Close: true, - ContentLength: -1, - }, - - "", - }, - - // golang.org/issue/4767: don't special-case multipart/byteranges responses - { - `HTTP/1.1 206 Partial Content -Connection: close -Content-Type: multipart/byteranges; boundary=18a75608c8f47cef - -some body`, - Response{ - Status: "206 Partial Content", - StatusCode: 206, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - Request: dummyReq("GET"), - Header: Header{ - "Content-Type": []string{"multipart/byteranges; boundary=18a75608c8f47cef"}, - }, - Close: true, - ContentLength: -1, - }, - - "some body", - }, - - // Unchunked response without Content-Length, Request is nil - { - "HTTP/1.0 200 OK\r\n" + - "Connection: close\r\n" + - "\r\n" + - "Body here\n", - - Response{ - Status: "200 OK", - StatusCode: 200, - Proto: "HTTP/1.0", - ProtoMajor: 1, - ProtoMinor: 0, - Header: Header{ - "Connection": {"close"}, // TODO(rsc): Delete? - }, - Close: true, - ContentLength: -1, - }, - - "Body here\n", - }, -} - -func TestReadResponse(t *testing.T) { - for i, tt := range respTests { - resp, err := ReadResponse(bufio.NewReader(strings.NewReader(tt.Raw)), tt.Resp.Request) - if err != nil { - t.Errorf("#%d: %v", i, err) - continue - } - rbody := resp.Body - resp.Body = nil - diff(t, fmt.Sprintf("#%d Response", i), resp, &tt.Resp) - var bout bytes.Buffer - if rbody != nil { - _, err = io.Copy(&bout, rbody) - if err != nil { - t.Errorf("#%d: %v", i, err) - continue - } - rbody.Close() - } - body := bout.String() - if body != tt.Body { - t.Errorf("#%d: Body = %q want %q", i, body, tt.Body) - } - } -} - -func TestWriteResponse(t *testing.T) { - for i, tt := range respTests { - resp, err := ReadResponse(bufio.NewReader(strings.NewReader(tt.Raw)), tt.Resp.Request) - if err != nil { - t.Errorf("#%d: %v", i, err) - continue - } - err = resp.Write(ioutil.Discard) - if err != nil { - t.Errorf("#%d: %v", i, err) - continue - } - } -} - -var readResponseCloseInMiddleTests = []struct { - chunked, compressed bool -}{ - {false, false}, - {true, false}, - {true, true}, -} - -// TestReadResponseCloseInMiddle tests that closing a body after -// reading only part of its contents advances the read to the end of -// the request, right up until the next request. -func TestReadResponseCloseInMiddle(t *testing.T) { - for _, test := range readResponseCloseInMiddleTests { - fatalf := func(format string, args ...interface{}) { - args = append([]interface{}{test.chunked, test.compressed}, args...) - t.Fatalf("on test chunked=%v, compressed=%v: "+format, args...) - } - checkErr := func(err error, msg string) { - if err == nil { - return - } - fatalf(msg+": %v", err) - } - var buf bytes.Buffer - buf.WriteString("HTTP/1.1 200 OK\r\n") - if test.chunked { - buf.WriteString("Transfer-Encoding: chunked\r\n") - } else { - buf.WriteString("Content-Length: 1000000\r\n") - } - var wr io.Writer = &buf - if test.chunked { - wr = newChunkedWriter(wr) - } - if test.compressed { - buf.WriteString("Content-Encoding: gzip\r\n") - wr = gzip.NewWriter(wr) - } - buf.WriteString("\r\n") - - chunk := bytes.Repeat([]byte{'x'}, 1000) - for i := 0; i < 1000; i++ { - if test.compressed { - // Otherwise this compresses too well. - _, err := io.ReadFull(rand.Reader, chunk) - checkErr(err, "rand.Reader ReadFull") - } - wr.Write(chunk) - } - if test.compressed { - err := wr.(*gzip.Writer).Close() - checkErr(err, "compressor close") - } - if test.chunked { - buf.WriteString("0\r\n\r\n") - } - buf.WriteString("Next Request Here") - - bufr := bufio.NewReader(&buf) - resp, err := ReadResponse(bufr, dummyReq("GET")) - checkErr(err, "ReadResponse") - expectedLength := int64(-1) - if !test.chunked { - expectedLength = 1000000 - } - if resp.ContentLength != expectedLength { - fatalf("expected response length %d, got %d", expectedLength, resp.ContentLength) - } - if resp.Body == nil { - fatalf("nil body") - } - if test.compressed { - gzReader, err := gzip.NewReader(resp.Body) - checkErr(err, "gzip.NewReader") - resp.Body = &readerAndCloser{gzReader, resp.Body} - } - - rbuf := make([]byte, 2500) - n, err := io.ReadFull(resp.Body, rbuf) - checkErr(err, "2500 byte ReadFull") - if n != 2500 { - fatalf("ReadFull only read %d bytes", n) - } - if test.compressed == false && !bytes.Equal(bytes.Repeat([]byte{'x'}, 2500), rbuf) { - fatalf("ReadFull didn't read 2500 'x'; got %q", string(rbuf)) - } - resp.Body.Close() - - rest, err := ioutil.ReadAll(bufr) - checkErr(err, "ReadAll on remainder") - if e, g := "Next Request Here", string(rest); e != g { - g = regexp.MustCompile(`(xx+)`).ReplaceAllStringFunc(g, func(match string) string { - return fmt.Sprintf("x(repeated x%d)", len(match)) - }) - fatalf("remainder = %q, expected %q", g, e) - } - } -} - -func diff(t *testing.T, prefix string, have, want interface{}) { - hv := reflect.ValueOf(have).Elem() - wv := reflect.ValueOf(want).Elem() - if hv.Type() != wv.Type() { - t.Errorf("%s: type mismatch %v want %v", prefix, hv.Type(), wv.Type()) - } - for i := 0; i < hv.NumField(); i++ { - hf := hv.Field(i).Interface() - wf := wv.Field(i).Interface() - if !reflect.DeepEqual(hf, wf) { - t.Errorf("%s: %s = %v want %v", prefix, hv.Type().Field(i).Name, hf, wf) - } - } -} - -type responseLocationTest struct { - location string // Response's Location header or "" - requrl string // Response.Request.URL or "" - want string - wantErr error -} - -var responseLocationTests = []responseLocationTest{ - {"/foo", "http://bar.com/baz", "http://bar.com/foo", nil}, - {"http://foo.com/", "http://bar.com/baz", "http://foo.com/", nil}, - {"", "http://bar.com/baz", "", ErrNoLocation}, -} - -func TestLocationResponse(t *testing.T) { - for i, tt := range responseLocationTests { - res := new(Response) - res.Header = make(Header) - res.Header.Set("Location", tt.location) - if tt.requrl != "" { - res.Request = &Request{} - var err error - res.Request.URL, err = url.Parse(tt.requrl) - if err != nil { - t.Fatalf("bad test URL %q: %v", tt.requrl, err) - } - } - - got, err := res.Location() - if tt.wantErr != nil { - if err == nil { - t.Errorf("%d. err=nil; want %q", i, tt.wantErr) - continue - } - if g, e := err.Error(), tt.wantErr.Error(); g != e { - t.Errorf("%d. err=%q; want %q", i, g, e) - continue - } - continue - } - if err != nil { - t.Errorf("%d. err=%q", i, err) - continue - } - if g, e := got.String(), tt.want; g != e { - t.Errorf("%d. Location=%q; want %q", i, g, e) - } - } -} - -func TestResponseStatusStutter(t *testing.T) { - r := &Response{ - Status: "123 some status", - StatusCode: 123, - ProtoMajor: 1, - ProtoMinor: 3, - } - var buf bytes.Buffer - r.Write(&buf) - if strings.Contains(buf.String(), "123 123") { - t.Errorf("stutter in status: %s", buf.String()) - } -} - -func TestResponseContentLengthShortBody(t *testing.T) { - const shortBody = "Short body, not 123 bytes." - br := bufio.NewReader(strings.NewReader("HTTP/1.1 200 OK\r\n" + - "Content-Length: 123\r\n" + - "\r\n" + - shortBody)) - res, err := ReadResponse(br, &Request{Method: "GET"}) - if err != nil { - t.Fatal(err) - } - if res.ContentLength != 123 { - t.Fatalf("Content-Length = %d; want 123", res.ContentLength) - } - var buf bytes.Buffer - n, err := io.Copy(&buf, res.Body) - if n != int64(len(shortBody)) { - t.Errorf("Copied %d bytes; want %d, len(%q)", n, len(shortBody), shortBody) - } - if buf.String() != shortBody { - t.Errorf("Read body %q; want %q", buf.String(), shortBody) - } - if err != io.ErrUnexpectedEOF { - t.Errorf("io.Copy error = %#v; want io.ErrUnexpectedEOF", err) - } -} - -func TestReadResponseUnexpectedEOF(t *testing.T) { - br := bufio.NewReader(strings.NewReader("HTTP/1.1 301 Moved Permanently\r\n" + - "Location: http://example.com")) - _, err := ReadResponse(br, nil) - if err != io.ErrUnexpectedEOF { - t.Errorf("ReadResponse = %v; want io.ErrUnexpectedEOF", err) - } -} - -func TestNeedsSniff(t *testing.T) { - // needsSniff returns true with an empty response. - r := &response{} - if got, want := r.needsSniff(), true; got != want { - t.Errorf("needsSniff = %t; want %t", got, want) - } - // needsSniff returns false when Content-Type = nil. - r.handlerHeader = Header{"Content-Type": nil} - if got, want := r.needsSniff(), false; got != want { - t.Errorf("needsSniff empty Content-Type = %t; want %t", got, want) - } -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/responsewrite_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/responsewrite_test.go deleted file mode 100644 index 585b13b850..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/responsewrite_test.go +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http - -import ( - "bytes" - "io/ioutil" - "strings" - "testing" -) - -type respWriteTest struct { - Resp Response - Raw string -} - -func TestResponseWrite(t *testing.T) { - respWriteTests := []respWriteTest{ - // HTTP/1.0, identity coding; no trailer - { - Response{ - StatusCode: 503, - ProtoMajor: 1, - ProtoMinor: 0, - Request: dummyReq("GET"), - Header: Header{}, - Body: ioutil.NopCloser(strings.NewReader("abcdef")), - ContentLength: 6, - }, - - "HTTP/1.0 503 Service Unavailable\r\n" + - "Content-Length: 6\r\n\r\n" + - "abcdef", - }, - // Unchunked response without Content-Length. - { - Response{ - StatusCode: 200, - ProtoMajor: 1, - ProtoMinor: 0, - Request: dummyReq("GET"), - Header: Header{}, - Body: ioutil.NopCloser(strings.NewReader("abcdef")), - ContentLength: -1, - }, - "HTTP/1.0 200 OK\r\n" + - "\r\n" + - "abcdef", - }, - // HTTP/1.1 response with unknown length and Connection: close - { - Response{ - StatusCode: 200, - ProtoMajor: 1, - ProtoMinor: 1, - Request: dummyReq("GET"), - Header: Header{}, - Body: ioutil.NopCloser(strings.NewReader("abcdef")), - ContentLength: -1, - Close: true, - }, - "HTTP/1.1 200 OK\r\n" + - "Connection: close\r\n" + - "\r\n" + - "abcdef", - }, - // HTTP/1.1 response with unknown length and not setting connection: close - { - Response{ - StatusCode: 200, - ProtoMajor: 1, - ProtoMinor: 1, - Request: dummyReq11("GET"), - Header: Header{}, - Body: ioutil.NopCloser(strings.NewReader("abcdef")), - ContentLength: -1, - Close: false, - }, - "HTTP/1.1 200 OK\r\n" + - "Connection: close\r\n" + - "\r\n" + - "abcdef", - }, - // HTTP/1.1 response with unknown length and not setting connection: close, but - // setting chunked. - { - Response{ - StatusCode: 200, - ProtoMajor: 1, - ProtoMinor: 1, - Request: dummyReq11("GET"), - Header: Header{}, - Body: ioutil.NopCloser(strings.NewReader("abcdef")), - ContentLength: -1, - TransferEncoding: []string{"chunked"}, - Close: false, - }, - "HTTP/1.1 200 OK\r\n" + - "Transfer-Encoding: chunked\r\n\r\n" + - "6\r\nabcdef\r\n0\r\n\r\n", - }, - // HTTP/1.1 response 0 content-length, and nil body - { - Response{ - StatusCode: 200, - ProtoMajor: 1, - ProtoMinor: 1, - Request: dummyReq11("GET"), - Header: Header{}, - Body: nil, - ContentLength: 0, - Close: false, - }, - "HTTP/1.1 200 OK\r\n" + - "Content-Length: 0\r\n" + - "\r\n", - }, - // HTTP/1.1 response 0 content-length, and non-nil empty body - { - Response{ - StatusCode: 200, - ProtoMajor: 1, - ProtoMinor: 1, - Request: dummyReq11("GET"), - Header: Header{}, - Body: ioutil.NopCloser(strings.NewReader("")), - ContentLength: 0, - Close: false, - }, - "HTTP/1.1 200 OK\r\n" + - "Content-Length: 0\r\n" + - "\r\n", - }, - // HTTP/1.1 response 0 content-length, and non-nil non-empty body - { - Response{ - StatusCode: 200, - ProtoMajor: 1, - ProtoMinor: 1, - Request: dummyReq11("GET"), - Header: Header{}, - Body: ioutil.NopCloser(strings.NewReader("foo")), - ContentLength: 0, - Close: false, - }, - "HTTP/1.1 200 OK\r\n" + - "Connection: close\r\n" + - "\r\nfoo", - }, - // HTTP/1.1, chunked coding; empty trailer; close - { - Response{ - StatusCode: 200, - ProtoMajor: 1, - ProtoMinor: 1, - Request: dummyReq("GET"), - Header: Header{}, - Body: ioutil.NopCloser(strings.NewReader("abcdef")), - ContentLength: 6, - TransferEncoding: []string{"chunked"}, - Close: true, - }, - - "HTTP/1.1 200 OK\r\n" + - "Connection: close\r\n" + - "Transfer-Encoding: chunked\r\n\r\n" + - "6\r\nabcdef\r\n0\r\n\r\n", - }, - - // Header value with a newline character (Issue 914). - // Also tests removal of leading and trailing whitespace. - { - Response{ - StatusCode: 204, - ProtoMajor: 1, - ProtoMinor: 1, - Request: dummyReq("GET"), - Header: Header{ - "Foo": []string{" Bar\nBaz "}, - }, - Body: nil, - ContentLength: 0, - TransferEncoding: []string{"chunked"}, - Close: true, - }, - - "HTTP/1.1 204 No Content\r\n" + - "Connection: close\r\n" + - "Foo: Bar Baz\r\n" + - "\r\n", - }, - - // Want a single Content-Length header. Fixing issue 8180 where - // there were two. - { - Response{ - StatusCode: StatusOK, - ProtoMajor: 1, - ProtoMinor: 1, - Request: &Request{Method: "POST"}, - Header: Header{}, - ContentLength: 0, - TransferEncoding: nil, - Body: nil, - }, - "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n", - }, - } - - for i := range respWriteTests { - tt := &respWriteTests[i] - var braw bytes.Buffer - err := tt.Resp.Write(&braw) - if err != nil { - t.Errorf("error writing #%d: %s", i, err) - continue - } - sraw := braw.String() - if sraw != tt.Raw { - t.Errorf("Test %d, expecting:\n%q\nGot:\n%q\n", i, tt.Raw, sraw) - continue - } - } -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/serve_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/serve_test.go deleted file mode 100644 index 9e4d226bfe..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/serve_test.go +++ /dev/null @@ -1,2848 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// End-to-end serving tests - -package http_test - -import ( - "bufio" - "bytes" - "crypto/tls" - "errors" - "fmt" - "io" - "io/ioutil" - "log" - "net" - . "net/http" - "net/http/httptest" - "net/http/httputil" - "net/url" - "os" - "os/exec" - "reflect" - "runtime" - "strconv" - "strings" - "sync" - "sync/atomic" - "syscall" - "testing" - "time" -) - -type dummyAddr string -type oneConnListener struct { - conn net.Conn -} - -func (l *oneConnListener) Accept() (c net.Conn, err error) { - c = l.conn - if c == nil { - err = io.EOF - return - } - err = nil - l.conn = nil - return -} - -func (l *oneConnListener) Close() error { - return nil -} - -func (l *oneConnListener) Addr() net.Addr { - return dummyAddr("test-address") -} - -func (a dummyAddr) Network() string { - return string(a) -} - -func (a dummyAddr) String() string { - return string(a) -} - -type noopConn struct{} - -func (noopConn) LocalAddr() net.Addr { return dummyAddr("local-addr") } -func (noopConn) RemoteAddr() net.Addr { return dummyAddr("remote-addr") } -func (noopConn) SetDeadline(t time.Time) error { return nil } -func (noopConn) SetReadDeadline(t time.Time) error { return nil } -func (noopConn) SetWriteDeadline(t time.Time) error { return nil } - -type rwTestConn struct { - io.Reader - io.Writer - noopConn - - closeFunc func() error // called if non-nil - closec chan bool // else, if non-nil, send value to it on close -} - -func (c *rwTestConn) Close() error { - if c.closeFunc != nil { - return c.closeFunc() - } - select { - case c.closec <- true: - default: - } - return nil -} - -type testConn struct { - readBuf bytes.Buffer - writeBuf bytes.Buffer - closec chan bool // if non-nil, send value to it on close - noopConn -} - -func (c *testConn) Read(b []byte) (int, error) { - return c.readBuf.Read(b) -} - -func (c *testConn) Write(b []byte) (int, error) { - return c.writeBuf.Write(b) -} - -func (c *testConn) Close() error { - select { - case c.closec <- true: - default: - } - return nil -} - -// reqBytes treats req as a request (with \n delimiters) and returns it with \r\n delimiters, -// ending in \r\n\r\n -func reqBytes(req string) []byte { - return []byte(strings.Replace(strings.TrimSpace(req), "\n", "\r\n", -1) + "\r\n\r\n") -} - -type handlerTest struct { - handler Handler -} - -func newHandlerTest(h Handler) handlerTest { - return handlerTest{h} -} - -func (ht handlerTest) rawResponse(req string) string { - reqb := reqBytes(req) - var output bytes.Buffer - conn := &rwTestConn{ - Reader: bytes.NewReader(reqb), - Writer: &output, - closec: make(chan bool, 1), - } - ln := &oneConnListener{conn: conn} - go Serve(ln, ht.handler) - <-conn.closec - return output.String() -} - -func TestConsumingBodyOnNextConn(t *testing.T) { - conn := new(testConn) - for i := 0; i < 2; i++ { - conn.readBuf.Write([]byte( - "POST / HTTP/1.1\r\n" + - "Host: test\r\n" + - "Content-Length: 11\r\n" + - "\r\n" + - "foo=1&bar=1")) - } - - reqNum := 0 - ch := make(chan *Request) - servech := make(chan error) - listener := &oneConnListener{conn} - handler := func(res ResponseWriter, req *Request) { - reqNum++ - ch <- req - } - - go func() { - servech <- Serve(listener, HandlerFunc(handler)) - }() - - var req *Request - req = <-ch - if req == nil { - t.Fatal("Got nil first request.") - } - if req.Method != "POST" { - t.Errorf("For request #1's method, got %q; expected %q", - req.Method, "POST") - } - - req = <-ch - if req == nil { - t.Fatal("Got nil first request.") - } - if req.Method != "POST" { - t.Errorf("For request #2's method, got %q; expected %q", - req.Method, "POST") - } - - if serveerr := <-servech; serveerr != io.EOF { - t.Errorf("Serve returned %q; expected EOF", serveerr) - } -} - -type stringHandler string - -func (s stringHandler) ServeHTTP(w ResponseWriter, r *Request) { - w.Header().Set("Result", string(s)) -} - -var handlers = []struct { - pattern string - msg string -}{ - {"/", "Default"}, - {"/someDir/", "someDir"}, - {"someHost.com/someDir/", "someHost.com/someDir"}, -} - -var vtests = []struct { - url string - expected string -}{ - {"http://localhost/someDir/apage", "someDir"}, - {"http://localhost/otherDir/apage", "Default"}, - {"http://someHost.com/someDir/apage", "someHost.com/someDir"}, - {"http://otherHost.com/someDir/apage", "someDir"}, - {"http://otherHost.com/aDir/apage", "Default"}, - // redirections for trees - {"http://localhost/someDir", "/someDir/"}, - {"http://someHost.com/someDir", "/someDir/"}, -} - -func TestHostHandlers(t *testing.T) { - defer afterTest(t) - mux := NewServeMux() - for _, h := range handlers { - mux.Handle(h.pattern, stringHandler(h.msg)) - } - ts := httptest.NewServer(mux) - defer ts.Close() - - conn, err := net.Dial("tcp", ts.Listener.Addr().String()) - if err != nil { - t.Fatal(err) - } - defer conn.Close() - cc := httputil.NewClientConn(conn, nil) - for _, vt := range vtests { - var r *Response - var req Request - if req.URL, err = url.Parse(vt.url); err != nil { - t.Errorf("cannot parse url: %v", err) - continue - } - if err := cc.Write(&req); err != nil { - t.Errorf("writing request: %v", err) - continue - } - r, err := cc.Read(&req) - if err != nil { - t.Errorf("reading response: %v", err) - continue - } - switch r.StatusCode { - case StatusOK: - s := r.Header.Get("Result") - if s != vt.expected { - t.Errorf("Get(%q) = %q, want %q", vt.url, s, vt.expected) - } - case StatusMovedPermanently: - s := r.Header.Get("Location") - if s != vt.expected { - t.Errorf("Get(%q) = %q, want %q", vt.url, s, vt.expected) - } - default: - t.Errorf("Get(%q) unhandled status code %d", vt.url, r.StatusCode) - } - } -} - -var serveMuxRegister = []struct { - pattern string - h Handler -}{ - {"/dir/", serve(200)}, - {"/search", serve(201)}, - {"codesearch.google.com/search", serve(202)}, - {"codesearch.google.com/", serve(203)}, - {"example.com/", HandlerFunc(checkQueryStringHandler)}, -} - -// serve returns a handler that sends a response with the given code. -func serve(code int) HandlerFunc { - return func(w ResponseWriter, r *Request) { - w.WriteHeader(code) - } -} - -// checkQueryStringHandler checks if r.URL.RawQuery has the same value -// as the URL excluding the scheme and the query string and sends 200 -// response code if it is, 500 otherwise. -func checkQueryStringHandler(w ResponseWriter, r *Request) { - u := *r.URL - u.Scheme = "http" - u.Host = r.Host - u.RawQuery = "" - if "http://"+r.URL.RawQuery == u.String() { - w.WriteHeader(200) - } else { - w.WriteHeader(500) - } -} - -var serveMuxTests = []struct { - method string - host string - path string - code int - pattern string -}{ - {"GET", "google.com", "/", 404, ""}, - {"GET", "google.com", "/dir", 301, "/dir/"}, - {"GET", "google.com", "/dir/", 200, "/dir/"}, - {"GET", "google.com", "/dir/file", 200, "/dir/"}, - {"GET", "google.com", "/search", 201, "/search"}, - {"GET", "google.com", "/search/", 404, ""}, - {"GET", "google.com", "/search/foo", 404, ""}, - {"GET", "codesearch.google.com", "/search", 202, "codesearch.google.com/search"}, - {"GET", "codesearch.google.com", "/search/", 203, "codesearch.google.com/"}, - {"GET", "codesearch.google.com", "/search/foo", 203, "codesearch.google.com/"}, - {"GET", "codesearch.google.com", "/", 203, "codesearch.google.com/"}, - {"GET", "images.google.com", "/search", 201, "/search"}, - {"GET", "images.google.com", "/search/", 404, ""}, - {"GET", "images.google.com", "/search/foo", 404, ""}, - {"GET", "google.com", "/../search", 301, "/search"}, - {"GET", "google.com", "/dir/..", 301, ""}, - {"GET", "google.com", "/dir/..", 301, ""}, - {"GET", "google.com", "/dir/./file", 301, "/dir/"}, - - // The /foo -> /foo/ redirect applies to CONNECT requests - // but the path canonicalization does not. - {"CONNECT", "google.com", "/dir", 301, "/dir/"}, - {"CONNECT", "google.com", "/../search", 404, ""}, - {"CONNECT", "google.com", "/dir/..", 200, "/dir/"}, - {"CONNECT", "google.com", "/dir/..", 200, "/dir/"}, - {"CONNECT", "google.com", "/dir/./file", 200, "/dir/"}, -} - -func TestServeMuxHandler(t *testing.T) { - mux := NewServeMux() - for _, e := range serveMuxRegister { - mux.Handle(e.pattern, e.h) - } - - for _, tt := range serveMuxTests { - r := &Request{ - Method: tt.method, - Host: tt.host, - URL: &url.URL{ - Path: tt.path, - }, - } - h, pattern := mux.Handler(r) - rr := httptest.NewRecorder() - h.ServeHTTP(rr, r) - if pattern != tt.pattern || rr.Code != tt.code { - t.Errorf("%s %s %s = %d, %q, want %d, %q", tt.method, tt.host, tt.path, rr.Code, pattern, tt.code, tt.pattern) - } - } -} - -var serveMuxTests2 = []struct { - method string - host string - url string - code int - redirOk bool -}{ - {"GET", "google.com", "/", 404, false}, - {"GET", "example.com", "/test/?example.com/test/", 200, false}, - {"GET", "example.com", "test/?example.com/test/", 200, true}, -} - -// TestServeMuxHandlerRedirects tests that automatic redirects generated by -// mux.Handler() shouldn't clear the request's query string. -func TestServeMuxHandlerRedirects(t *testing.T) { - mux := NewServeMux() - for _, e := range serveMuxRegister { - mux.Handle(e.pattern, e.h) - } - - for _, tt := range serveMuxTests2 { - tries := 1 - turl := tt.url - for tries > 0 { - u, e := url.Parse(turl) - if e != nil { - t.Fatal(e) - } - r := &Request{ - Method: tt.method, - Host: tt.host, - URL: u, - } - h, _ := mux.Handler(r) - rr := httptest.NewRecorder() - h.ServeHTTP(rr, r) - if rr.Code != 301 { - if rr.Code != tt.code { - t.Errorf("%s %s %s = %d, want %d", tt.method, tt.host, tt.url, rr.Code, tt.code) - } - break - } - if !tt.redirOk { - t.Errorf("%s %s %s, unexpected redirect", tt.method, tt.host, tt.url) - break - } - turl = rr.HeaderMap.Get("Location") - tries-- - } - if tries < 0 { - t.Errorf("%s %s %s, too many redirects", tt.method, tt.host, tt.url) - } - } -} - -// Tests for http://code.google.com/p/go/issues/detail?id=900 -func TestMuxRedirectLeadingSlashes(t *testing.T) { - paths := []string{"//foo.txt", "///foo.txt", "/../../foo.txt"} - for _, path := range paths { - req, err := ReadRequest(bufio.NewReader(strings.NewReader("GET " + path + " HTTP/1.1\r\nHost: test\r\n\r\n"))) - if err != nil { - t.Errorf("%s", err) - } - mux := NewServeMux() - resp := httptest.NewRecorder() - - mux.ServeHTTP(resp, req) - - if loc, expected := resp.Header().Get("Location"), "/foo.txt"; loc != expected { - t.Errorf("Expected Location header set to %q; got %q", expected, loc) - return - } - - if code, expected := resp.Code, StatusMovedPermanently; code != expected { - t.Errorf("Expected response code of StatusMovedPermanently; got %d", code) - return - } - } -} - -func TestServerTimeouts(t *testing.T) { - if runtime.GOOS == "plan9" { - t.Skip("skipping test; see http://golang.org/issue/7237") - } - defer afterTest(t) - reqNum := 0 - ts := httptest.NewUnstartedServer(HandlerFunc(func(res ResponseWriter, req *Request) { - reqNum++ - fmt.Fprintf(res, "req=%d", reqNum) - })) - ts.Config.ReadTimeout = 250 * time.Millisecond - ts.Config.WriteTimeout = 250 * time.Millisecond - ts.Start() - defer ts.Close() - - // Hit the HTTP server successfully. - tr := &Transport{DisableKeepAlives: true} // they interfere with this test - defer tr.CloseIdleConnections() - c := &Client{Transport: tr} - r, err := c.Get(ts.URL) - if err != nil { - t.Fatalf("http Get #1: %v", err) - } - got, _ := ioutil.ReadAll(r.Body) - expected := "req=1" - if string(got) != expected { - t.Errorf("Unexpected response for request #1; got %q; expected %q", - string(got), expected) - } - - // Slow client that should timeout. - t1 := time.Now() - conn, err := net.Dial("tcp", ts.Listener.Addr().String()) - if err != nil { - t.Fatalf("Dial: %v", err) - } - buf := make([]byte, 1) - n, err := conn.Read(buf) - latency := time.Since(t1) - if n != 0 || err != io.EOF { - t.Errorf("Read = %v, %v, wanted %v, %v", n, err, 0, io.EOF) - } - if latency < 200*time.Millisecond /* fudge from 250 ms above */ { - t.Errorf("got EOF after %s, want >= %s", latency, 200*time.Millisecond) - } - - // Hit the HTTP server successfully again, verifying that the - // previous slow connection didn't run our handler. (that we - // get "req=2", not "req=3") - r, err = Get(ts.URL) - if err != nil { - t.Fatalf("http Get #2: %v", err) - } - got, _ = ioutil.ReadAll(r.Body) - expected = "req=2" - if string(got) != expected { - t.Errorf("Get #2 got %q, want %q", string(got), expected) - } - - if !testing.Short() { - conn, err := net.Dial("tcp", ts.Listener.Addr().String()) - if err != nil { - t.Fatalf("Dial: %v", err) - } - defer conn.Close() - go io.Copy(ioutil.Discard, conn) - for i := 0; i < 5; i++ { - _, err := conn.Write([]byte("GET / HTTP/1.1\r\nHost: foo\r\n\r\n")) - if err != nil { - t.Fatalf("on write %d: %v", i, err) - } - time.Sleep(ts.Config.ReadTimeout / 2) - } - } -} - -// golang.org/issue/4741 -- setting only a write timeout that triggers -// shouldn't cause a handler to block forever on reads (next HTTP -// request) that will never happen. -func TestOnlyWriteTimeout(t *testing.T) { - if runtime.GOOS == "plan9" { - t.Skip("skipping test; see http://golang.org/issue/7237") - } - defer afterTest(t) - var conn net.Conn - var afterTimeoutErrc = make(chan error, 1) - ts := httptest.NewUnstartedServer(HandlerFunc(func(w ResponseWriter, req *Request) { - buf := make([]byte, 512<<10) - _, err := w.Write(buf) - if err != nil { - t.Errorf("handler Write error: %v", err) - return - } - conn.SetWriteDeadline(time.Now().Add(-30 * time.Second)) - _, err = w.Write(buf) - afterTimeoutErrc <- err - })) - ts.Listener = trackLastConnListener{ts.Listener, &conn} - ts.Start() - defer ts.Close() - - tr := &Transport{DisableKeepAlives: false} - defer tr.CloseIdleConnections() - c := &Client{Transport: tr} - - errc := make(chan error) - go func() { - res, err := c.Get(ts.URL) - if err != nil { - errc <- err - return - } - _, err = io.Copy(ioutil.Discard, res.Body) - errc <- err - }() - select { - case err := <-errc: - if err == nil { - t.Errorf("expected an error from Get request") - } - case <-time.After(5 * time.Second): - t.Fatal("timeout waiting for Get error") - } - if err := <-afterTimeoutErrc; err == nil { - t.Error("expected write error after timeout") - } -} - -// trackLastConnListener tracks the last net.Conn that was accepted. -type trackLastConnListener struct { - net.Listener - last *net.Conn // destination -} - -func (l trackLastConnListener) Accept() (c net.Conn, err error) { - c, err = l.Listener.Accept() - *l.last = c - return -} - -// TestIdentityResponse verifies that a handler can unset -func TestIdentityResponse(t *testing.T) { - defer afterTest(t) - handler := HandlerFunc(func(rw ResponseWriter, req *Request) { - rw.Header().Set("Content-Length", "3") - rw.Header().Set("Transfer-Encoding", req.FormValue("te")) - switch { - case req.FormValue("overwrite") == "1": - _, err := rw.Write([]byte("foo TOO LONG")) - if err != ErrContentLength { - t.Errorf("expected ErrContentLength; got %v", err) - } - case req.FormValue("underwrite") == "1": - rw.Header().Set("Content-Length", "500") - rw.Write([]byte("too short")) - default: - rw.Write([]byte("foo")) - } - }) - - ts := httptest.NewServer(handler) - defer ts.Close() - - // Note: this relies on the assumption (which is true) that - // Get sends HTTP/1.1 or greater requests. Otherwise the - // server wouldn't have the choice to send back chunked - // responses. - for _, te := range []string{"", "identity"} { - url := ts.URL + "/?te=" + te - res, err := Get(url) - if err != nil { - t.Fatalf("error with Get of %s: %v", url, err) - } - if cl, expected := res.ContentLength, int64(3); cl != expected { - t.Errorf("for %s expected res.ContentLength of %d; got %d", url, expected, cl) - } - if cl, expected := res.Header.Get("Content-Length"), "3"; cl != expected { - t.Errorf("for %s expected Content-Length header of %q; got %q", url, expected, cl) - } - if tl, expected := len(res.TransferEncoding), 0; tl != expected { - t.Errorf("for %s expected len(res.TransferEncoding) of %d; got %d (%v)", - url, expected, tl, res.TransferEncoding) - } - res.Body.Close() - } - - // Verify that ErrContentLength is returned - url := ts.URL + "/?overwrite=1" - res, err := Get(url) - if err != nil { - t.Fatalf("error with Get of %s: %v", url, err) - } - res.Body.Close() - - // Verify that the connection is closed when the declared Content-Length - // is larger than what the handler wrote. - conn, err := net.Dial("tcp", ts.Listener.Addr().String()) - if err != nil { - t.Fatalf("error dialing: %v", err) - } - _, err = conn.Write([]byte("GET /?underwrite=1 HTTP/1.1\r\nHost: foo\r\n\r\n")) - if err != nil { - t.Fatalf("error writing: %v", err) - } - - // The ReadAll will hang for a failing test, so use a Timer to - // fail explicitly. - goTimeout(t, 2*time.Second, func() { - got, _ := ioutil.ReadAll(conn) - expectedSuffix := "\r\n\r\ntoo short" - if !strings.HasSuffix(string(got), expectedSuffix) { - t.Errorf("Expected output to end with %q; got response body %q", - expectedSuffix, string(got)) - } - }) -} - -func testTCPConnectionCloses(t *testing.T, req string, h Handler) { - defer afterTest(t) - s := httptest.NewServer(h) - defer s.Close() - - conn, err := net.Dial("tcp", s.Listener.Addr().String()) - if err != nil { - t.Fatal("dial error:", err) - } - defer conn.Close() - - _, err = fmt.Fprint(conn, req) - if err != nil { - t.Fatal("print error:", err) - } - - r := bufio.NewReader(conn) - res, err := ReadResponse(r, &Request{Method: "GET"}) - if err != nil { - t.Fatal("ReadResponse error:", err) - } - - didReadAll := make(chan bool, 1) - go func() { - select { - case <-time.After(5 * time.Second): - t.Error("body not closed after 5s") - return - case <-didReadAll: - } - }() - - _, err = ioutil.ReadAll(r) - if err != nil { - t.Fatal("read error:", err) - } - didReadAll <- true - - if !res.Close { - t.Errorf("Response.Close = false; want true") - } -} - -// TestServeHTTP10Close verifies that HTTP/1.0 requests won't be kept alive. -func TestServeHTTP10Close(t *testing.T) { - testTCPConnectionCloses(t, "GET / HTTP/1.0\r\n\r\n", HandlerFunc(func(w ResponseWriter, r *Request) { - ServeFile(w, r, "testdata/file") - })) -} - -// TestClientCanClose verifies that clients can also force a connection to close. -func TestClientCanClose(t *testing.T) { - testTCPConnectionCloses(t, "GET / HTTP/1.1\r\nConnection: close\r\n\r\n", HandlerFunc(func(w ResponseWriter, r *Request) { - // Nothing. - })) -} - -// TestHandlersCanSetConnectionClose verifies that handlers can force a connection to close, -// even for HTTP/1.1 requests. -func TestHandlersCanSetConnectionClose11(t *testing.T) { - testTCPConnectionCloses(t, "GET / HTTP/1.1\r\n\r\n", HandlerFunc(func(w ResponseWriter, r *Request) { - w.Header().Set("Connection", "close") - })) -} - -func TestHandlersCanSetConnectionClose10(t *testing.T) { - testTCPConnectionCloses(t, "GET / HTTP/1.0\r\nConnection: keep-alive\r\n\r\n", HandlerFunc(func(w ResponseWriter, r *Request) { - w.Header().Set("Connection", "close") - })) -} - -func TestSetsRemoteAddr(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - fmt.Fprintf(w, "%s", r.RemoteAddr) - })) - defer ts.Close() - - res, err := Get(ts.URL) - if err != nil { - t.Fatalf("Get error: %v", err) - } - body, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatalf("ReadAll error: %v", err) - } - ip := string(body) - if !strings.HasPrefix(ip, "127.0.0.1:") && !strings.HasPrefix(ip, "[::1]:") { - t.Fatalf("Expected local addr; got %q", ip) - } -} - -func TestChunkedResponseHeaders(t *testing.T) { - defer afterTest(t) - log.SetOutput(ioutil.Discard) // is noisy otherwise - defer log.SetOutput(os.Stderr) - - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - w.Header().Set("Content-Length", "intentional gibberish") // we check that this is deleted - w.(Flusher).Flush() - fmt.Fprintf(w, "I am a chunked response.") - })) - defer ts.Close() - - res, err := Get(ts.URL) - if err != nil { - t.Fatalf("Get error: %v", err) - } - defer res.Body.Close() - if g, e := res.ContentLength, int64(-1); g != e { - t.Errorf("expected ContentLength of %d; got %d", e, g) - } - if g, e := res.TransferEncoding, []string{"chunked"}; !reflect.DeepEqual(g, e) { - t.Errorf("expected TransferEncoding of %v; got %v", e, g) - } - if _, haveCL := res.Header["Content-Length"]; haveCL { - t.Errorf("Unexpected Content-Length") - } -} - -// Test304Responses verifies that 304s don't declare that they're -// chunking in their response headers and aren't allowed to produce -// output. -func Test304Responses(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - w.WriteHeader(StatusNotModified) - _, err := w.Write([]byte("illegal body")) - if err != ErrBodyNotAllowed { - t.Errorf("on Write, expected ErrBodyNotAllowed, got %v", err) - } - })) - defer ts.Close() - res, err := Get(ts.URL) - if err != nil { - t.Error(err) - } - if len(res.TransferEncoding) > 0 { - t.Errorf("expected no TransferEncoding; got %v", res.TransferEncoding) - } - body, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Error(err) - } - if len(body) > 0 { - t.Errorf("got unexpected body %q", string(body)) - } -} - -// TestHeadResponses verifies that all MIME type sniffing and Content-Length -// counting of GET requests also happens on HEAD requests. -func TestHeadResponses(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - _, err := w.Write([]byte("")) - if err != nil { - t.Errorf("ResponseWriter.Write: %v", err) - } - - // Also exercise the ReaderFrom path - _, err = io.Copy(w, strings.NewReader("789a")) - if err != nil { - t.Errorf("Copy(ResponseWriter, ...): %v", err) - } - })) - defer ts.Close() - res, err := Head(ts.URL) - if err != nil { - t.Error(err) - } - if len(res.TransferEncoding) > 0 { - t.Errorf("expected no TransferEncoding; got %v", res.TransferEncoding) - } - if ct := res.Header.Get("Content-Type"); ct != "text/html; charset=utf-8" { - t.Errorf("Content-Type: %q; want text/html; charset=utf-8", ct) - } - if v := res.ContentLength; v != 10 { - t.Errorf("Content-Length: %d; want 10", v) - } - body, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Error(err) - } - if len(body) > 0 { - t.Errorf("got unexpected body %q", string(body)) - } -} - -func TestTLSHandshakeTimeout(t *testing.T) { - if runtime.GOOS == "plan9" { - t.Skip("skipping test; see http://golang.org/issue/7237") - } - defer afterTest(t) - ts := httptest.NewUnstartedServer(HandlerFunc(func(w ResponseWriter, r *Request) {})) - errc := make(chanWriter, 10) // but only expecting 1 - ts.Config.ReadTimeout = 250 * time.Millisecond - ts.Config.ErrorLog = log.New(errc, "", 0) - ts.StartTLS() - defer ts.Close() - conn, err := net.Dial("tcp", ts.Listener.Addr().String()) - if err != nil { - t.Fatalf("Dial: %v", err) - } - defer conn.Close() - goTimeout(t, 10*time.Second, func() { - var buf [1]byte - n, err := conn.Read(buf[:]) - if err == nil || n != 0 { - t.Errorf("Read = %d, %v; want an error and no bytes", n, err) - } - }) - select { - case v := <-errc: - if !strings.Contains(v, "timeout") && !strings.Contains(v, "TLS handshake") { - t.Errorf("expected a TLS handshake timeout error; got %q", v) - } - case <-time.After(5 * time.Second): - t.Errorf("timeout waiting for logged error") - } -} - -func TestTLSServer(t *testing.T) { - defer afterTest(t) - ts := httptest.NewTLSServer(HandlerFunc(func(w ResponseWriter, r *Request) { - if r.TLS != nil { - w.Header().Set("X-TLS-Set", "true") - if r.TLS.HandshakeComplete { - w.Header().Set("X-TLS-HandshakeComplete", "true") - } - } - })) - ts.Config.ErrorLog = log.New(ioutil.Discard, "", 0) - defer ts.Close() - - // Connect an idle TCP connection to this server before we run - // our real tests. This idle connection used to block forever - // in the TLS handshake, preventing future connections from - // being accepted. It may prevent future accidental blocking - // in newConn. - idleConn, err := net.Dial("tcp", ts.Listener.Addr().String()) - if err != nil { - t.Fatalf("Dial: %v", err) - } - defer idleConn.Close() - goTimeout(t, 10*time.Second, func() { - if !strings.HasPrefix(ts.URL, "https://") { - t.Errorf("expected test TLS server to start with https://, got %q", ts.URL) - return - } - noVerifyTransport := &Transport{ - TLSClientConfig: &tls.Config{ - InsecureSkipVerify: true, - }, - } - client := &Client{Transport: noVerifyTransport} - res, err := client.Get(ts.URL) - if err != nil { - t.Error(err) - return - } - if res == nil { - t.Errorf("got nil Response") - return - } - defer res.Body.Close() - if res.Header.Get("X-TLS-Set") != "true" { - t.Errorf("expected X-TLS-Set response header") - return - } - if res.Header.Get("X-TLS-HandshakeComplete") != "true" { - t.Errorf("expected X-TLS-HandshakeComplete header") - } - }) -} - -type serverExpectTest struct { - contentLength int // of request body - chunked bool - expectation string // e.g. "100-continue" - readBody bool // whether handler should read the body (if false, sends StatusUnauthorized) - expectedResponse string // expected substring in first line of http response -} - -func expectTest(contentLength int, expectation string, readBody bool, expectedResponse string) serverExpectTest { - return serverExpectTest{ - contentLength: contentLength, - expectation: expectation, - readBody: readBody, - expectedResponse: expectedResponse, - } -} - -var serverExpectTests = []serverExpectTest{ - // Normal 100-continues, case-insensitive. - expectTest(100, "100-continue", true, "100 Continue"), - expectTest(100, "100-cOntInUE", true, "100 Continue"), - - // No 100-continue. - expectTest(100, "", true, "200 OK"), - - // 100-continue but requesting client to deny us, - // so it never reads the body. - expectTest(100, "100-continue", false, "401 Unauthorized"), - // Likewise without 100-continue: - expectTest(100, "", false, "401 Unauthorized"), - - // Non-standard expectations are failures - expectTest(0, "a-pony", false, "417 Expectation Failed"), - - // Expect-100 requested but no body (is apparently okay: Issue 7625) - expectTest(0, "100-continue", true, "200 OK"), - // Expect-100 requested but handler doesn't read the body - expectTest(0, "100-continue", false, "401 Unauthorized"), - // Expect-100 continue with no body, but a chunked body. - { - expectation: "100-continue", - readBody: true, - chunked: true, - expectedResponse: "100 Continue", - }, -} - -// Tests that the server responds to the "Expect" request header -// correctly. -func TestServerExpect(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - // Note using r.FormValue("readbody") because for POST - // requests that would read from r.Body, which we only - // conditionally want to do. - if strings.Contains(r.URL.RawQuery, "readbody=true") { - ioutil.ReadAll(r.Body) - w.Write([]byte("Hi")) - } else { - w.WriteHeader(StatusUnauthorized) - } - })) - defer ts.Close() - - runTest := func(test serverExpectTest) { - conn, err := net.Dial("tcp", ts.Listener.Addr().String()) - if err != nil { - t.Fatalf("Dial: %v", err) - } - defer conn.Close() - - // Only send the body immediately if we're acting like an HTTP client - // that doesn't send 100-continue expectations. - writeBody := test.contentLength != 0 && strings.ToLower(test.expectation) != "100-continue" - - go func() { - contentLen := fmt.Sprintf("Content-Length: %d", test.contentLength) - if test.chunked { - contentLen = "Transfer-Encoding: chunked" - } - _, err := fmt.Fprintf(conn, "POST /?readbody=%v HTTP/1.1\r\n"+ - "Connection: close\r\n"+ - "%s\r\n"+ - "Expect: %s\r\nHost: foo\r\n\r\n", - test.readBody, contentLen, test.expectation) - if err != nil { - t.Errorf("On test %#v, error writing request headers: %v", test, err) - return - } - if writeBody { - var targ io.WriteCloser = struct { - io.Writer - io.Closer - }{ - conn, - ioutil.NopCloser(nil), - } - if test.chunked { - targ = httputil.NewChunkedWriter(conn) - } - body := strings.Repeat("A", test.contentLength) - _, err = fmt.Fprint(targ, body) - if err == nil { - err = targ.Close() - } - if err != nil { - if !test.readBody { - // Server likely already hung up on us. - // See larger comment below. - t.Logf("On test %#v, acceptable error writing request body: %v", test, err) - return - } - t.Errorf("On test %#v, error writing request body: %v", test, err) - } - } - }() - bufr := bufio.NewReader(conn) - line, err := bufr.ReadString('\n') - if err != nil { - if writeBody && !test.readBody { - // This is an acceptable failure due to a possible TCP race: - // We were still writing data and the server hung up on us. A TCP - // implementation may send a RST if our request body data was known - // to be lost, which may trigger our reads to fail. - // See RFC 1122 page 88. - t.Logf("On test %#v, acceptable error from ReadString: %v", test, err) - return - } - t.Fatalf("On test %#v, ReadString: %v", test, err) - } - if !strings.Contains(line, test.expectedResponse) { - t.Errorf("On test %#v, got first line = %q; want %q", test, line, test.expectedResponse) - } - } - - for _, test := range serverExpectTests { - runTest(test) - } -} - -// Under a ~256KB (maxPostHandlerReadBytes) threshold, the server -// should consume client request bodies that a handler didn't read. -func TestServerUnreadRequestBodyLittle(t *testing.T) { - conn := new(testConn) - body := strings.Repeat("x", 100<<10) - conn.readBuf.Write([]byte(fmt.Sprintf( - "POST / HTTP/1.1\r\n"+ - "Host: test\r\n"+ - "Content-Length: %d\r\n"+ - "\r\n", len(body)))) - conn.readBuf.Write([]byte(body)) - - done := make(chan bool) - - ls := &oneConnListener{conn} - go Serve(ls, HandlerFunc(func(rw ResponseWriter, req *Request) { - defer close(done) - if conn.readBuf.Len() < len(body)/2 { - t.Errorf("on request, read buffer length is %d; expected about 100 KB", conn.readBuf.Len()) - } - rw.WriteHeader(200) - rw.(Flusher).Flush() - if g, e := conn.readBuf.Len(), 0; g != e { - t.Errorf("after WriteHeader, read buffer length is %d; want %d", g, e) - } - if c := rw.Header().Get("Connection"); c != "" { - t.Errorf(`Connection header = %q; want ""`, c) - } - })) - <-done -} - -// Over a ~256KB (maxPostHandlerReadBytes) threshold, the server -// should ignore client request bodies that a handler didn't read -// and close the connection. -func TestServerUnreadRequestBodyLarge(t *testing.T) { - conn := new(testConn) - body := strings.Repeat("x", 1<<20) - conn.readBuf.Write([]byte(fmt.Sprintf( - "POST / HTTP/1.1\r\n"+ - "Host: test\r\n"+ - "Content-Length: %d\r\n"+ - "\r\n", len(body)))) - conn.readBuf.Write([]byte(body)) - conn.closec = make(chan bool, 1) - - ls := &oneConnListener{conn} - go Serve(ls, HandlerFunc(func(rw ResponseWriter, req *Request) { - if conn.readBuf.Len() < len(body)/2 { - t.Errorf("on request, read buffer length is %d; expected about 1MB", conn.readBuf.Len()) - } - rw.WriteHeader(200) - rw.(Flusher).Flush() - if conn.readBuf.Len() < len(body)/2 { - t.Errorf("post-WriteHeader, read buffer length is %d; expected about 1MB", conn.readBuf.Len()) - } - })) - <-conn.closec - - if res := conn.writeBuf.String(); !strings.Contains(res, "Connection: close") { - t.Errorf("Expected a Connection: close header; got response: %s", res) - } -} - -func TestTimeoutHandler(t *testing.T) { - defer afterTest(t) - sendHi := make(chan bool, 1) - writeErrors := make(chan error, 1) - sayHi := HandlerFunc(func(w ResponseWriter, r *Request) { - <-sendHi - _, werr := w.Write([]byte("hi")) - writeErrors <- werr - }) - timeout := make(chan time.Time, 1) // write to this to force timeouts - ts := httptest.NewServer(NewTestTimeoutHandler(sayHi, timeout)) - defer ts.Close() - - // Succeed without timing out: - sendHi <- true - res, err := Get(ts.URL) - if err != nil { - t.Error(err) - } - if g, e := res.StatusCode, StatusOK; g != e { - t.Errorf("got res.StatusCode %d; expected %d", g, e) - } - body, _ := ioutil.ReadAll(res.Body) - if g, e := string(body), "hi"; g != e { - t.Errorf("got body %q; expected %q", g, e) - } - if g := <-writeErrors; g != nil { - t.Errorf("got unexpected Write error on first request: %v", g) - } - - // Times out: - timeout <- time.Time{} - res, err = Get(ts.URL) - if err != nil { - t.Error(err) - } - if g, e := res.StatusCode, StatusServiceUnavailable; g != e { - t.Errorf("got res.StatusCode %d; expected %d", g, e) - } - body, _ = ioutil.ReadAll(res.Body) - if !strings.Contains(string(body), "Timeout") { - t.Errorf("expected timeout body; got %q", string(body)) - } - - // Now make the previously-timed out handler speak again, - // which verifies the panic is handled: - sendHi <- true - if g, e := <-writeErrors, ErrHandlerTimeout; g != e { - t.Errorf("expected Write error of %v; got %v", e, g) - } -} - -// Verifies we don't path.Clean() on the wrong parts in redirects. -func TestRedirectMunging(t *testing.T) { - req, _ := NewRequest("GET", "http://example.com/", nil) - - resp := httptest.NewRecorder() - Redirect(resp, req, "/foo?next=http://bar.com/", 302) - if g, e := resp.Header().Get("Location"), "/foo?next=http://bar.com/"; g != e { - t.Errorf("Location header was %q; want %q", g, e) - } - - resp = httptest.NewRecorder() - Redirect(resp, req, "http://localhost:8080/_ah/login?continue=http://localhost:8080/", 302) - if g, e := resp.Header().Get("Location"), "http://localhost:8080/_ah/login?continue=http://localhost:8080/"; g != e { - t.Errorf("Location header was %q; want %q", g, e) - } -} - -func TestRedirectBadPath(t *testing.T) { - // This used to crash. It's not valid input (bad path), but it - // shouldn't crash. - rr := httptest.NewRecorder() - req := &Request{ - Method: "GET", - URL: &url.URL{ - Scheme: "http", - Path: "not-empty-but-no-leading-slash", // bogus - }, - } - Redirect(rr, req, "", 304) - if rr.Code != 304 { - t.Errorf("Code = %d; want 304", rr.Code) - } -} - -// TestZeroLengthPostAndResponse exercises an optimization done by the Transport: -// when there is no body (either because the method doesn't permit a body, or an -// explicit Content-Length of zero is present), then the transport can re-use the -// connection immediately. But when it re-uses the connection, it typically closes -// the previous request's body, which is not optimal for zero-lengthed bodies, -// as the client would then see http.ErrBodyReadAfterClose and not 0, io.EOF. -func TestZeroLengthPostAndResponse(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(rw ResponseWriter, r *Request) { - all, err := ioutil.ReadAll(r.Body) - if err != nil { - t.Fatalf("handler ReadAll: %v", err) - } - if len(all) != 0 { - t.Errorf("handler got %d bytes; expected 0", len(all)) - } - rw.Header().Set("Content-Length", "0") - })) - defer ts.Close() - - req, err := NewRequest("POST", ts.URL, strings.NewReader("")) - if err != nil { - t.Fatal(err) - } - req.ContentLength = 0 - - var resp [5]*Response - for i := range resp { - resp[i], err = DefaultClient.Do(req) - if err != nil { - t.Fatalf("client post #%d: %v", i, err) - } - } - - for i := range resp { - all, err := ioutil.ReadAll(resp[i].Body) - if err != nil { - t.Fatalf("req #%d: client ReadAll: %v", i, err) - } - if len(all) != 0 { - t.Errorf("req #%d: client got %d bytes; expected 0", i, len(all)) - } - } -} - -func TestHandlerPanicNil(t *testing.T) { - testHandlerPanic(t, false, nil) -} - -func TestHandlerPanic(t *testing.T) { - testHandlerPanic(t, false, "intentional death for testing") -} - -func TestHandlerPanicWithHijack(t *testing.T) { - testHandlerPanic(t, true, "intentional death for testing") -} - -func testHandlerPanic(t *testing.T, withHijack bool, panicValue interface{}) { - defer afterTest(t) - // Unlike the other tests that set the log output to ioutil.Discard - // to quiet the output, this test uses a pipe. The pipe serves three - // purposes: - // - // 1) The log.Print from the http server (generated by the caught - // panic) will go to the pipe instead of stderr, making the - // output quiet. - // - // 2) We read from the pipe to verify that the handler - // actually caught the panic and logged something. - // - // 3) The blocking Read call prevents this TestHandlerPanic - // function from exiting before the HTTP server handler - // finishes crashing. If this text function exited too - // early (and its defer log.SetOutput(os.Stderr) ran), - // then the crash output could spill into the next test. - pr, pw := io.Pipe() - log.SetOutput(pw) - defer log.SetOutput(os.Stderr) - defer pw.Close() - - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - if withHijack { - rwc, _, err := w.(Hijacker).Hijack() - if err != nil { - t.Logf("unexpected error: %v", err) - } - defer rwc.Close() - } - panic(panicValue) - })) - defer ts.Close() - - // Do a blocking read on the log output pipe so its logging - // doesn't bleed into the next test. But wait only 5 seconds - // for it. - done := make(chan bool, 1) - go func() { - buf := make([]byte, 4<<10) - _, err := pr.Read(buf) - pr.Close() - if err != nil && err != io.EOF { - t.Error(err) - } - done <- true - }() - - _, err := Get(ts.URL) - if err == nil { - t.Logf("expected an error") - } - - if panicValue == nil { - return - } - - select { - case <-done: - return - case <-time.After(5 * time.Second): - t.Fatal("expected server handler to log an error") - } -} - -func TestNoDate(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - w.Header()["Date"] = nil - })) - defer ts.Close() - res, err := Get(ts.URL) - if err != nil { - t.Fatal(err) - } - _, present := res.Header["Date"] - if present { - t.Fatalf("Expected no Date header; got %v", res.Header["Date"]) - } -} - -func TestStripPrefix(t *testing.T) { - defer afterTest(t) - h := HandlerFunc(func(w ResponseWriter, r *Request) { - w.Header().Set("X-Path", r.URL.Path) - }) - ts := httptest.NewServer(StripPrefix("/foo", h)) - defer ts.Close() - - res, err := Get(ts.URL + "/foo/bar") - if err != nil { - t.Fatal(err) - } - if g, e := res.Header.Get("X-Path"), "/bar"; g != e { - t.Errorf("test 1: got %s, want %s", g, e) - } - res.Body.Close() - - res, err = Get(ts.URL + "/bar") - if err != nil { - t.Fatal(err) - } - if g, e := res.StatusCode, 404; g != e { - t.Errorf("test 2: got status %v, want %v", g, e) - } - res.Body.Close() -} - -func TestRequestLimit(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - t.Fatalf("didn't expect to get request in Handler") - })) - defer ts.Close() - req, _ := NewRequest("GET", ts.URL, nil) - var bytesPerHeader = len("header12345: val12345\r\n") - for i := 0; i < ((DefaultMaxHeaderBytes+4096)/bytesPerHeader)+1; i++ { - req.Header.Set(fmt.Sprintf("header%05d", i), fmt.Sprintf("val%05d", i)) - } - res, err := DefaultClient.Do(req) - if err != nil { - // Some HTTP clients may fail on this undefined behavior (server replying and - // closing the connection while the request is still being written), but - // we do support it (at least currently), so we expect a response below. - t.Fatalf("Do: %v", err) - } - defer res.Body.Close() - if res.StatusCode != 413 { - t.Fatalf("expected 413 response status; got: %d %s", res.StatusCode, res.Status) - } -} - -type neverEnding byte - -func (b neverEnding) Read(p []byte) (n int, err error) { - for i := range p { - p[i] = byte(b) - } - return len(p), nil -} - -type countReader struct { - r io.Reader - n *int64 -} - -func (cr countReader) Read(p []byte) (n int, err error) { - n, err = cr.r.Read(p) - atomic.AddInt64(cr.n, int64(n)) - return -} - -func TestRequestBodyLimit(t *testing.T) { - defer afterTest(t) - const limit = 1 << 20 - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - r.Body = MaxBytesReader(w, r.Body, limit) - n, err := io.Copy(ioutil.Discard, r.Body) - if err == nil { - t.Errorf("expected error from io.Copy") - } - if n != limit { - t.Errorf("io.Copy = %d, want %d", n, limit) - } - })) - defer ts.Close() - - nWritten := new(int64) - req, _ := NewRequest("POST", ts.URL, io.LimitReader(countReader{neverEnding('a'), nWritten}, limit*200)) - - // Send the POST, but don't care it succeeds or not. The - // remote side is going to reply and then close the TCP - // connection, and HTTP doesn't really define if that's - // allowed or not. Some HTTP clients will get the response - // and some (like ours, currently) will complain that the - // request write failed, without reading the response. - // - // But that's okay, since what we're really testing is that - // the remote side hung up on us before we wrote too much. - _, _ = DefaultClient.Do(req) - - if atomic.LoadInt64(nWritten) > limit*100 { - t.Errorf("handler restricted the request body to %d bytes, but client managed to write %d", - limit, nWritten) - } -} - -// TestClientWriteShutdown tests that if the client shuts down the write -// side of their TCP connection, the server doesn't send a 400 Bad Request. -func TestClientWriteShutdown(t *testing.T) { - if runtime.GOOS == "plan9" { - t.Skip("skipping test; see http://golang.org/issue/7237") - } - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {})) - defer ts.Close() - conn, err := net.Dial("tcp", ts.Listener.Addr().String()) - if err != nil { - t.Fatalf("Dial: %v", err) - } - err = conn.(*net.TCPConn).CloseWrite() - if err != nil { - t.Fatalf("Dial: %v", err) - } - donec := make(chan bool) - go func() { - defer close(donec) - bs, err := ioutil.ReadAll(conn) - if err != nil { - t.Fatalf("ReadAll: %v", err) - } - got := string(bs) - if got != "" { - t.Errorf("read %q from server; want nothing", got) - } - }() - select { - case <-donec: - case <-time.After(10 * time.Second): - t.Fatalf("timeout") - } -} - -// Tests that chunked server responses that write 1 byte at a time are -// buffered before chunk headers are added, not after chunk headers. -func TestServerBufferedChunking(t *testing.T) { - conn := new(testConn) - conn.readBuf.Write([]byte("GET / HTTP/1.1\r\n\r\n")) - conn.closec = make(chan bool, 1) - ls := &oneConnListener{conn} - go Serve(ls, HandlerFunc(func(rw ResponseWriter, req *Request) { - rw.(Flusher).Flush() // force the Header to be sent, in chunking mode, not counting the length - rw.Write([]byte{'x'}) - rw.Write([]byte{'y'}) - rw.Write([]byte{'z'}) - })) - <-conn.closec - if !bytes.HasSuffix(conn.writeBuf.Bytes(), []byte("\r\n\r\n3\r\nxyz\r\n0\r\n\r\n")) { - t.Errorf("response didn't end with a single 3 byte 'xyz' chunk; got:\n%q", - conn.writeBuf.Bytes()) - } -} - -// Tests that the server flushes its response headers out when it's -// ignoring the response body and waits a bit before forcefully -// closing the TCP connection, causing the client to get a RST. -// See http://golang.org/issue/3595 -func TestServerGracefulClose(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - Error(w, "bye", StatusUnauthorized) - })) - defer ts.Close() - - conn, err := net.Dial("tcp", ts.Listener.Addr().String()) - if err != nil { - t.Fatal(err) - } - defer conn.Close() - const bodySize = 5 << 20 - req := []byte(fmt.Sprintf("POST / HTTP/1.1\r\nHost: foo.com\r\nContent-Length: %d\r\n\r\n", bodySize)) - for i := 0; i < bodySize; i++ { - req = append(req, 'x') - } - writeErr := make(chan error) - go func() { - _, err := conn.Write(req) - writeErr <- err - }() - br := bufio.NewReader(conn) - lineNum := 0 - for { - line, err := br.ReadString('\n') - if err == io.EOF { - break - } - if err != nil { - t.Fatalf("ReadLine: %v", err) - } - lineNum++ - if lineNum == 1 && !strings.Contains(line, "401 Unauthorized") { - t.Errorf("Response line = %q; want a 401", line) - } - } - // Wait for write to finish. This is a broken pipe on both - // Darwin and Linux, but checking this isn't the point of - // the test. - <-writeErr -} - -func TestCaseSensitiveMethod(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - if r.Method != "get" { - t.Errorf(`Got method %q; want "get"`, r.Method) - } - })) - defer ts.Close() - req, _ := NewRequest("get", ts.URL, nil) - res, err := DefaultClient.Do(req) - if err != nil { - t.Error(err) - return - } - res.Body.Close() -} - -// TestContentLengthZero tests that for both an HTTP/1.0 and HTTP/1.1 -// request (both keep-alive), when a Handler never writes any -// response, the net/http package adds a "Content-Length: 0" response -// header. -func TestContentLengthZero(t *testing.T) { - ts := httptest.NewServer(HandlerFunc(func(rw ResponseWriter, req *Request) {})) - defer ts.Close() - - for _, version := range []string{"HTTP/1.0", "HTTP/1.1"} { - conn, err := net.Dial("tcp", ts.Listener.Addr().String()) - if err != nil { - t.Fatalf("error dialing: %v", err) - } - _, err = fmt.Fprintf(conn, "GET / %v\r\nConnection: keep-alive\r\nHost: foo\r\n\r\n", version) - if err != nil { - t.Fatalf("error writing: %v", err) - } - req, _ := NewRequest("GET", "/", nil) - res, err := ReadResponse(bufio.NewReader(conn), req) - if err != nil { - t.Fatalf("error reading response: %v", err) - } - if te := res.TransferEncoding; len(te) > 0 { - t.Errorf("For version %q, Transfer-Encoding = %q; want none", version, te) - } - if cl := res.ContentLength; cl != 0 { - t.Errorf("For version %q, Content-Length = %v; want 0", version, cl) - } - conn.Close() - } -} - -func TestCloseNotifier(t *testing.T) { - defer afterTest(t) - gotReq := make(chan bool, 1) - sawClose := make(chan bool, 1) - ts := httptest.NewServer(HandlerFunc(func(rw ResponseWriter, req *Request) { - gotReq <- true - cc := rw.(CloseNotifier).CloseNotify() - <-cc - sawClose <- true - })) - conn, err := net.Dial("tcp", ts.Listener.Addr().String()) - if err != nil { - t.Fatalf("error dialing: %v", err) - } - diec := make(chan bool) - go func() { - _, err = fmt.Fprintf(conn, "GET / HTTP/1.1\r\nConnection: keep-alive\r\nHost: foo\r\n\r\n") - if err != nil { - t.Fatal(err) - } - <-diec - conn.Close() - }() -For: - for { - select { - case <-gotReq: - diec <- true - case <-sawClose: - break For - case <-time.After(5 * time.Second): - t.Fatal("timeout") - } - } - ts.Close() -} - -func TestCloseNotifierChanLeak(t *testing.T) { - defer afterTest(t) - req := reqBytes("GET / HTTP/1.0\nHost: golang.org") - for i := 0; i < 20; i++ { - var output bytes.Buffer - conn := &rwTestConn{ - Reader: bytes.NewReader(req), - Writer: &output, - closec: make(chan bool, 1), - } - ln := &oneConnListener{conn: conn} - handler := HandlerFunc(func(rw ResponseWriter, r *Request) { - // Ignore the return value and never read from - // it, testing that we don't leak goroutines - // on the sending side: - _ = rw.(CloseNotifier).CloseNotify() - }) - go Serve(ln, handler) - <-conn.closec - } -} - -func TestOptions(t *testing.T) { - uric := make(chan string, 2) // only expect 1, but leave space for 2 - mux := NewServeMux() - mux.HandleFunc("/", func(w ResponseWriter, r *Request) { - uric <- r.RequestURI - }) - ts := httptest.NewServer(mux) - defer ts.Close() - - conn, err := net.Dial("tcp", ts.Listener.Addr().String()) - if err != nil { - t.Fatal(err) - } - defer conn.Close() - - // An OPTIONS * request should succeed. - _, err = conn.Write([]byte("OPTIONS * HTTP/1.1\r\nHost: foo.com\r\n\r\n")) - if err != nil { - t.Fatal(err) - } - br := bufio.NewReader(conn) - res, err := ReadResponse(br, &Request{Method: "OPTIONS"}) - if err != nil { - t.Fatal(err) - } - if res.StatusCode != 200 { - t.Errorf("Got non-200 response to OPTIONS *: %#v", res) - } - - // A GET * request on a ServeMux should fail. - _, err = conn.Write([]byte("GET * HTTP/1.1\r\nHost: foo.com\r\n\r\n")) - if err != nil { - t.Fatal(err) - } - res, err = ReadResponse(br, &Request{Method: "GET"}) - if err != nil { - t.Fatal(err) - } - if res.StatusCode != 400 { - t.Errorf("Got non-400 response to GET *: %#v", res) - } - - res, err = Get(ts.URL + "/second") - if err != nil { - t.Fatal(err) - } - res.Body.Close() - if got := <-uric; got != "/second" { - t.Errorf("Handler saw request for %q; want /second", got) - } -} - -// Tests regarding the ordering of Write, WriteHeader, Header, and -// Flush calls. In Go 1.0, rw.WriteHeader immediately flushed the -// (*response).header to the wire. In Go 1.1, the actual wire flush is -// delayed, so we could maybe tack on a Content-Length and better -// Content-Type after we see more (or all) of the output. To preserve -// compatibility with Go 1, we need to be careful to track which -// headers were live at the time of WriteHeader, so we write the same -// ones, even if the handler modifies them (~erroneously) after the -// first Write. -func TestHeaderToWire(t *testing.T) { - tests := []struct { - name string - handler func(ResponseWriter, *Request) - check func(output string) error - }{ - { - name: "write without Header", - handler: func(rw ResponseWriter, r *Request) { - rw.Write([]byte("hello world")) - }, - check: func(got string) error { - if !strings.Contains(got, "Content-Length:") { - return errors.New("no content-length") - } - if !strings.Contains(got, "Content-Type: text/plain") { - return errors.New("no content-length") - } - return nil - }, - }, - { - name: "Header mutation before write", - handler: func(rw ResponseWriter, r *Request) { - h := rw.Header() - h.Set("Content-Type", "some/type") - rw.Write([]byte("hello world")) - h.Set("Too-Late", "bogus") - }, - check: func(got string) error { - if !strings.Contains(got, "Content-Length:") { - return errors.New("no content-length") - } - if !strings.Contains(got, "Content-Type: some/type") { - return errors.New("wrong content-type") - } - if strings.Contains(got, "Too-Late") { - return errors.New("don't want too-late header") - } - return nil - }, - }, - { - name: "write then useless Header mutation", - handler: func(rw ResponseWriter, r *Request) { - rw.Write([]byte("hello world")) - rw.Header().Set("Too-Late", "Write already wrote headers") - }, - check: func(got string) error { - if strings.Contains(got, "Too-Late") { - return errors.New("header appeared from after WriteHeader") - } - return nil - }, - }, - { - name: "flush then write", - handler: func(rw ResponseWriter, r *Request) { - rw.(Flusher).Flush() - rw.Write([]byte("post-flush")) - rw.Header().Set("Too-Late", "Write already wrote headers") - }, - check: func(got string) error { - if !strings.Contains(got, "Transfer-Encoding: chunked") { - return errors.New("not chunked") - } - if strings.Contains(got, "Too-Late") { - return errors.New("header appeared from after WriteHeader") - } - return nil - }, - }, - { - name: "header then flush", - handler: func(rw ResponseWriter, r *Request) { - rw.Header().Set("Content-Type", "some/type") - rw.(Flusher).Flush() - rw.Write([]byte("post-flush")) - rw.Header().Set("Too-Late", "Write already wrote headers") - }, - check: func(got string) error { - if !strings.Contains(got, "Transfer-Encoding: chunked") { - return errors.New("not chunked") - } - if strings.Contains(got, "Too-Late") { - return errors.New("header appeared from after WriteHeader") - } - if !strings.Contains(got, "Content-Type: some/type") { - return errors.New("wrong content-length") - } - return nil - }, - }, - { - name: "sniff-on-first-write content-type", - handler: func(rw ResponseWriter, r *Request) { - rw.Write([]byte("some html")) - rw.Header().Set("Content-Type", "x/wrong") - }, - check: func(got string) error { - if !strings.Contains(got, "Content-Type: text/html") { - return errors.New("wrong content-length; want html") - } - return nil - }, - }, - { - name: "explicit content-type wins", - handler: func(rw ResponseWriter, r *Request) { - rw.Header().Set("Content-Type", "some/type") - rw.Write([]byte("some html")) - }, - check: func(got string) error { - if !strings.Contains(got, "Content-Type: some/type") { - return errors.New("wrong content-length; want html") - } - return nil - }, - }, - { - name: "empty handler", - handler: func(rw ResponseWriter, r *Request) { - }, - check: func(got string) error { - if !strings.Contains(got, "Content-Type: text/plain") { - return errors.New("wrong content-length; want text/plain") - } - if !strings.Contains(got, "Content-Length: 0") { - return errors.New("want 0 content-length") - } - return nil - }, - }, - { - name: "only Header, no write", - handler: func(rw ResponseWriter, r *Request) { - rw.Header().Set("Some-Header", "some-value") - }, - check: func(got string) error { - if !strings.Contains(got, "Some-Header") { - return errors.New("didn't get header") - } - return nil - }, - }, - { - name: "WriteHeader call", - handler: func(rw ResponseWriter, r *Request) { - rw.WriteHeader(404) - rw.Header().Set("Too-Late", "some-value") - }, - check: func(got string) error { - if !strings.Contains(got, "404") { - return errors.New("wrong status") - } - if strings.Contains(got, "Some-Header") { - return errors.New("shouldn't have seen Too-Late") - } - return nil - }, - }, - } - for _, tc := range tests { - ht := newHandlerTest(HandlerFunc(tc.handler)) - got := ht.rawResponse("GET / HTTP/1.1\nHost: golang.org") - if err := tc.check(got); err != nil { - t.Errorf("%s: %v\nGot response:\n%s", tc.name, err, got) - } - } -} - -// goTimeout runs f, failing t if f takes more than ns to complete. -func goTimeout(t *testing.T, d time.Duration, f func()) { - ch := make(chan bool, 2) - timer := time.AfterFunc(d, func() { - t.Errorf("Timeout expired after %v", d) - ch <- true - }) - defer timer.Stop() - go func() { - defer func() { ch <- true }() - f() - }() - <-ch -} - -type errorListener struct { - errs []error -} - -func (l *errorListener) Accept() (c net.Conn, err error) { - if len(l.errs) == 0 { - return nil, io.EOF - } - err = l.errs[0] - l.errs = l.errs[1:] - return -} - -func (l *errorListener) Close() error { - return nil -} - -func (l *errorListener) Addr() net.Addr { - return dummyAddr("test-address") -} - -func TestAcceptMaxFds(t *testing.T) { - log.SetOutput(ioutil.Discard) // is noisy otherwise - defer log.SetOutput(os.Stderr) - - ln := &errorListener{[]error{ - &net.OpError{ - Op: "accept", - Err: syscall.EMFILE, - }}} - err := Serve(ln, HandlerFunc(HandlerFunc(func(ResponseWriter, *Request) {}))) - if err != io.EOF { - t.Errorf("got error %v, want EOF", err) - } -} - -func TestWriteAfterHijack(t *testing.T) { - req := reqBytes("GET / HTTP/1.1\nHost: golang.org") - var buf bytes.Buffer - wrotec := make(chan bool, 1) - conn := &rwTestConn{ - Reader: bytes.NewReader(req), - Writer: &buf, - closec: make(chan bool, 1), - } - handler := HandlerFunc(func(rw ResponseWriter, r *Request) { - conn, bufrw, err := rw.(Hijacker).Hijack() - if err != nil { - t.Error(err) - return - } - go func() { - bufrw.Write([]byte("[hijack-to-bufw]")) - bufrw.Flush() - conn.Write([]byte("[hijack-to-conn]")) - conn.Close() - wrotec <- true - }() - }) - ln := &oneConnListener{conn: conn} - go Serve(ln, handler) - <-conn.closec - <-wrotec - if g, w := buf.String(), "[hijack-to-bufw][hijack-to-conn]"; g != w { - t.Errorf("wrote %q; want %q", g, w) - } -} - -func TestDoubleHijack(t *testing.T) { - req := reqBytes("GET / HTTP/1.1\nHost: golang.org") - var buf bytes.Buffer - conn := &rwTestConn{ - Reader: bytes.NewReader(req), - Writer: &buf, - closec: make(chan bool, 1), - } - handler := HandlerFunc(func(rw ResponseWriter, r *Request) { - conn, _, err := rw.(Hijacker).Hijack() - if err != nil { - t.Error(err) - return - } - _, _, err = rw.(Hijacker).Hijack() - if err == nil { - t.Errorf("got err = nil; want err != nil") - } - conn.Close() - }) - ln := &oneConnListener{conn: conn} - go Serve(ln, handler) - <-conn.closec -} - -// http://code.google.com/p/go/issues/detail?id=5955 -// Note that this does not test the "request too large" -// exit path from the http server. This is intentional; -// not sending Connection: close is just a minor wire -// optimization and is pointless if dealing with a -// badly behaved client. -func TestHTTP10ConnectionHeader(t *testing.T) { - defer afterTest(t) - - mux := NewServeMux() - mux.Handle("/", HandlerFunc(func(resp ResponseWriter, req *Request) {})) - ts := httptest.NewServer(mux) - defer ts.Close() - - // net/http uses HTTP/1.1 for requests, so write requests manually - tests := []struct { - req string // raw http request - expect []string // expected Connection header(s) - }{ - { - req: "GET / HTTP/1.0\r\n\r\n", - expect: nil, - }, - { - req: "OPTIONS * HTTP/1.0\r\n\r\n", - expect: nil, - }, - { - req: "GET / HTTP/1.0\r\nConnection: keep-alive\r\n\r\n", - expect: []string{"keep-alive"}, - }, - } - - for _, tt := range tests { - conn, err := net.Dial("tcp", ts.Listener.Addr().String()) - if err != nil { - t.Fatal("dial err:", err) - } - - _, err = fmt.Fprint(conn, tt.req) - if err != nil { - t.Fatal("conn write err:", err) - } - - resp, err := ReadResponse(bufio.NewReader(conn), &Request{Method: "GET"}) - if err != nil { - t.Fatal("ReadResponse err:", err) - } - conn.Close() - resp.Body.Close() - - got := resp.Header["Connection"] - if !reflect.DeepEqual(got, tt.expect) { - t.Errorf("wrong Connection headers for request %q. Got %q expect %q", tt.req, got, tt.expect) - } - } -} - -// See golang.org/issue/5660 -func TestServerReaderFromOrder(t *testing.T) { - defer afterTest(t) - pr, pw := io.Pipe() - const size = 3 << 20 - ts := httptest.NewServer(HandlerFunc(func(rw ResponseWriter, req *Request) { - rw.Header().Set("Content-Type", "text/plain") // prevent sniffing path - done := make(chan bool) - go func() { - io.Copy(rw, pr) - close(done) - }() - time.Sleep(25 * time.Millisecond) // give Copy a chance to break things - n, err := io.Copy(ioutil.Discard, req.Body) - if err != nil { - t.Errorf("handler Copy: %v", err) - return - } - if n != size { - t.Errorf("handler Copy = %d; want %d", n, size) - } - pw.Write([]byte("hi")) - pw.Close() - <-done - })) - defer ts.Close() - - req, err := NewRequest("POST", ts.URL, io.LimitReader(neverEnding('a'), size)) - if err != nil { - t.Fatal(err) - } - res, err := DefaultClient.Do(req) - if err != nil { - t.Fatal(err) - } - all, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatal(err) - } - res.Body.Close() - if string(all) != "hi" { - t.Errorf("Body = %q; want hi", all) - } -} - -// Issue 6157, Issue 6685 -func TestCodesPreventingContentTypeAndBody(t *testing.T) { - for _, code := range []int{StatusNotModified, StatusNoContent, StatusContinue} { - ht := newHandlerTest(HandlerFunc(func(w ResponseWriter, r *Request) { - if r.URL.Path == "/header" { - w.Header().Set("Content-Length", "123") - } - w.WriteHeader(code) - if r.URL.Path == "/more" { - w.Write([]byte("stuff")) - } - })) - for _, req := range []string{ - "GET / HTTP/1.0", - "GET /header HTTP/1.0", - "GET /more HTTP/1.0", - "GET / HTTP/1.1", - "GET /header HTTP/1.1", - "GET /more HTTP/1.1", - } { - got := ht.rawResponse(req) - wantStatus := fmt.Sprintf("%d %s", code, StatusText(code)) - if !strings.Contains(got, wantStatus) { - t.Errorf("Code %d: Wanted %q Modified for %q: %s", code, wantStatus, req, got) - } else if strings.Contains(got, "Content-Length") { - t.Errorf("Code %d: Got a Content-Length from %q: %s", code, req, got) - } else if strings.Contains(got, "stuff") { - t.Errorf("Code %d: Response contains a body from %q: %s", code, req, got) - } - } - } -} - -func TestContentTypeOkayOn204(t *testing.T) { - ht := newHandlerTest(HandlerFunc(func(w ResponseWriter, r *Request) { - w.Header().Set("Content-Length", "123") // suppressed - w.Header().Set("Content-Type", "foo/bar") - w.WriteHeader(204) - })) - got := ht.rawResponse("GET / HTTP/1.1") - if !strings.Contains(got, "Content-Type: foo/bar") { - t.Errorf("Response = %q; want Content-Type: foo/bar", got) - } - if strings.Contains(got, "Content-Length: 123") { - t.Errorf("Response = %q; don't want a Content-Length", got) - } -} - -// Issue 6995 -// A server Handler can receive a Request, and then turn around and -// give a copy of that Request.Body out to the Transport (e.g. any -// proxy). So then two people own that Request.Body (both the server -// and the http client), and both think they can close it on failure. -// Therefore, all incoming server requests Bodies need to be thread-safe. -func TestTransportAndServerSharedBodyRace(t *testing.T) { - defer afterTest(t) - - const bodySize = 1 << 20 - - unblockBackend := make(chan bool) - backend := httptest.NewServer(HandlerFunc(func(rw ResponseWriter, req *Request) { - io.CopyN(rw, req.Body, bodySize/2) - <-unblockBackend - })) - defer backend.Close() - - backendRespc := make(chan *Response, 1) - proxy := httptest.NewServer(HandlerFunc(func(rw ResponseWriter, req *Request) { - if req.RequestURI == "/foo" { - rw.Write([]byte("bar")) - return - } - req2, _ := NewRequest("POST", backend.URL, req.Body) - req2.ContentLength = bodySize - - bresp, err := DefaultClient.Do(req2) - if err != nil { - t.Errorf("Proxy outbound request: %v", err) - return - } - _, err = io.CopyN(ioutil.Discard, bresp.Body, bodySize/4) - if err != nil { - t.Errorf("Proxy copy error: %v", err) - return - } - backendRespc <- bresp // to close later - - // Try to cause a race: Both the DefaultTransport and the proxy handler's Server - // will try to read/close req.Body (aka req2.Body) - DefaultTransport.(*Transport).CancelRequest(req2) - rw.Write([]byte("OK")) - })) - defer proxy.Close() - - req, _ := NewRequest("POST", proxy.URL, io.LimitReader(neverEnding('a'), bodySize)) - res, err := DefaultClient.Do(req) - if err != nil { - t.Fatalf("Original request: %v", err) - } - - // Cleanup, so we don't leak goroutines. - res.Body.Close() - close(unblockBackend) - (<-backendRespc).Body.Close() -} - -// Test that a hanging Request.Body.Read from another goroutine can't -// cause the Handler goroutine's Request.Body.Close to block. -func TestRequestBodyCloseDoesntBlock(t *testing.T) { - t.Skipf("Skipping known issue; see golang.org/issue/7121") - if testing.Short() { - t.Skip("skipping in -short mode") - } - defer afterTest(t) - - readErrCh := make(chan error, 1) - errCh := make(chan error, 2) - - server := httptest.NewServer(HandlerFunc(func(rw ResponseWriter, req *Request) { - go func(body io.Reader) { - _, err := body.Read(make([]byte, 100)) - readErrCh <- err - }(req.Body) - time.Sleep(500 * time.Millisecond) - })) - defer server.Close() - - closeConn := make(chan bool) - defer close(closeConn) - go func() { - conn, err := net.Dial("tcp", server.Listener.Addr().String()) - if err != nil { - errCh <- err - return - } - defer conn.Close() - _, err = conn.Write([]byte("POST / HTTP/1.1\r\nConnection: close\r\nHost: foo\r\nContent-Length: 100000\r\n\r\n")) - if err != nil { - errCh <- err - return - } - // And now just block, making the server block on our - // 100000 bytes of body that will never arrive. - <-closeConn - }() - select { - case err := <-readErrCh: - if err == nil { - t.Error("Read was nil. Expected error.") - } - case err := <-errCh: - t.Error(err) - case <-time.After(5 * time.Second): - t.Error("timeout") - } -} - -func TestResponseWriterWriteStringAllocs(t *testing.T) { - ht := newHandlerTest(HandlerFunc(func(w ResponseWriter, r *Request) { - if r.URL.Path == "/s" { - io.WriteString(w, "Hello world") - } else { - w.Write([]byte("Hello world")) - } - })) - before := testing.AllocsPerRun(50, func() { ht.rawResponse("GET / HTTP/1.0") }) - after := testing.AllocsPerRun(50, func() { ht.rawResponse("GET /s HTTP/1.0") }) - if int(after) >= int(before) { - t.Errorf("WriteString allocs of %v >= Write allocs of %v", after, before) - } -} - -func TestAppendTime(t *testing.T) { - var b [len(TimeFormat)]byte - t1 := time.Date(2013, 9, 21, 15, 41, 0, 0, time.FixedZone("CEST", 2*60*60)) - res := ExportAppendTime(b[:0], t1) - t2, err := ParseTime(string(res)) - if err != nil { - t.Fatalf("Error parsing time: %s", err) - } - if !t1.Equal(t2) { - t.Fatalf("Times differ; expected: %v, got %v (%s)", t1, t2, string(res)) - } -} - -func TestServerConnState(t *testing.T) { - defer afterTest(t) - handler := map[string]func(w ResponseWriter, r *Request){ - "/": func(w ResponseWriter, r *Request) { - fmt.Fprintf(w, "Hello.") - }, - "/close": func(w ResponseWriter, r *Request) { - w.Header().Set("Connection", "close") - fmt.Fprintf(w, "Hello.") - }, - "/hijack": func(w ResponseWriter, r *Request) { - c, _, _ := w.(Hijacker).Hijack() - c.Write([]byte("HTTP/1.0 200 OK\r\nConnection: close\r\n\r\nHello.")) - c.Close() - }, - "/hijack-panic": func(w ResponseWriter, r *Request) { - c, _, _ := w.(Hijacker).Hijack() - c.Write([]byte("HTTP/1.0 200 OK\r\nConnection: close\r\n\r\nHello.")) - c.Close() - panic("intentional panic") - }, - } - ts := httptest.NewUnstartedServer(HandlerFunc(func(w ResponseWriter, r *Request) { - handler[r.URL.Path](w, r) - })) - defer ts.Close() - - var mu sync.Mutex // guard stateLog and connID - var stateLog = map[int][]ConnState{} - var connID = map[net.Conn]int{} - - ts.Config.ErrorLog = log.New(ioutil.Discard, "", 0) - ts.Config.ConnState = func(c net.Conn, state ConnState) { - if c == nil { - t.Errorf("nil conn seen in state %s", state) - return - } - mu.Lock() - defer mu.Unlock() - id, ok := connID[c] - if !ok { - id = len(connID) + 1 - connID[c] = id - } - stateLog[id] = append(stateLog[id], state) - } - ts.Start() - - mustGet(t, ts.URL+"/") - mustGet(t, ts.URL+"/close") - - mustGet(t, ts.URL+"/") - mustGet(t, ts.URL+"/", "Connection", "close") - - mustGet(t, ts.URL+"/hijack") - mustGet(t, ts.URL+"/hijack-panic") - - // New->Closed - { - c, err := net.Dial("tcp", ts.Listener.Addr().String()) - if err != nil { - t.Fatal(err) - } - c.Close() - } - - // New->Active->Closed - { - c, err := net.Dial("tcp", ts.Listener.Addr().String()) - if err != nil { - t.Fatal(err) - } - if _, err := io.WriteString(c, "BOGUS REQUEST\r\n\r\n"); err != nil { - t.Fatal(err) - } - c.Close() - } - - // New->Idle->Closed - { - c, err := net.Dial("tcp", ts.Listener.Addr().String()) - if err != nil { - t.Fatal(err) - } - if _, err := io.WriteString(c, "GET / HTTP/1.1\r\nHost: foo\r\n\r\n"); err != nil { - t.Fatal(err) - } - res, err := ReadResponse(bufio.NewReader(c), nil) - if err != nil { - t.Fatal(err) - } - if _, err := io.Copy(ioutil.Discard, res.Body); err != nil { - t.Fatal(err) - } - c.Close() - } - - want := map[int][]ConnState{ - 1: []ConnState{StateNew, StateActive, StateIdle, StateActive, StateClosed}, - 2: []ConnState{StateNew, StateActive, StateIdle, StateActive, StateClosed}, - 3: []ConnState{StateNew, StateActive, StateHijacked}, - 4: []ConnState{StateNew, StateActive, StateHijacked}, - 5: []ConnState{StateNew, StateClosed}, - 6: []ConnState{StateNew, StateActive, StateClosed}, - 7: []ConnState{StateNew, StateActive, StateIdle, StateClosed}, - } - logString := func(m map[int][]ConnState) string { - var b bytes.Buffer - for id, l := range m { - fmt.Fprintf(&b, "Conn %d: ", id) - for _, s := range l { - fmt.Fprintf(&b, "%s ", s) - } - b.WriteString("\n") - } - return b.String() - } - - for i := 0; i < 5; i++ { - time.Sleep(time.Duration(i) * 50 * time.Millisecond) - mu.Lock() - match := reflect.DeepEqual(stateLog, want) - mu.Unlock() - if match { - return - } - } - - mu.Lock() - t.Errorf("Unexpected events.\nGot log: %s\n Want: %s\n", logString(stateLog), logString(want)) - mu.Unlock() -} - -func mustGet(t *testing.T, url string, headers ...string) { - req, err := NewRequest("GET", url, nil) - if err != nil { - t.Fatal(err) - } - for len(headers) > 0 { - req.Header.Add(headers[0], headers[1]) - headers = headers[2:] - } - res, err := DefaultClient.Do(req) - if err != nil { - t.Errorf("Error fetching %s: %v", url, err) - return - } - _, err = ioutil.ReadAll(res.Body) - defer res.Body.Close() - if err != nil { - t.Errorf("Error reading %s: %v", url, err) - } -} - -func TestServerKeepAlivesEnabled(t *testing.T) { - defer afterTest(t) - ts := httptest.NewUnstartedServer(HandlerFunc(func(w ResponseWriter, r *Request) {})) - ts.Config.SetKeepAlivesEnabled(false) - ts.Start() - defer ts.Close() - res, err := Get(ts.URL) - if err != nil { - t.Fatal(err) - } - defer res.Body.Close() - if !res.Close { - t.Errorf("Body.Close == false; want true") - } -} - -// golang.org/issue/7856 -func TestServerEmptyBodyRace(t *testing.T) { - defer afterTest(t) - var n int32 - ts := httptest.NewServer(HandlerFunc(func(rw ResponseWriter, req *Request) { - atomic.AddInt32(&n, 1) - })) - defer ts.Close() - var wg sync.WaitGroup - const reqs = 20 - for i := 0; i < reqs; i++ { - wg.Add(1) - go func() { - defer wg.Done() - res, err := Get(ts.URL) - if err != nil { - t.Error(err) - return - } - defer res.Body.Close() - _, err = io.Copy(ioutil.Discard, res.Body) - if err != nil { - t.Error(err) - return - } - }() - } - wg.Wait() - if got := atomic.LoadInt32(&n); got != reqs { - t.Errorf("handler ran %d times; want %d", got, reqs) - } -} - -func TestServerConnStateNew(t *testing.T) { - sawNew := false // if the test is buggy, we'll race on this variable. - srv := &Server{ - ConnState: func(c net.Conn, state ConnState) { - if state == StateNew { - sawNew = true // testing that this write isn't racy - } - }, - Handler: HandlerFunc(func(w ResponseWriter, r *Request) {}), // irrelevant - } - srv.Serve(&oneConnListener{ - conn: &rwTestConn{ - Reader: strings.NewReader("GET / HTTP/1.1\r\nHost: foo\r\n\r\n"), - Writer: ioutil.Discard, - }, - }) - if !sawNew { // testing that this read isn't racy - t.Error("StateNew not seen") - } -} - -func BenchmarkClientServer(b *testing.B) { - b.ReportAllocs() - b.StopTimer() - ts := httptest.NewServer(HandlerFunc(func(rw ResponseWriter, r *Request) { - fmt.Fprintf(rw, "Hello world.\n") - })) - defer ts.Close() - b.StartTimer() - - for i := 0; i < b.N; i++ { - res, err := Get(ts.URL) - if err != nil { - b.Fatal("Get:", err) - } - all, err := ioutil.ReadAll(res.Body) - res.Body.Close() - if err != nil { - b.Fatal("ReadAll:", err) - } - body := string(all) - if body != "Hello world.\n" { - b.Fatal("Got body:", body) - } - } - - b.StopTimer() -} - -func BenchmarkClientServerParallel4(b *testing.B) { - benchmarkClientServerParallel(b, 4) -} - -func BenchmarkClientServerParallel64(b *testing.B) { - benchmarkClientServerParallel(b, 64) -} - -func benchmarkClientServerParallel(b *testing.B, parallelism int) { - b.ReportAllocs() - ts := httptest.NewServer(HandlerFunc(func(rw ResponseWriter, r *Request) { - fmt.Fprintf(rw, "Hello world.\n") - })) - defer ts.Close() - b.ResetTimer() - b.SetParallelism(parallelism) - b.RunParallel(func(pb *testing.PB) { - for pb.Next() { - res, err := Get(ts.URL) - if err != nil { - b.Logf("Get: %v", err) - continue - } - all, err := ioutil.ReadAll(res.Body) - res.Body.Close() - if err != nil { - b.Logf("ReadAll: %v", err) - continue - } - body := string(all) - if body != "Hello world.\n" { - panic("Got body: " + body) - } - } - }) -} - -// A benchmark for profiling the server without the HTTP client code. -// The client code runs in a subprocess. -// -// For use like: -// $ go test -c -// $ ./http.test -test.run=XX -test.bench=BenchmarkServer -test.benchtime=15s -test.cpuprofile=http.prof -// $ go tool pprof http.test http.prof -// (pprof) web -func BenchmarkServer(b *testing.B) { - b.ReportAllocs() - // Child process mode; - if url := os.Getenv("TEST_BENCH_SERVER_URL"); url != "" { - n, err := strconv.Atoi(os.Getenv("TEST_BENCH_CLIENT_N")) - if err != nil { - panic(err) - } - for i := 0; i < n; i++ { - res, err := Get(url) - if err != nil { - log.Panicf("Get: %v", err) - } - all, err := ioutil.ReadAll(res.Body) - res.Body.Close() - if err != nil { - log.Panicf("ReadAll: %v", err) - } - body := string(all) - if body != "Hello world.\n" { - log.Panicf("Got body: %q", body) - } - } - os.Exit(0) - return - } - - var res = []byte("Hello world.\n") - b.StopTimer() - ts := httptest.NewServer(HandlerFunc(func(rw ResponseWriter, r *Request) { - rw.Header().Set("Content-Type", "text/html; charset=utf-8") - rw.Write(res) - })) - defer ts.Close() - b.StartTimer() - - cmd := exec.Command(os.Args[0], "-test.run=XXXX", "-test.bench=BenchmarkServer") - cmd.Env = append([]string{ - fmt.Sprintf("TEST_BENCH_CLIENT_N=%d", b.N), - fmt.Sprintf("TEST_BENCH_SERVER_URL=%s", ts.URL), - }, os.Environ()...) - out, err := cmd.CombinedOutput() - if err != nil { - b.Errorf("Test failure: %v, with output: %s", err, out) - } -} - -func BenchmarkServerFakeConnNoKeepAlive(b *testing.B) { - b.ReportAllocs() - req := reqBytes(`GET / HTTP/1.0 -Host: golang.org -Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 -User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17 -Accept-Encoding: gzip,deflate,sdch -Accept-Language: en-US,en;q=0.8 -Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 -`) - res := []byte("Hello world!\n") - - conn := &testConn{ - // testConn.Close will not push into the channel - // if it's full. - closec: make(chan bool, 1), - } - handler := HandlerFunc(func(rw ResponseWriter, r *Request) { - rw.Header().Set("Content-Type", "text/html; charset=utf-8") - rw.Write(res) - }) - ln := new(oneConnListener) - for i := 0; i < b.N; i++ { - conn.readBuf.Reset() - conn.writeBuf.Reset() - conn.readBuf.Write(req) - ln.conn = conn - Serve(ln, handler) - <-conn.closec - } -} - -// repeatReader reads content count times, then EOFs. -type repeatReader struct { - content []byte - count int - off int -} - -func (r *repeatReader) Read(p []byte) (n int, err error) { - if r.count <= 0 { - return 0, io.EOF - } - n = copy(p, r.content[r.off:]) - r.off += n - if r.off == len(r.content) { - r.count-- - r.off = 0 - } - return -} - -func BenchmarkServerFakeConnWithKeepAlive(b *testing.B) { - b.ReportAllocs() - - req := reqBytes(`GET / HTTP/1.1 -Host: golang.org -Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 -User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17 -Accept-Encoding: gzip,deflate,sdch -Accept-Language: en-US,en;q=0.8 -Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 -`) - res := []byte("Hello world!\n") - - conn := &rwTestConn{ - Reader: &repeatReader{content: req, count: b.N}, - Writer: ioutil.Discard, - closec: make(chan bool, 1), - } - handled := 0 - handler := HandlerFunc(func(rw ResponseWriter, r *Request) { - handled++ - rw.Header().Set("Content-Type", "text/html; charset=utf-8") - rw.Write(res) - }) - ln := &oneConnListener{conn: conn} - go Serve(ln, handler) - <-conn.closec - if b.N != handled { - b.Errorf("b.N=%d but handled %d", b.N, handled) - } -} - -// same as above, but representing the most simple possible request -// and handler. Notably: the handler does not call rw.Header(). -func BenchmarkServerFakeConnWithKeepAliveLite(b *testing.B) { - b.ReportAllocs() - - req := reqBytes(`GET / HTTP/1.1 -Host: golang.org -`) - res := []byte("Hello world!\n") - - conn := &rwTestConn{ - Reader: &repeatReader{content: req, count: b.N}, - Writer: ioutil.Discard, - closec: make(chan bool, 1), - } - handled := 0 - handler := HandlerFunc(func(rw ResponseWriter, r *Request) { - handled++ - rw.Write(res) - }) - ln := &oneConnListener{conn: conn} - go Serve(ln, handler) - <-conn.closec - if b.N != handled { - b.Errorf("b.N=%d but handled %d", b.N, handled) - } -} - -const someResponse = "some response" - -// A Response that's just no bigger than 2KB, the buffer-before-chunking threshold. -var response = bytes.Repeat([]byte(someResponse), 2<<10/len(someResponse)) - -// Both Content-Type and Content-Length set. Should be no buffering. -func BenchmarkServerHandlerTypeLen(b *testing.B) { - benchmarkHandler(b, HandlerFunc(func(w ResponseWriter, r *Request) { - w.Header().Set("Content-Type", "text/html") - w.Header().Set("Content-Length", strconv.Itoa(len(response))) - w.Write(response) - })) -} - -// A Content-Type is set, but no length. No sniffing, but will count the Content-Length. -func BenchmarkServerHandlerNoLen(b *testing.B) { - benchmarkHandler(b, HandlerFunc(func(w ResponseWriter, r *Request) { - w.Header().Set("Content-Type", "text/html") - w.Write(response) - })) -} - -// A Content-Length is set, but the Content-Type will be sniffed. -func BenchmarkServerHandlerNoType(b *testing.B) { - benchmarkHandler(b, HandlerFunc(func(w ResponseWriter, r *Request) { - w.Header().Set("Content-Length", strconv.Itoa(len(response))) - w.Write(response) - })) -} - -// Neither a Content-Type or Content-Length, so sniffed and counted. -func BenchmarkServerHandlerNoHeader(b *testing.B) { - benchmarkHandler(b, HandlerFunc(func(w ResponseWriter, r *Request) { - w.Write(response) - })) -} - -func benchmarkHandler(b *testing.B, h Handler) { - b.ReportAllocs() - req := reqBytes(`GET / HTTP/1.1 -Host: golang.org -`) - conn := &rwTestConn{ - Reader: &repeatReader{content: req, count: b.N}, - Writer: ioutil.Discard, - closec: make(chan bool, 1), - } - handled := 0 - handler := HandlerFunc(func(rw ResponseWriter, r *Request) { - handled++ - h.ServeHTTP(rw, r) - }) - ln := &oneConnListener{conn: conn} - go Serve(ln, handler) - <-conn.closec - if b.N != handled { - b.Errorf("b.N=%d but handled %d", b.N, handled) - } -} - -func BenchmarkServerHijack(b *testing.B) { - b.ReportAllocs() - req := reqBytes(`GET / HTTP/1.1 -Host: golang.org -`) - h := HandlerFunc(func(w ResponseWriter, r *Request) { - conn, _, err := w.(Hijacker).Hijack() - if err != nil { - panic(err) - } - conn.Close() - }) - conn := &rwTestConn{ - Writer: ioutil.Discard, - closec: make(chan bool, 1), - } - ln := &oneConnListener{conn: conn} - for i := 0; i < b.N; i++ { - conn.Reader = bytes.NewReader(req) - ln.conn = conn - Serve(ln, h) - <-conn.closec - } -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/sniff_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/sniff_test.go deleted file mode 100644 index 24ca27afc1..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/sniff_test.go +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http_test - -import ( - "bytes" - "fmt" - "io" - "io/ioutil" - "log" - . "net/http" - "net/http/httptest" - "reflect" - "strconv" - "strings" - "testing" -) - -var sniffTests = []struct { - desc string - data []byte - contentType string -}{ - // Some nonsense. - {"Empty", []byte{}, "text/plain; charset=utf-8"}, - {"Binary", []byte{1, 2, 3}, "application/octet-stream"}, - - {"HTML document #1", []byte(`blah blah blah`), "text/html; charset=utf-8"}, - {"HTML document #2", []byte(``), "text/html; charset=utf-8"}, - {"HTML document #3 (leading whitespace)", []byte(` ...`), "text/html; charset=utf-8"}, - {"HTML document #4 (leading CRLF)", []byte("\r\n..."), "text/html; charset=utf-8"}, - - {"Plain text", []byte(`This is not HTML. It has ☃ though.`), "text/plain; charset=utf-8"}, - - {"XML", []byte("\nhi") - })) - defer ts.Close() - - resp, err := Get(ts.URL) - if err != nil { - t.Fatal(err) - } - - got := resp.Header["Content-Type"] - want := []string{""} - if !reflect.DeepEqual(got, want) { - t.Errorf("Content-Type = %q; want %q", got, want) - } - resp.Body.Close() -} - -func TestContentTypeWithCopy(t *testing.T) { - defer afterTest(t) - - const ( - input = "\n\n\t\n" - expected = "text/html; charset=utf-8" - ) - - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - // Use io.Copy from a bytes.Buffer to trigger ReadFrom. - buf := bytes.NewBuffer([]byte(input)) - n, err := io.Copy(w, buf) - if int(n) != len(input) || err != nil { - t.Errorf("io.Copy(w, %q) = %v, %v want %d, nil", input, n, err, len(input)) - } - })) - defer ts.Close() - - resp, err := Get(ts.URL) - if err != nil { - t.Fatalf("Get: %v", err) - } - if ct := resp.Header.Get("Content-Type"); ct != expected { - t.Errorf("Content-Type = %q, want %q", ct, expected) - } - data, err := ioutil.ReadAll(resp.Body) - if err != nil { - t.Errorf("reading body: %v", err) - } else if !bytes.Equal(data, []byte(input)) { - t.Errorf("data is %q, want %q", data, input) - } - resp.Body.Close() -} - -func TestSniffWriteSize(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - size, _ := strconv.Atoi(r.FormValue("size")) - written, err := io.WriteString(w, strings.Repeat("a", size)) - if err != nil { - t.Errorf("write of %d bytes: %v", size, err) - return - } - if written != size { - t.Errorf("write of %d bytes wrote %d bytes", size, written) - } - })) - defer ts.Close() - for _, size := range []int{0, 1, 200, 600, 999, 1000, 1023, 1024, 512 << 10, 1 << 20} { - res, err := Get(fmt.Sprintf("%s/?size=%d", ts.URL, size)) - if err != nil { - t.Fatalf("size %d: %v", size, err) - } - if _, err := io.Copy(ioutil.Discard, res.Body); err != nil { - t.Fatalf("size %d: io.Copy of body = %v", size, err) - } - if err := res.Body.Close(); err != nil { - t.Fatalf("size %d: body Close = %v", size, err) - } - } -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/transfer_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/transfer_test.go deleted file mode 100644 index 48cd540b9f..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/transfer_test.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http - -import ( - "bufio" - "io" - "strings" - "testing" -) - -func TestBodyReadBadTrailer(t *testing.T) { - b := &body{ - src: strings.NewReader("foobar"), - hdr: true, // force reading the trailer - r: bufio.NewReader(strings.NewReader("")), - } - buf := make([]byte, 7) - n, err := b.Read(buf[:3]) - got := string(buf[:n]) - if got != "foo" || err != nil { - t.Fatalf(`first Read = %d (%q), %v; want 3 ("foo")`, n, got, err) - } - - n, err = b.Read(buf[:]) - got = string(buf[:n]) - if got != "bar" || err != nil { - t.Fatalf(`second Read = %d (%q), %v; want 3 ("bar")`, n, got, err) - } - - n, err = b.Read(buf[:]) - got = string(buf[:n]) - if err == nil { - t.Errorf("final Read was successful (%q), expected error from trailer read", got) - } -} - -func TestFinalChunkedBodyReadEOF(t *testing.T) { - res, err := ReadResponse(bufio.NewReader(strings.NewReader( - "HTTP/1.1 200 OK\r\n"+ - "Transfer-Encoding: chunked\r\n"+ - "\r\n"+ - "0a\r\n"+ - "Body here\n\r\n"+ - "09\r\n"+ - "continued\r\n"+ - "0\r\n"+ - "\r\n")), nil) - if err != nil { - t.Fatal(err) - } - want := "Body here\ncontinued" - buf := make([]byte, len(want)) - n, err := res.Body.Read(buf) - if n != len(want) || err != io.EOF { - t.Logf("body = %#v", res.Body) - t.Errorf("Read = %v, %v; want %d, EOF", n, err, len(want)) - } - if string(buf) != want { - t.Errorf("buf = %q; want %q", buf, want) - } -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/transport_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/transport_test.go deleted file mode 100644 index 964ca0fca5..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/transport_test.go +++ /dev/null @@ -1,2173 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Tests for transport.go - -package http_test - -import ( - "bufio" - "bytes" - "compress/gzip" - "crypto/rand" - "crypto/tls" - "errors" - "fmt" - "io" - "io/ioutil" - "log" - "net" - "net/http" - . "net/http" - "net/http/httptest" - "net/url" - "os" - "runtime" - "strconv" - "strings" - "sync" - "testing" - "time" -) - -// TODO: test 5 pipelined requests with responses: 1) OK, 2) OK, Connection: Close -// and then verify that the final 2 responses get errors back. - -// hostPortHandler writes back the client's "host:port". -var hostPortHandler = HandlerFunc(func(w ResponseWriter, r *Request) { - if r.FormValue("close") == "true" { - w.Header().Set("Connection", "close") - } - w.Write([]byte(r.RemoteAddr)) -}) - -// testCloseConn is a net.Conn tracked by a testConnSet. -type testCloseConn struct { - net.Conn - set *testConnSet -} - -func (c *testCloseConn) Close() error { - c.set.remove(c) - return c.Conn.Close() -} - -// testConnSet tracks a set of TCP connections and whether they've -// been closed. -type testConnSet struct { - t *testing.T - mu sync.Mutex // guards closed and list - closed map[net.Conn]bool - list []net.Conn // in order created -} - -func (tcs *testConnSet) insert(c net.Conn) { - tcs.mu.Lock() - defer tcs.mu.Unlock() - tcs.closed[c] = false - tcs.list = append(tcs.list, c) -} - -func (tcs *testConnSet) remove(c net.Conn) { - tcs.mu.Lock() - defer tcs.mu.Unlock() - tcs.closed[c] = true -} - -// some tests use this to manage raw tcp connections for later inspection -func makeTestDial(t *testing.T) (*testConnSet, func(n, addr string) (net.Conn, error)) { - connSet := &testConnSet{ - t: t, - closed: make(map[net.Conn]bool), - } - dial := func(n, addr string) (net.Conn, error) { - c, err := net.Dial(n, addr) - if err != nil { - return nil, err - } - tc := &testCloseConn{c, connSet} - connSet.insert(tc) - return tc, nil - } - return connSet, dial -} - -func (tcs *testConnSet) check(t *testing.T) { - tcs.mu.Lock() - defer tcs.mu.Unlock() - for i := 4; i >= 0; i-- { - for i, c := range tcs.list { - if tcs.closed[c] { - continue - } - if i != 0 { - tcs.mu.Unlock() - time.Sleep(50 * time.Millisecond) - tcs.mu.Lock() - continue - } - t.Errorf("TCP connection #%d, %p (of %d total) was not closed", i+1, c, len(tcs.list)) - } - } -} - -// Two subsequent requests and verify their response is the same. -// The response from the server is our own IP:port -func TestTransportKeepAlives(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(hostPortHandler) - defer ts.Close() - - for _, disableKeepAlive := range []bool{false, true} { - tr := &Transport{DisableKeepAlives: disableKeepAlive} - defer tr.CloseIdleConnections() - c := &Client{Transport: tr} - - fetch := func(n int) string { - res, err := c.Get(ts.URL) - if err != nil { - t.Fatalf("error in disableKeepAlive=%v, req #%d, GET: %v", disableKeepAlive, n, err) - } - body, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatalf("error in disableKeepAlive=%v, req #%d, ReadAll: %v", disableKeepAlive, n, err) - } - return string(body) - } - - body1 := fetch(1) - body2 := fetch(2) - - bodiesDiffer := body1 != body2 - if bodiesDiffer != disableKeepAlive { - t.Errorf("error in disableKeepAlive=%v. unexpected bodiesDiffer=%v; body1=%q; body2=%q", - disableKeepAlive, bodiesDiffer, body1, body2) - } - } -} - -func TestTransportConnectionCloseOnResponse(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(hostPortHandler) - defer ts.Close() - - connSet, testDial := makeTestDial(t) - - for _, connectionClose := range []bool{false, true} { - tr := &Transport{ - Dial: testDial, - } - c := &Client{Transport: tr} - - fetch := func(n int) string { - req := new(Request) - var err error - req.URL, err = url.Parse(ts.URL + fmt.Sprintf("/?close=%v", connectionClose)) - if err != nil { - t.Fatalf("URL parse error: %v", err) - } - req.Method = "GET" - req.Proto = "HTTP/1.1" - req.ProtoMajor = 1 - req.ProtoMinor = 1 - - res, err := c.Do(req) - if err != nil { - t.Fatalf("error in connectionClose=%v, req #%d, Do: %v", connectionClose, n, err) - } - defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatalf("error in connectionClose=%v, req #%d, ReadAll: %v", connectionClose, n, err) - } - return string(body) - } - - body1 := fetch(1) - body2 := fetch(2) - bodiesDiffer := body1 != body2 - if bodiesDiffer != connectionClose { - t.Errorf("error in connectionClose=%v. unexpected bodiesDiffer=%v; body1=%q; body2=%q", - connectionClose, bodiesDiffer, body1, body2) - } - - tr.CloseIdleConnections() - } - - connSet.check(t) -} - -func TestTransportConnectionCloseOnRequest(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(hostPortHandler) - defer ts.Close() - - connSet, testDial := makeTestDial(t) - - for _, connectionClose := range []bool{false, true} { - tr := &Transport{ - Dial: testDial, - } - c := &Client{Transport: tr} - - fetch := func(n int) string { - req := new(Request) - var err error - req.URL, err = url.Parse(ts.URL) - if err != nil { - t.Fatalf("URL parse error: %v", err) - } - req.Method = "GET" - req.Proto = "HTTP/1.1" - req.ProtoMajor = 1 - req.ProtoMinor = 1 - req.Close = connectionClose - - res, err := c.Do(req) - if err != nil { - t.Fatalf("error in connectionClose=%v, req #%d, Do: %v", connectionClose, n, err) - } - body, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatalf("error in connectionClose=%v, req #%d, ReadAll: %v", connectionClose, n, err) - } - return string(body) - } - - body1 := fetch(1) - body2 := fetch(2) - bodiesDiffer := body1 != body2 - if bodiesDiffer != connectionClose { - t.Errorf("error in connectionClose=%v. unexpected bodiesDiffer=%v; body1=%q; body2=%q", - connectionClose, bodiesDiffer, body1, body2) - } - - tr.CloseIdleConnections() - } - - connSet.check(t) -} - -func TestTransportIdleCacheKeys(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(hostPortHandler) - defer ts.Close() - - tr := &Transport{DisableKeepAlives: false} - c := &Client{Transport: tr} - - if e, g := 0, len(tr.IdleConnKeysForTesting()); e != g { - t.Errorf("After CloseIdleConnections expected %d idle conn cache keys; got %d", e, g) - } - - resp, err := c.Get(ts.URL) - if err != nil { - t.Error(err) - } - ioutil.ReadAll(resp.Body) - - keys := tr.IdleConnKeysForTesting() - if e, g := 1, len(keys); e != g { - t.Fatalf("After Get expected %d idle conn cache keys; got %d", e, g) - } - - if e := "|http|" + ts.Listener.Addr().String(); keys[0] != e { - t.Errorf("Expected idle cache key %q; got %q", e, keys[0]) - } - - tr.CloseIdleConnections() - if e, g := 0, len(tr.IdleConnKeysForTesting()); e != g { - t.Errorf("After CloseIdleConnections expected %d idle conn cache keys; got %d", e, g) - } -} - -// Tests that the HTTP transport re-uses connections when a client -// reads to the end of a response Body without closing it. -func TestTransportReadToEndReusesConn(t *testing.T) { - defer afterTest(t) - const msg = "foobar" - - var addrSeen map[string]int - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - addrSeen[r.RemoteAddr]++ - if r.URL.Path == "/chunked/" { - w.WriteHeader(200) - w.(http.Flusher).Flush() - } else { - w.Header().Set("Content-Type", strconv.Itoa(len(msg))) - w.WriteHeader(200) - } - w.Write([]byte(msg)) - })) - defer ts.Close() - - buf := make([]byte, len(msg)) - - for pi, path := range []string{"/content-length/", "/chunked/"} { - wantLen := []int{len(msg), -1}[pi] - addrSeen = make(map[string]int) - for i := 0; i < 3; i++ { - res, err := http.Get(ts.URL + path) - if err != nil { - t.Errorf("Get %s: %v", path, err) - continue - } - // We want to close this body eventually (before the - // defer afterTest at top runs), but not before the - // len(addrSeen) check at the bottom of this test, - // since Closing this early in the loop would risk - // making connections be re-used for the wrong reason. - defer res.Body.Close() - - if res.ContentLength != int64(wantLen) { - t.Errorf("%s res.ContentLength = %d; want %d", path, res.ContentLength, wantLen) - } - n, err := res.Body.Read(buf) - if n != len(msg) || err != io.EOF { - t.Errorf("%s Read = %v, %v; want %d, EOF", path, n, err, len(msg)) - } - } - if len(addrSeen) != 1 { - t.Errorf("for %s, server saw %d distinct client addresses; want 1", path, len(addrSeen)) - } - } -} - -func TestTransportMaxPerHostIdleConns(t *testing.T) { - defer afterTest(t) - resch := make(chan string) - gotReq := make(chan bool) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - gotReq <- true - msg := <-resch - _, err := w.Write([]byte(msg)) - if err != nil { - t.Fatalf("Write: %v", err) - } - })) - defer ts.Close() - maxIdleConns := 2 - tr := &Transport{DisableKeepAlives: false, MaxIdleConnsPerHost: maxIdleConns} - c := &Client{Transport: tr} - - // Start 3 outstanding requests and wait for the server to get them. - // Their responses will hang until we write to resch, though. - donech := make(chan bool) - doReq := func() { - resp, err := c.Get(ts.URL) - if err != nil { - t.Error(err) - return - } - if _, err := ioutil.ReadAll(resp.Body); err != nil { - t.Errorf("ReadAll: %v", err) - return - } - donech <- true - } - go doReq() - <-gotReq - go doReq() - <-gotReq - go doReq() - <-gotReq - - if e, g := 0, len(tr.IdleConnKeysForTesting()); e != g { - t.Fatalf("Before writes, expected %d idle conn cache keys; got %d", e, g) - } - - resch <- "res1" - <-donech - keys := tr.IdleConnKeysForTesting() - if e, g := 1, len(keys); e != g { - t.Fatalf("after first response, expected %d idle conn cache keys; got %d", e, g) - } - cacheKey := "|http|" + ts.Listener.Addr().String() - if keys[0] != cacheKey { - t.Fatalf("Expected idle cache key %q; got %q", cacheKey, keys[0]) - } - if e, g := 1, tr.IdleConnCountForTesting(cacheKey); e != g { - t.Errorf("after first response, expected %d idle conns; got %d", e, g) - } - - resch <- "res2" - <-donech - if e, g := 2, tr.IdleConnCountForTesting(cacheKey); e != g { - t.Errorf("after second response, expected %d idle conns; got %d", e, g) - } - - resch <- "res3" - <-donech - if e, g := maxIdleConns, tr.IdleConnCountForTesting(cacheKey); e != g { - t.Errorf("after third response, still expected %d idle conns; got %d", e, g) - } -} - -func TestTransportServerClosingUnexpectedly(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(hostPortHandler) - defer ts.Close() - - tr := &Transport{} - c := &Client{Transport: tr} - - fetch := func(n, retries int) string { - condFatalf := func(format string, arg ...interface{}) { - if retries <= 0 { - t.Fatalf(format, arg...) - } - t.Logf("retrying shortly after expected error: "+format, arg...) - time.Sleep(time.Second / time.Duration(retries)) - } - for retries >= 0 { - retries-- - res, err := c.Get(ts.URL) - if err != nil { - condFatalf("error in req #%d, GET: %v", n, err) - continue - } - body, err := ioutil.ReadAll(res.Body) - if err != nil { - condFatalf("error in req #%d, ReadAll: %v", n, err) - continue - } - res.Body.Close() - return string(body) - } - panic("unreachable") - } - - body1 := fetch(1, 0) - body2 := fetch(2, 0) - - ts.CloseClientConnections() // surprise! - - // This test has an expected race. Sleeping for 25 ms prevents - // it on most fast machines, causing the next fetch() call to - // succeed quickly. But if we do get errors, fetch() will retry 5 - // times with some delays between. - time.Sleep(25 * time.Millisecond) - - body3 := fetch(3, 5) - - if body1 != body2 { - t.Errorf("expected body1 and body2 to be equal") - } - if body2 == body3 { - t.Errorf("expected body2 and body3 to be different") - } -} - -// Test for http://golang.org/issue/2616 (appropriate issue number) -// This fails pretty reliably with GOMAXPROCS=100 or something high. -func TestStressSurpriseServerCloses(t *testing.T) { - defer afterTest(t) - if testing.Short() { - t.Skip("skipping test in short mode") - } - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - w.Header().Set("Content-Length", "5") - w.Header().Set("Content-Type", "text/plain") - w.Write([]byte("Hello")) - w.(Flusher).Flush() - conn, buf, _ := w.(Hijacker).Hijack() - buf.Flush() - conn.Close() - })) - defer ts.Close() - - tr := &Transport{DisableKeepAlives: false} - c := &Client{Transport: tr} - - // Do a bunch of traffic from different goroutines. Send to activityc - // after each request completes, regardless of whether it failed. - const ( - numClients = 50 - reqsPerClient = 250 - ) - activityc := make(chan bool) - for i := 0; i < numClients; i++ { - go func() { - for i := 0; i < reqsPerClient; i++ { - res, err := c.Get(ts.URL) - if err == nil { - // We expect errors since the server is - // hanging up on us after telling us to - // send more requests, so we don't - // actually care what the error is. - // But we want to close the body in cases - // where we won the race. - res.Body.Close() - } - activityc <- true - } - }() - } - - // Make sure all the request come back, one way or another. - for i := 0; i < numClients*reqsPerClient; i++ { - select { - case <-activityc: - case <-time.After(5 * time.Second): - t.Fatalf("presumed deadlock; no HTTP client activity seen in awhile") - } - } -} - -// TestTransportHeadResponses verifies that we deal with Content-Lengths -// with no bodies properly -func TestTransportHeadResponses(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - if r.Method != "HEAD" { - panic("expected HEAD; got " + r.Method) - } - w.Header().Set("Content-Length", "123") - w.WriteHeader(200) - })) - defer ts.Close() - - tr := &Transport{DisableKeepAlives: false} - c := &Client{Transport: tr} - for i := 0; i < 2; i++ { - res, err := c.Head(ts.URL) - if err != nil { - t.Errorf("error on loop %d: %v", i, err) - continue - } - if e, g := "123", res.Header.Get("Content-Length"); e != g { - t.Errorf("loop %d: expected Content-Length header of %q, got %q", i, e, g) - } - if e, g := int64(123), res.ContentLength; e != g { - t.Errorf("loop %d: expected res.ContentLength of %v, got %v", i, e, g) - } - if all, err := ioutil.ReadAll(res.Body); err != nil { - t.Errorf("loop %d: Body ReadAll: %v", i, err) - } else if len(all) != 0 { - t.Errorf("Bogus body %q", all) - } - } -} - -// TestTransportHeadChunkedResponse verifies that we ignore chunked transfer-encoding -// on responses to HEAD requests. -func TestTransportHeadChunkedResponse(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - if r.Method != "HEAD" { - panic("expected HEAD; got " + r.Method) - } - w.Header().Set("Transfer-Encoding", "chunked") // client should ignore - w.Header().Set("x-client-ipport", r.RemoteAddr) - w.WriteHeader(200) - })) - defer ts.Close() - - tr := &Transport{DisableKeepAlives: false} - c := &Client{Transport: tr} - - res1, err := c.Head(ts.URL) - if err != nil { - t.Fatalf("request 1 error: %v", err) - } - res2, err := c.Head(ts.URL) - if err != nil { - t.Fatalf("request 2 error: %v", err) - } - if v1, v2 := res1.Header.Get("x-client-ipport"), res2.Header.Get("x-client-ipport"); v1 != v2 { - t.Errorf("ip/ports differed between head requests: %q vs %q", v1, v2) - } -} - -var roundTripTests = []struct { - accept string - expectAccept string - compressed bool -}{ - // Requests with no accept-encoding header use transparent compression - {"", "gzip", false}, - // Requests with other accept-encoding should pass through unmodified - {"foo", "foo", false}, - // Requests with accept-encoding == gzip should be passed through - {"gzip", "gzip", true}, -} - -// Test that the modification made to the Request by the RoundTripper is cleaned up -func TestRoundTripGzip(t *testing.T) { - defer afterTest(t) - const responseBody = "test response body" - ts := httptest.NewServer(HandlerFunc(func(rw ResponseWriter, req *Request) { - accept := req.Header.Get("Accept-Encoding") - if expect := req.FormValue("expect_accept"); accept != expect { - t.Errorf("in handler, test %v: Accept-Encoding = %q, want %q", - req.FormValue("testnum"), accept, expect) - } - if accept == "gzip" { - rw.Header().Set("Content-Encoding", "gzip") - gz := gzip.NewWriter(rw) - gz.Write([]byte(responseBody)) - gz.Close() - } else { - rw.Header().Set("Content-Encoding", accept) - rw.Write([]byte(responseBody)) - } - })) - defer ts.Close() - - for i, test := range roundTripTests { - // Test basic request (no accept-encoding) - req, _ := NewRequest("GET", fmt.Sprintf("%s/?testnum=%d&expect_accept=%s", ts.URL, i, test.expectAccept), nil) - if test.accept != "" { - req.Header.Set("Accept-Encoding", test.accept) - } - res, err := DefaultTransport.RoundTrip(req) - var body []byte - if test.compressed { - var r *gzip.Reader - r, err = gzip.NewReader(res.Body) - if err != nil { - t.Errorf("%d. gzip NewReader: %v", i, err) - continue - } - body, err = ioutil.ReadAll(r) - res.Body.Close() - } else { - body, err = ioutil.ReadAll(res.Body) - } - if err != nil { - t.Errorf("%d. Error: %q", i, err) - continue - } - if g, e := string(body), responseBody; g != e { - t.Errorf("%d. body = %q; want %q", i, g, e) - } - if g, e := req.Header.Get("Accept-Encoding"), test.accept; g != e { - t.Errorf("%d. Accept-Encoding = %q; want %q (it was mutated, in violation of RoundTrip contract)", i, g, e) - } - if g, e := res.Header.Get("Content-Encoding"), test.accept; g != e { - t.Errorf("%d. Content-Encoding = %q; want %q", i, g, e) - } - } - -} - -func TestTransportGzip(t *testing.T) { - defer afterTest(t) - const testString = "The test string aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - const nRandBytes = 1024 * 1024 - ts := httptest.NewServer(HandlerFunc(func(rw ResponseWriter, req *Request) { - if req.Method == "HEAD" { - if g := req.Header.Get("Accept-Encoding"); g != "" { - t.Errorf("HEAD request sent with Accept-Encoding of %q; want none", g) - } - return - } - if g, e := req.Header.Get("Accept-Encoding"), "gzip"; g != e { - t.Errorf("Accept-Encoding = %q, want %q", g, e) - } - rw.Header().Set("Content-Encoding", "gzip") - - var w io.Writer = rw - var buf bytes.Buffer - if req.FormValue("chunked") == "0" { - w = &buf - defer io.Copy(rw, &buf) - defer func() { - rw.Header().Set("Content-Length", strconv.Itoa(buf.Len())) - }() - } - gz := gzip.NewWriter(w) - gz.Write([]byte(testString)) - if req.FormValue("body") == "large" { - io.CopyN(gz, rand.Reader, nRandBytes) - } - gz.Close() - })) - defer ts.Close() - - for _, chunked := range []string{"1", "0"} { - c := &Client{Transport: &Transport{}} - - // First fetch something large, but only read some of it. - res, err := c.Get(ts.URL + "/?body=large&chunked=" + chunked) - if err != nil { - t.Fatalf("large get: %v", err) - } - buf := make([]byte, len(testString)) - n, err := io.ReadFull(res.Body, buf) - if err != nil { - t.Fatalf("partial read of large response: size=%d, %v", n, err) - } - if e, g := testString, string(buf); e != g { - t.Errorf("partial read got %q, expected %q", g, e) - } - res.Body.Close() - // Read on the body, even though it's closed - n, err = res.Body.Read(buf) - if n != 0 || err == nil { - t.Errorf("expected error post-closed large Read; got = %d, %v", n, err) - } - - // Then something small. - res, err = c.Get(ts.URL + "/?chunked=" + chunked) - if err != nil { - t.Fatal(err) - } - body, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatal(err) - } - if g, e := string(body), testString; g != e { - t.Fatalf("body = %q; want %q", g, e) - } - if g, e := res.Header.Get("Content-Encoding"), ""; g != e { - t.Fatalf("Content-Encoding = %q; want %q", g, e) - } - - // Read on the body after it's been fully read: - n, err = res.Body.Read(buf) - if n != 0 || err == nil { - t.Errorf("expected Read error after exhausted reads; got %d, %v", n, err) - } - res.Body.Close() - n, err = res.Body.Read(buf) - if n != 0 || err == nil { - t.Errorf("expected Read error after Close; got %d, %v", n, err) - } - } - - // And a HEAD request too, because they're always weird. - c := &Client{Transport: &Transport{}} - res, err := c.Head(ts.URL) - if err != nil { - t.Fatalf("Head: %v", err) - } - if res.StatusCode != 200 { - t.Errorf("Head status=%d; want=200", res.StatusCode) - } -} - -func TestTransportProxy(t *testing.T) { - defer afterTest(t) - ch := make(chan string, 1) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - ch <- "real server" - })) - defer ts.Close() - proxy := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - ch <- "proxy for " + r.URL.String() - })) - defer proxy.Close() - - pu, err := url.Parse(proxy.URL) - if err != nil { - t.Fatal(err) - } - c := &Client{Transport: &Transport{Proxy: ProxyURL(pu)}} - c.Head(ts.URL) - got := <-ch - want := "proxy for " + ts.URL + "/" - if got != want { - t.Errorf("want %q, got %q", want, got) - } -} - -// TestTransportGzipRecursive sends a gzip quine and checks that the -// client gets the same value back. This is more cute than anything, -// but checks that we don't recurse forever, and checks that -// Content-Encoding is removed. -func TestTransportGzipRecursive(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - w.Header().Set("Content-Encoding", "gzip") - w.Write(rgz) - })) - defer ts.Close() - - c := &Client{Transport: &Transport{}} - res, err := c.Get(ts.URL) - if err != nil { - t.Fatal(err) - } - body, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(body, rgz) { - t.Fatalf("Incorrect result from recursive gz:\nhave=%x\nwant=%x", - body, rgz) - } - if g, e := res.Header.Get("Content-Encoding"), ""; g != e { - t.Fatalf("Content-Encoding = %q; want %q", g, e) - } -} - -// golang.org/issue/7750: request fails when server replies with -// a short gzip body -func TestTransportGzipShort(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - w.Header().Set("Content-Encoding", "gzip") - w.Write([]byte{0x1f, 0x8b}) - })) - defer ts.Close() - - tr := &Transport{} - defer tr.CloseIdleConnections() - c := &Client{Transport: tr} - res, err := c.Get(ts.URL) - if err != nil { - t.Fatal(err) - } - defer res.Body.Close() - _, err = ioutil.ReadAll(res.Body) - if err == nil { - t.Fatal("Expect an error from reading a body.") - } - if err != io.ErrUnexpectedEOF { - t.Errorf("ReadAll error = %v; want io.ErrUnexpectedEOF", err) - } -} - -// tests that persistent goroutine connections shut down when no longer desired. -func TestTransportPersistConnLeak(t *testing.T) { - if runtime.GOOS == "plan9" { - t.Skip("skipping test; see http://golang.org/issue/7237") - } - defer afterTest(t) - gotReqCh := make(chan bool) - unblockCh := make(chan bool) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - gotReqCh <- true - <-unblockCh - w.Header().Set("Content-Length", "0") - w.WriteHeader(204) - })) - defer ts.Close() - - tr := &Transport{} - c := &Client{Transport: tr} - - n0 := runtime.NumGoroutine() - - const numReq = 25 - didReqCh := make(chan bool) - for i := 0; i < numReq; i++ { - go func() { - res, err := c.Get(ts.URL) - didReqCh <- true - if err != nil { - t.Errorf("client fetch error: %v", err) - return - } - res.Body.Close() - }() - } - - // Wait for all goroutines to be stuck in the Handler. - for i := 0; i < numReq; i++ { - <-gotReqCh - } - - nhigh := runtime.NumGoroutine() - - // Tell all handlers to unblock and reply. - for i := 0; i < numReq; i++ { - unblockCh <- true - } - - // Wait for all HTTP clients to be done. - for i := 0; i < numReq; i++ { - <-didReqCh - } - - tr.CloseIdleConnections() - time.Sleep(100 * time.Millisecond) - runtime.GC() - runtime.GC() // even more. - nfinal := runtime.NumGoroutine() - - growth := nfinal - n0 - - // We expect 0 or 1 extra goroutine, empirically. Allow up to 5. - // Previously we were leaking one per numReq. - if int(growth) > 5 { - t.Logf("goroutine growth: %d -> %d -> %d (delta: %d)", n0, nhigh, nfinal, growth) - t.Error("too many new goroutines") - } -} - -// golang.org/issue/4531: Transport leaks goroutines when -// request.ContentLength is explicitly short -func TestTransportPersistConnLeakShortBody(t *testing.T) { - if runtime.GOOS == "plan9" { - t.Skip("skipping test; see http://golang.org/issue/7237") - } - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - })) - defer ts.Close() - - tr := &Transport{} - c := &Client{Transport: tr} - - n0 := runtime.NumGoroutine() - body := []byte("Hello") - for i := 0; i < 20; i++ { - req, err := NewRequest("POST", ts.URL, bytes.NewReader(body)) - if err != nil { - t.Fatal(err) - } - req.ContentLength = int64(len(body) - 2) // explicitly short - _, err = c.Do(req) - if err == nil { - t.Fatal("Expect an error from writing too long of a body.") - } - } - nhigh := runtime.NumGoroutine() - tr.CloseIdleConnections() - time.Sleep(400 * time.Millisecond) - runtime.GC() - nfinal := runtime.NumGoroutine() - - growth := nfinal - n0 - - // We expect 0 or 1 extra goroutine, empirically. Allow up to 5. - // Previously we were leaking one per numReq. - t.Logf("goroutine growth: %d -> %d -> %d (delta: %d)", n0, nhigh, nfinal, growth) - if int(growth) > 5 { - t.Error("too many new goroutines") - } -} - -// This used to crash; http://golang.org/issue/3266 -func TestTransportIdleConnCrash(t *testing.T) { - defer afterTest(t) - tr := &Transport{} - c := &Client{Transport: tr} - - unblockCh := make(chan bool, 1) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - <-unblockCh - tr.CloseIdleConnections() - })) - defer ts.Close() - - didreq := make(chan bool) - go func() { - res, err := c.Get(ts.URL) - if err != nil { - t.Error(err) - } else { - res.Body.Close() // returns idle conn - } - didreq <- true - }() - unblockCh <- true - <-didreq -} - -// Test that the transport doesn't close the TCP connection early, -// before the response body has been read. This was a regression -// which sadly lacked a triggering test. The large response body made -// the old race easier to trigger. -func TestIssue3644(t *testing.T) { - defer afterTest(t) - const numFoos = 5000 - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - w.Header().Set("Connection", "close") - for i := 0; i < numFoos; i++ { - w.Write([]byte("foo ")) - } - })) - defer ts.Close() - tr := &Transport{} - c := &Client{Transport: tr} - res, err := c.Get(ts.URL) - if err != nil { - t.Fatal(err) - } - defer res.Body.Close() - bs, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatal(err) - } - if len(bs) != numFoos*len("foo ") { - t.Errorf("unexpected response length") - } -} - -// Test that a client receives a server's reply, even if the server doesn't read -// the entire request body. -func TestIssue3595(t *testing.T) { - defer afterTest(t) - const deniedMsg = "sorry, denied." - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - Error(w, deniedMsg, StatusUnauthorized) - })) - defer ts.Close() - tr := &Transport{} - c := &Client{Transport: tr} - res, err := c.Post(ts.URL, "application/octet-stream", neverEnding('a')) - if err != nil { - t.Errorf("Post: %v", err) - return - } - got, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatalf("Body ReadAll: %v", err) - } - if !strings.Contains(string(got), deniedMsg) { - t.Errorf("Known bug: response %q does not contain %q", got, deniedMsg) - } -} - -// From http://golang.org/issue/4454 , -// "client fails to handle requests with no body and chunked encoding" -func TestChunkedNoContent(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - w.WriteHeader(StatusNoContent) - })) - defer ts.Close() - - for _, closeBody := range []bool{true, false} { - c := &Client{Transport: &Transport{}} - const n = 4 - for i := 1; i <= n; i++ { - res, err := c.Get(ts.URL) - if err != nil { - t.Errorf("closingBody=%v, req %d/%d: %v", closeBody, i, n, err) - } else { - if closeBody { - res.Body.Close() - } - } - } - } -} - -func TestTransportConcurrency(t *testing.T) { - defer afterTest(t) - maxProcs, numReqs := 16, 500 - if testing.Short() { - maxProcs, numReqs = 4, 50 - } - defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(maxProcs)) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - fmt.Fprintf(w, "%v", r.FormValue("echo")) - })) - defer ts.Close() - - var wg sync.WaitGroup - wg.Add(numReqs) - - tr := &Transport{ - Dial: func(netw, addr string) (c net.Conn, err error) { - // Due to the Transport's "socket late - // binding" (see idleConnCh in transport.go), - // the numReqs HTTP requests below can finish - // with a dial still outstanding. So count - // our dials as work too so the leak checker - // doesn't complain at us. - wg.Add(1) - defer wg.Done() - return net.Dial(netw, addr) - }, - } - defer tr.CloseIdleConnections() - c := &Client{Transport: tr} - reqs := make(chan string) - defer close(reqs) - - for i := 0; i < maxProcs*2; i++ { - go func() { - for req := range reqs { - res, err := c.Get(ts.URL + "/?echo=" + req) - if err != nil { - t.Errorf("error on req %s: %v", req, err) - wg.Done() - continue - } - all, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Errorf("read error on req %s: %v", req, err) - wg.Done() - continue - } - if string(all) != req { - t.Errorf("body of req %s = %q; want %q", req, all, req) - } - res.Body.Close() - wg.Done() - } - }() - } - for i := 0; i < numReqs; i++ { - reqs <- fmt.Sprintf("request-%d", i) - } - wg.Wait() -} - -func TestIssue4191_InfiniteGetTimeout(t *testing.T) { - if runtime.GOOS == "plan9" { - t.Skip("skipping test; see http://golang.org/issue/7237") - } - defer afterTest(t) - const debug = false - mux := NewServeMux() - mux.HandleFunc("/get", func(w ResponseWriter, r *Request) { - io.Copy(w, neverEnding('a')) - }) - ts := httptest.NewServer(mux) - timeout := 100 * time.Millisecond - - client := &Client{ - Transport: &Transport{ - Dial: func(n, addr string) (net.Conn, error) { - conn, err := net.Dial(n, addr) - if err != nil { - return nil, err - } - conn.SetDeadline(time.Now().Add(timeout)) - if debug { - conn = NewLoggingConn("client", conn) - } - return conn, nil - }, - DisableKeepAlives: true, - }, - } - - getFailed := false - nRuns := 5 - if testing.Short() { - nRuns = 1 - } - for i := 0; i < nRuns; i++ { - if debug { - println("run", i+1, "of", nRuns) - } - sres, err := client.Get(ts.URL + "/get") - if err != nil { - if !getFailed { - // Make the timeout longer, once. - getFailed = true - t.Logf("increasing timeout") - i-- - timeout *= 10 - continue - } - t.Errorf("Error issuing GET: %v", err) - break - } - _, err = io.Copy(ioutil.Discard, sres.Body) - if err == nil { - t.Errorf("Unexpected successful copy") - break - } - } - if debug { - println("tests complete; waiting for handlers to finish") - } - ts.Close() -} - -func TestIssue4191_InfiniteGetToPutTimeout(t *testing.T) { - if runtime.GOOS == "plan9" { - t.Skip("skipping test; see http://golang.org/issue/7237") - } - defer afterTest(t) - const debug = false - mux := NewServeMux() - mux.HandleFunc("/get", func(w ResponseWriter, r *Request) { - io.Copy(w, neverEnding('a')) - }) - mux.HandleFunc("/put", func(w ResponseWriter, r *Request) { - defer r.Body.Close() - io.Copy(ioutil.Discard, r.Body) - }) - ts := httptest.NewServer(mux) - timeout := 100 * time.Millisecond - - client := &Client{ - Transport: &Transport{ - Dial: func(n, addr string) (net.Conn, error) { - conn, err := net.Dial(n, addr) - if err != nil { - return nil, err - } - conn.SetDeadline(time.Now().Add(timeout)) - if debug { - conn = NewLoggingConn("client", conn) - } - return conn, nil - }, - DisableKeepAlives: true, - }, - } - - getFailed := false - nRuns := 5 - if testing.Short() { - nRuns = 1 - } - for i := 0; i < nRuns; i++ { - if debug { - println("run", i+1, "of", nRuns) - } - sres, err := client.Get(ts.URL + "/get") - if err != nil { - if !getFailed { - // Make the timeout longer, once. - getFailed = true - t.Logf("increasing timeout") - i-- - timeout *= 10 - continue - } - t.Errorf("Error issuing GET: %v", err) - break - } - req, _ := NewRequest("PUT", ts.URL+"/put", sres.Body) - _, err = client.Do(req) - if err == nil { - sres.Body.Close() - t.Errorf("Unexpected successful PUT") - break - } - sres.Body.Close() - } - if debug { - println("tests complete; waiting for handlers to finish") - } - ts.Close() -} - -func TestTransportResponseHeaderTimeout(t *testing.T) { - defer afterTest(t) - if testing.Short() { - t.Skip("skipping timeout test in -short mode") - } - inHandler := make(chan bool, 1) - mux := NewServeMux() - mux.HandleFunc("/fast", func(w ResponseWriter, r *Request) { - inHandler <- true - }) - mux.HandleFunc("/slow", func(w ResponseWriter, r *Request) { - inHandler <- true - time.Sleep(2 * time.Second) - }) - ts := httptest.NewServer(mux) - defer ts.Close() - - tr := &Transport{ - ResponseHeaderTimeout: 500 * time.Millisecond, - } - defer tr.CloseIdleConnections() - c := &Client{Transport: tr} - - tests := []struct { - path string - want int - wantErr string - }{ - {path: "/fast", want: 200}, - {path: "/slow", wantErr: "timeout awaiting response headers"}, - {path: "/fast", want: 200}, - } - for i, tt := range tests { - res, err := c.Get(ts.URL + tt.path) - select { - case <-inHandler: - case <-time.After(5 * time.Second): - t.Errorf("never entered handler for test index %d, %s", i, tt.path) - continue - } - if err != nil { - uerr, ok := err.(*url.Error) - if !ok { - t.Errorf("error is not an url.Error; got: %#v", err) - continue - } - nerr, ok := uerr.Err.(net.Error) - if !ok { - t.Errorf("error does not satisfy net.Error interface; got: %#v", err) - continue - } - if !nerr.Timeout() { - t.Errorf("want timeout error; got: %q", nerr) - continue - } - if strings.Contains(err.Error(), tt.wantErr) { - continue - } - t.Errorf("%d. unexpected error: %v", i, err) - continue - } - if tt.wantErr != "" { - t.Errorf("%d. no error. expected error: %v", i, tt.wantErr) - continue - } - if res.StatusCode != tt.want { - t.Errorf("%d for path %q status = %d; want %d", i, tt.path, res.StatusCode, tt.want) - } - } -} - -func TestTransportCancelRequest(t *testing.T) { - defer afterTest(t) - if testing.Short() { - t.Skip("skipping test in -short mode") - } - unblockc := make(chan bool) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - fmt.Fprintf(w, "Hello") - w.(Flusher).Flush() // send headers and some body - <-unblockc - })) - defer ts.Close() - defer close(unblockc) - - tr := &Transport{} - defer tr.CloseIdleConnections() - c := &Client{Transport: tr} - - req, _ := NewRequest("GET", ts.URL, nil) - res, err := c.Do(req) - if err != nil { - t.Fatal(err) - } - go func() { - time.Sleep(1 * time.Second) - tr.CancelRequest(req) - }() - t0 := time.Now() - body, err := ioutil.ReadAll(res.Body) - d := time.Since(t0) - - if err == nil { - t.Error("expected an error reading the body") - } - if string(body) != "Hello" { - t.Errorf("Body = %q; want Hello", body) - } - if d < 500*time.Millisecond { - t.Errorf("expected ~1 second delay; got %v", d) - } - // Verify no outstanding requests after readLoop/writeLoop - // goroutines shut down. - for tries := 3; tries > 0; tries-- { - n := tr.NumPendingRequestsForTesting() - if n == 0 { - break - } - time.Sleep(100 * time.Millisecond) - if tries == 1 { - t.Errorf("pending requests = %d; want 0", n) - } - } -} - -func TestTransportCancelRequestInDial(t *testing.T) { - defer afterTest(t) - if testing.Short() { - t.Skip("skipping test in -short mode") - } - var logbuf bytes.Buffer - eventLog := log.New(&logbuf, "", 0) - - unblockDial := make(chan bool) - defer close(unblockDial) - - inDial := make(chan bool) - tr := &Transport{ - Dial: func(network, addr string) (net.Conn, error) { - eventLog.Println("dial: blocking") - inDial <- true - <-unblockDial - return nil, errors.New("nope") - }, - } - cl := &Client{Transport: tr} - gotres := make(chan bool) - req, _ := NewRequest("GET", "http://something.no-network.tld/", nil) - go func() { - _, err := cl.Do(req) - eventLog.Printf("Get = %v", err) - gotres <- true - }() - - select { - case <-inDial: - case <-time.After(5 * time.Second): - t.Fatal("timeout; never saw blocking dial") - } - - eventLog.Printf("canceling") - tr.CancelRequest(req) - - select { - case <-gotres: - case <-time.After(5 * time.Second): - panic("hang. events are: " + logbuf.String()) - } - - got := logbuf.String() - want := `dial: blocking -canceling -Get = Get http://something.no-network.tld/: net/http: request canceled while waiting for connection -` - if got != want { - t.Errorf("Got events:\n%s\nWant:\n%s", got, want) - } -} - -// golang.org/issue/3672 -- Client can't close HTTP stream -// Calling Close on a Response.Body used to just read until EOF. -// Now it actually closes the TCP connection. -func TestTransportCloseResponseBody(t *testing.T) { - defer afterTest(t) - writeErr := make(chan error, 1) - msg := []byte("young\n") - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - for { - _, err := w.Write(msg) - if err != nil { - writeErr <- err - return - } - w.(Flusher).Flush() - } - })) - defer ts.Close() - - tr := &Transport{} - defer tr.CloseIdleConnections() - c := &Client{Transport: tr} - - req, _ := NewRequest("GET", ts.URL, nil) - defer tr.CancelRequest(req) - - res, err := c.Do(req) - if err != nil { - t.Fatal(err) - } - - const repeats = 3 - buf := make([]byte, len(msg)*repeats) - want := bytes.Repeat(msg, repeats) - - _, err = io.ReadFull(res.Body, buf) - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(buf, want) { - t.Fatalf("read %q; want %q", buf, want) - } - didClose := make(chan error, 1) - go func() { - didClose <- res.Body.Close() - }() - select { - case err := <-didClose: - if err != nil { - t.Errorf("Close = %v", err) - } - case <-time.After(10 * time.Second): - t.Fatal("too long waiting for close") - } - select { - case err := <-writeErr: - if err == nil { - t.Errorf("expected non-nil write error") - } - case <-time.After(10 * time.Second): - t.Fatal("too long waiting for write error") - } -} - -type fooProto struct{} - -func (fooProto) RoundTrip(req *Request) (*Response, error) { - res := &Response{ - Status: "200 OK", - StatusCode: 200, - Header: make(Header), - Body: ioutil.NopCloser(strings.NewReader("You wanted " + req.URL.String())), - } - return res, nil -} - -func TestTransportAltProto(t *testing.T) { - defer afterTest(t) - tr := &Transport{} - c := &Client{Transport: tr} - tr.RegisterProtocol("foo", fooProto{}) - res, err := c.Get("foo://bar.com/path") - if err != nil { - t.Fatal(err) - } - bodyb, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatal(err) - } - body := string(bodyb) - if e := "You wanted foo://bar.com/path"; body != e { - t.Errorf("got response %q, want %q", body, e) - } -} - -func TestTransportNoHost(t *testing.T) { - defer afterTest(t) - tr := &Transport{} - _, err := tr.RoundTrip(&Request{ - Header: make(Header), - URL: &url.URL{ - Scheme: "http", - }, - }) - want := "http: no Host in request URL" - if got := fmt.Sprint(err); got != want { - t.Errorf("error = %v; want %q", err, want) - } -} - -func TestTransportSocketLateBinding(t *testing.T) { - defer afterTest(t) - - mux := NewServeMux() - fooGate := make(chan bool, 1) - mux.HandleFunc("/foo", func(w ResponseWriter, r *Request) { - w.Header().Set("foo-ipport", r.RemoteAddr) - w.(Flusher).Flush() - <-fooGate - }) - mux.HandleFunc("/bar", func(w ResponseWriter, r *Request) { - w.Header().Set("bar-ipport", r.RemoteAddr) - }) - ts := httptest.NewServer(mux) - defer ts.Close() - - dialGate := make(chan bool, 1) - tr := &Transport{ - Dial: func(n, addr string) (net.Conn, error) { - if <-dialGate { - return net.Dial(n, addr) - } - return nil, errors.New("manually closed") - }, - DisableKeepAlives: false, - } - defer tr.CloseIdleConnections() - c := &Client{ - Transport: tr, - } - - dialGate <- true // only allow one dial - fooRes, err := c.Get(ts.URL + "/foo") - if err != nil { - t.Fatal(err) - } - fooAddr := fooRes.Header.Get("foo-ipport") - if fooAddr == "" { - t.Fatal("No addr on /foo request") - } - time.AfterFunc(200*time.Millisecond, func() { - // let the foo response finish so we can use its - // connection for /bar - fooGate <- true - io.Copy(ioutil.Discard, fooRes.Body) - fooRes.Body.Close() - }) - - barRes, err := c.Get(ts.URL + "/bar") - if err != nil { - t.Fatal(err) - } - barAddr := barRes.Header.Get("bar-ipport") - if barAddr != fooAddr { - t.Fatalf("/foo came from conn %q; /bar came from %q instead", fooAddr, barAddr) - } - barRes.Body.Close() - dialGate <- false -} - -// Issue 2184 -func TestTransportReading100Continue(t *testing.T) { - defer afterTest(t) - - const numReqs = 5 - reqBody := func(n int) string { return fmt.Sprintf("request body %d", n) } - reqID := func(n int) string { return fmt.Sprintf("REQ-ID-%d", n) } - - send100Response := func(w *io.PipeWriter, r *io.PipeReader) { - defer w.Close() - defer r.Close() - br := bufio.NewReader(r) - n := 0 - for { - n++ - req, err := ReadRequest(br) - if err == io.EOF { - return - } - if err != nil { - t.Error(err) - return - } - slurp, err := ioutil.ReadAll(req.Body) - if err != nil { - t.Errorf("Server request body slurp: %v", err) - return - } - id := req.Header.Get("Request-Id") - resCode := req.Header.Get("X-Want-Response-Code") - if resCode == "" { - resCode = "100 Continue" - if string(slurp) != reqBody(n) { - t.Errorf("Server got %q, %v; want %q", slurp, err, reqBody(n)) - } - } - body := fmt.Sprintf("Response number %d", n) - v := []byte(strings.Replace(fmt.Sprintf(`HTTP/1.1 %s -Date: Thu, 28 Feb 2013 17:55:41 GMT - -HTTP/1.1 200 OK -Content-Type: text/html -Echo-Request-Id: %s -Content-Length: %d - -%s`, resCode, id, len(body), body), "\n", "\r\n", -1)) - w.Write(v) - if id == reqID(numReqs) { - return - } - } - - } - - tr := &Transport{ - Dial: func(n, addr string) (net.Conn, error) { - sr, sw := io.Pipe() // server read/write - cr, cw := io.Pipe() // client read/write - conn := &rwTestConn{ - Reader: cr, - Writer: sw, - closeFunc: func() error { - sw.Close() - cw.Close() - return nil - }, - } - go send100Response(cw, sr) - return conn, nil - }, - DisableKeepAlives: false, - } - defer tr.CloseIdleConnections() - c := &Client{Transport: tr} - - testResponse := func(req *Request, name string, wantCode int) { - res, err := c.Do(req) - if err != nil { - t.Fatalf("%s: Do: %v", name, err) - } - if res.StatusCode != wantCode { - t.Fatalf("%s: Response Statuscode=%d; want %d", name, res.StatusCode, wantCode) - } - if id, idBack := req.Header.Get("Request-Id"), res.Header.Get("Echo-Request-Id"); id != "" && id != idBack { - t.Errorf("%s: response id %q != request id %q", name, idBack, id) - } - _, err = ioutil.ReadAll(res.Body) - if err != nil { - t.Fatalf("%s: Slurp error: %v", name, err) - } - } - - // Few 100 responses, making sure we're not off-by-one. - for i := 1; i <= numReqs; i++ { - req, _ := NewRequest("POST", "http://dummy.tld/", strings.NewReader(reqBody(i))) - req.Header.Set("Request-Id", reqID(i)) - testResponse(req, fmt.Sprintf("100, %d/%d", i, numReqs), 200) - } - - // And some other informational 1xx but non-100 responses, to test - // we return them but don't re-use the connection. - for i := 1; i <= numReqs; i++ { - req, _ := NewRequest("POST", "http://other.tld/", strings.NewReader(reqBody(i))) - req.Header.Set("X-Want-Response-Code", "123 Sesame Street") - testResponse(req, fmt.Sprintf("123, %d/%d", i, numReqs), 123) - } -} - -type proxyFromEnvTest struct { - req string // URL to fetch; blank means "http://example.com" - env string - noenv string - want string - wanterr error -} - -func (t proxyFromEnvTest) String() string { - var buf bytes.Buffer - if t.env != "" { - fmt.Fprintf(&buf, "http_proxy=%q", t.env) - } - if t.noenv != "" { - fmt.Fprintf(&buf, " no_proxy=%q", t.noenv) - } - req := "http://example.com" - if t.req != "" { - req = t.req - } - fmt.Fprintf(&buf, " req=%q", req) - return strings.TrimSpace(buf.String()) -} - -var proxyFromEnvTests = []proxyFromEnvTest{ - {env: "127.0.0.1:8080", want: "http://127.0.0.1:8080"}, - {env: "cache.corp.example.com:1234", want: "http://cache.corp.example.com:1234"}, - {env: "cache.corp.example.com", want: "http://cache.corp.example.com"}, - {env: "https://cache.corp.example.com", want: "https://cache.corp.example.com"}, - {env: "http://127.0.0.1:8080", want: "http://127.0.0.1:8080"}, - {env: "https://127.0.0.1:8080", want: "https://127.0.0.1:8080"}, - {want: ""}, - {noenv: "example.com", req: "http://example.com/", env: "proxy", want: ""}, - {noenv: ".example.com", req: "http://example.com/", env: "proxy", want: ""}, - {noenv: "ample.com", req: "http://example.com/", env: "proxy", want: "http://proxy"}, - {noenv: "example.com", req: "http://foo.example.com/", env: "proxy", want: ""}, - {noenv: ".foo.com", req: "http://example.com/", env: "proxy", want: "http://proxy"}, -} - -func TestProxyFromEnvironment(t *testing.T) { - ResetProxyEnv() - for _, tt := range proxyFromEnvTests { - os.Setenv("HTTP_PROXY", tt.env) - os.Setenv("NO_PROXY", tt.noenv) - ResetCachedEnvironment() - reqURL := tt.req - if reqURL == "" { - reqURL = "http://example.com" - } - req, _ := NewRequest("GET", reqURL, nil) - url, err := ProxyFromEnvironment(req) - if g, e := fmt.Sprintf("%v", err), fmt.Sprintf("%v", tt.wanterr); g != e { - t.Errorf("%v: got error = %q, want %q", tt, g, e) - continue - } - if got := fmt.Sprintf("%s", url); got != tt.want { - t.Errorf("%v: got URL = %q, want %q", tt, url, tt.want) - } - } -} - -func TestIdleConnChannelLeak(t *testing.T) { - var mu sync.Mutex - var n int - - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - mu.Lock() - n++ - mu.Unlock() - })) - defer ts.Close() - - tr := &Transport{ - Dial: func(netw, addr string) (net.Conn, error) { - return net.Dial(netw, ts.Listener.Addr().String()) - }, - } - defer tr.CloseIdleConnections() - - c := &Client{Transport: tr} - - // First, without keep-alives. - for _, disableKeep := range []bool{true, false} { - tr.DisableKeepAlives = disableKeep - for i := 0; i < 5; i++ { - _, err := c.Get(fmt.Sprintf("http://foo-host-%d.tld/", i)) - if err != nil { - t.Fatal(err) - } - } - if got := tr.IdleConnChMapSizeForTesting(); got != 0 { - t.Fatalf("ForDisableKeepAlives = %v, map size = %d; want 0", disableKeep, got) - } - } -} - -// Verify the status quo: that the Client.Post function coerces its -// body into a ReadCloser if it's a Closer, and that the Transport -// then closes it. -func TestTransportClosesRequestBody(t *testing.T) { - defer afterTest(t) - ts := httptest.NewServer(http.HandlerFunc(func(w ResponseWriter, r *Request) { - io.Copy(ioutil.Discard, r.Body) - })) - defer ts.Close() - - tr := &Transport{} - defer tr.CloseIdleConnections() - cl := &Client{Transport: tr} - - closes := 0 - - res, err := cl.Post(ts.URL, "text/plain", countCloseReader{&closes, strings.NewReader("hello")}) - if err != nil { - t.Fatal(err) - } - res.Body.Close() - if closes != 1 { - t.Errorf("closes = %d; want 1", closes) - } -} - -func TestTransportTLSHandshakeTimeout(t *testing.T) { - defer afterTest(t) - if testing.Short() { - t.Skip("skipping in short mode") - } - ln := newLocalListener(t) - defer ln.Close() - testdonec := make(chan struct{}) - defer close(testdonec) - - go func() { - c, err := ln.Accept() - if err != nil { - t.Error(err) - return - } - <-testdonec - c.Close() - }() - - getdonec := make(chan struct{}) - go func() { - defer close(getdonec) - tr := &Transport{ - Dial: func(_, _ string) (net.Conn, error) { - return net.Dial("tcp", ln.Addr().String()) - }, - TLSHandshakeTimeout: 250 * time.Millisecond, - } - cl := &Client{Transport: tr} - _, err := cl.Get("https://dummy.tld/") - if err == nil { - t.Error("expected error") - return - } - ue, ok := err.(*url.Error) - if !ok { - t.Errorf("expected url.Error; got %#v", err) - return - } - ne, ok := ue.Err.(net.Error) - if !ok { - t.Errorf("expected net.Error; got %#v", err) - return - } - if !ne.Timeout() { - t.Errorf("expected timeout error; got %v", err) - } - if !strings.Contains(err.Error(), "handshake timeout") { - t.Errorf("expected 'handshake timeout' in error; got %v", err) - } - }() - select { - case <-getdonec: - case <-time.After(5 * time.Second): - t.Error("test timeout; TLS handshake hung?") - } -} - -// Trying to repro golang.org/issue/3514 -func TestTLSServerClosesConnection(t *testing.T) { - defer afterTest(t) - if runtime.GOOS == "windows" { - t.Skip("skipping flaky test on Windows; golang.org/issue/7634") - } - closedc := make(chan bool, 1) - ts := httptest.NewTLSServer(HandlerFunc(func(w ResponseWriter, r *Request) { - if strings.Contains(r.URL.Path, "/keep-alive-then-die") { - conn, _, _ := w.(Hijacker).Hijack() - conn.Write([]byte("HTTP/1.1 200 OK\r\nContent-Length: 3\r\n\r\nfoo")) - conn.Close() - closedc <- true - return - } - fmt.Fprintf(w, "hello") - })) - defer ts.Close() - tr := &Transport{ - TLSClientConfig: &tls.Config{ - InsecureSkipVerify: true, - }, - } - defer tr.CloseIdleConnections() - client := &Client{Transport: tr} - - var nSuccess = 0 - var errs []error - const trials = 20 - for i := 0; i < trials; i++ { - tr.CloseIdleConnections() - res, err := client.Get(ts.URL + "/keep-alive-then-die") - if err != nil { - t.Fatal(err) - } - <-closedc - slurp, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatal(err) - } - if string(slurp) != "foo" { - t.Errorf("Got %q, want foo", slurp) - } - - // Now try again and see if we successfully - // pick a new connection. - res, err = client.Get(ts.URL + "/") - if err != nil { - errs = append(errs, err) - continue - } - slurp, err = ioutil.ReadAll(res.Body) - if err != nil { - errs = append(errs, err) - continue - } - nSuccess++ - } - if nSuccess > 0 { - t.Logf("successes = %d of %d", nSuccess, trials) - } else { - t.Errorf("All runs failed:") - } - for _, err := range errs { - t.Logf(" err: %v", err) - } -} - -// byteFromChanReader is an io.Reader that reads a single byte at a -// time from the channel. When the channel is closed, the reader -// returns io.EOF. -type byteFromChanReader chan byte - -func (c byteFromChanReader) Read(p []byte) (n int, err error) { - if len(p) == 0 { - return - } - b, ok := <-c - if !ok { - return 0, io.EOF - } - p[0] = b - return 1, nil -} - -// Verifies that the Transport doesn't reuse a connection in the case -// where the server replies before the request has been fully -// written. We still honor that reply (see TestIssue3595), but don't -// send future requests on the connection because it's then in a -// questionable state. -// golang.org/issue/7569 -func TestTransportNoReuseAfterEarlyResponse(t *testing.T) { - defer afterTest(t) - var sconn struct { - sync.Mutex - c net.Conn - } - var getOkay bool - closeConn := func() { - sconn.Lock() - defer sconn.Unlock() - if sconn.c != nil { - sconn.c.Close() - sconn.c = nil - if !getOkay { - t.Logf("Closed server connection") - } - } - } - defer closeConn() - - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - if r.Method == "GET" { - io.WriteString(w, "bar") - return - } - conn, _, _ := w.(Hijacker).Hijack() - sconn.Lock() - sconn.c = conn - sconn.Unlock() - conn.Write([]byte("HTTP/1.1 200 OK\r\nContent-Length: 3\r\n\r\nfoo")) // keep-alive - go io.Copy(ioutil.Discard, conn) - })) - defer ts.Close() - tr := &Transport{} - defer tr.CloseIdleConnections() - client := &Client{Transport: tr} - - const bodySize = 256 << 10 - finalBit := make(byteFromChanReader, 1) - req, _ := NewRequest("POST", ts.URL, io.MultiReader(io.LimitReader(neverEnding('x'), bodySize-1), finalBit)) - req.ContentLength = bodySize - res, err := client.Do(req) - if err := wantBody(res, err, "foo"); err != nil { - t.Errorf("POST response: %v", err) - } - donec := make(chan bool) - go func() { - defer close(donec) - res, err = client.Get(ts.URL) - if err := wantBody(res, err, "bar"); err != nil { - t.Errorf("GET response: %v", err) - return - } - getOkay = true // suppress test noise - }() - time.AfterFunc(5*time.Second, closeConn) - select { - case <-donec: - finalBit <- 'x' // unblock the writeloop of the first Post - close(finalBit) - case <-time.After(7 * time.Second): - t.Fatal("timeout waiting for GET request to finish") - } -} - -type errorReader struct { - err error -} - -func (e errorReader) Read(p []byte) (int, error) { return 0, e.err } - -type closerFunc func() error - -func (f closerFunc) Close() error { return f() } - -// Issue 6981 -func TestTransportClosesBodyOnError(t *testing.T) { - if runtime.GOOS == "plan9" { - t.Skip("skipping test; see http://golang.org/issue/7782") - } - defer afterTest(t) - readBody := make(chan error, 1) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - _, err := ioutil.ReadAll(r.Body) - readBody <- err - })) - defer ts.Close() - fakeErr := errors.New("fake error") - didClose := make(chan bool, 1) - req, _ := NewRequest("POST", ts.URL, struct { - io.Reader - io.Closer - }{ - io.MultiReader(io.LimitReader(neverEnding('x'), 1<<20), errorReader{fakeErr}), - closerFunc(func() error { - select { - case didClose <- true: - default: - } - return nil - }), - }) - res, err := DefaultClient.Do(req) - if res != nil { - defer res.Body.Close() - } - if err == nil || !strings.Contains(err.Error(), fakeErr.Error()) { - t.Fatalf("Do error = %v; want something containing %q", err, fakeErr.Error()) - } - select { - case err := <-readBody: - if err == nil { - t.Errorf("Unexpected success reading request body from handler; want 'unexpected EOF reading trailer'") - } - case <-time.After(5 * time.Second): - t.Error("timeout waiting for server handler to complete") - } - select { - case <-didClose: - default: - t.Errorf("didn't see Body.Close") - } -} - -func wantBody(res *http.Response, err error, want string) error { - if err != nil { - return err - } - slurp, err := ioutil.ReadAll(res.Body) - if err != nil { - return fmt.Errorf("error reading body: %v", err) - } - if string(slurp) != want { - return fmt.Errorf("body = %q; want %q", slurp, want) - } - if err := res.Body.Close(); err != nil { - return fmt.Errorf("body Close = %v", err) - } - return nil -} - -func newLocalListener(t *testing.T) net.Listener { - ln, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - ln, err = net.Listen("tcp6", "[::1]:0") - } - if err != nil { - t.Fatal(err) - } - return ln -} - -type countCloseReader struct { - n *int - io.Reader -} - -func (cr countCloseReader) Close() error { - (*cr.n)++ - return nil -} - -// rgz is a gzip quine that uncompresses to itself. -var rgz = []byte{ - 0x1f, 0x8b, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x72, 0x65, 0x63, 0x75, 0x72, 0x73, - 0x69, 0x76, 0x65, 0x00, 0x92, 0xef, 0xe6, 0xe0, - 0x60, 0x00, 0x83, 0xa2, 0xd4, 0xe4, 0xd2, 0xa2, - 0xe2, 0xcc, 0xb2, 0x54, 0x06, 0x00, 0x00, 0x17, - 0x00, 0xe8, 0xff, 0x92, 0xef, 0xe6, 0xe0, 0x60, - 0x00, 0x83, 0xa2, 0xd4, 0xe4, 0xd2, 0xa2, 0xe2, - 0xcc, 0xb2, 0x54, 0x06, 0x00, 0x00, 0x17, 0x00, - 0xe8, 0xff, 0x42, 0x12, 0x46, 0x16, 0x06, 0x00, - 0x05, 0x00, 0xfa, 0xff, 0x42, 0x12, 0x46, 0x16, - 0x06, 0x00, 0x05, 0x00, 0xfa, 0xff, 0x00, 0x05, - 0x00, 0xfa, 0xff, 0x00, 0x14, 0x00, 0xeb, 0xff, - 0x42, 0x12, 0x46, 0x16, 0x06, 0x00, 0x05, 0x00, - 0xfa, 0xff, 0x00, 0x05, 0x00, 0xfa, 0xff, 0x00, - 0x14, 0x00, 0xeb, 0xff, 0x42, 0x88, 0x21, 0xc4, - 0x00, 0x00, 0x14, 0x00, 0xeb, 0xff, 0x42, 0x88, - 0x21, 0xc4, 0x00, 0x00, 0x14, 0x00, 0xeb, 0xff, - 0x42, 0x88, 0x21, 0xc4, 0x00, 0x00, 0x14, 0x00, - 0xeb, 0xff, 0x42, 0x88, 0x21, 0xc4, 0x00, 0x00, - 0x14, 0x00, 0xeb, 0xff, 0x42, 0x88, 0x21, 0xc4, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0x00, 0xff, 0xff, 0x00, 0x17, 0x00, 0xe8, 0xff, - 0x42, 0x88, 0x21, 0xc4, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, - 0x17, 0x00, 0xe8, 0xff, 0x42, 0x12, 0x46, 0x16, - 0x06, 0x00, 0x00, 0x00, 0xff, 0xff, 0x01, 0x08, - 0x00, 0xf7, 0xff, 0x3d, 0xb1, 0x20, 0x85, 0xfa, - 0x00, 0x00, 0x00, 0x42, 0x12, 0x46, 0x16, 0x06, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x01, 0x08, 0x00, - 0xf7, 0xff, 0x3d, 0xb1, 0x20, 0x85, 0xfa, 0x00, - 0x00, 0x00, 0x3d, 0xb1, 0x20, 0x85, 0xfa, 0x00, - 0x00, 0x00, -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/z_last_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/z_last_test.go deleted file mode 100644 index 5a0cc11984..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/http/z_last_test.go +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http_test - -import ( - "net/http" - "runtime" - "sort" - "strings" - "testing" - "time" -) - -func interestingGoroutines() (gs []string) { - buf := make([]byte, 2<<20) - buf = buf[:runtime.Stack(buf, true)] - for _, g := range strings.Split(string(buf), "\n\n") { - sl := strings.SplitN(g, "\n", 2) - if len(sl) != 2 { - continue - } - stack := strings.TrimSpace(sl[1]) - if stack == "" || - strings.Contains(stack, "created by net.startServer") || - strings.Contains(stack, "created by testing.RunTests") || - strings.Contains(stack, "closeWriteAndWait") || - strings.Contains(stack, "testing.Main(") || - // These only show up with GOTRACEBACK=2; Issue 5005 (comment 28) - strings.Contains(stack, "runtime.goexit") || - strings.Contains(stack, "created by runtime.gc") || - strings.Contains(stack, "runtime.MHeap_Scavenger") { - continue - } - gs = append(gs, stack) - } - sort.Strings(gs) - return -} - -// Verify the other tests didn't leave any goroutines running. -// This is in a file named z_last_test.go so it sorts at the end. -func TestGoroutinesRunning(t *testing.T) { - if testing.Short() { - t.Skip("not counting goroutines for leakage in -short mode") - } - gs := interestingGoroutines() - - n := 0 - stackCount := make(map[string]int) - for _, g := range gs { - stackCount[g]++ - n++ - } - - t.Logf("num goroutines = %d", n) - if n > 0 { - t.Error("Too many goroutines.") - for stack, count := range stackCount { - t.Logf("%d instances of:\n%s", count, stack) - } - } -} - -func afterTest(t *testing.T) { - http.DefaultTransport.(*http.Transport).CloseIdleConnections() - if testing.Short() { - return - } - var bad string - badSubstring := map[string]string{ - ").readLoop(": "a Transport", - ").writeLoop(": "a Transport", - "created by net/http/httptest.(*Server).Start": "an httptest.Server", - "timeoutHandler": "a TimeoutHandler", - "net.(*netFD).connect(": "a timing out dial", - ").noteClientGone(": "a closenotifier sender", - } - var stacks string - for i := 0; i < 4; i++ { - bad = "" - stacks = strings.Join(interestingGoroutines(), "\n\n") - for substr, what := range badSubstring { - if strings.Contains(stacks, substr) { - bad = what - } - } - if bad == "" { - return - } - // Bad stuff found, but goroutines might just still be - // shutting down, so give it some time. - time.Sleep(250 * time.Millisecond) - } - t.Errorf("Test appears to have leaked %s:\n%s", bad, stacks) -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/conn_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/conn_test.go deleted file mode 100644 index 5c555147ca..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/conn_test.go +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package tls - -import ( - "testing" -) - -func TestRoundUp(t *testing.T) { - if roundUp(0, 16) != 0 || - roundUp(1, 16) != 16 || - roundUp(15, 16) != 16 || - roundUp(16, 16) != 16 || - roundUp(17, 16) != 32 { - t.Error("roundUp broken") - } -} - -var paddingTests = []struct { - in []byte - good bool - expectedLen int -}{ - {[]byte{1, 2, 3, 4, 0}, true, 4}, - {[]byte{1, 2, 3, 4, 0, 1}, false, 0}, - {[]byte{1, 2, 3, 4, 99, 99}, false, 0}, - {[]byte{1, 2, 3, 4, 1, 1}, true, 4}, - {[]byte{1, 2, 3, 2, 2, 2}, true, 3}, - {[]byte{1, 2, 3, 3, 3, 3}, true, 2}, - {[]byte{1, 2, 3, 4, 3, 3}, false, 0}, - {[]byte{1, 4, 4, 4, 4, 4}, true, 1}, - {[]byte{5, 5, 5, 5, 5, 5}, true, 0}, - {[]byte{6, 6, 6, 6, 6, 6}, false, 0}, -} - -func TestRemovePadding(t *testing.T) { - for i, test := range paddingTests { - payload, good := removePadding(test.in) - expectedGood := byte(255) - if !test.good { - expectedGood = 0 - } - if good != expectedGood { - t.Errorf("#%d: wrong validity, want:%d got:%d", i, expectedGood, good) - } - if good == 255 && len(payload) != test.expectedLen { - t.Errorf("#%d: got %d, want %d", i, len(payload), test.expectedLen) - } - } -} - -var certExampleCom = `308201403081eda003020102020101300b06092a864886f70d010105301e311c301a060355040a131354657374696e67204365727469666963617465301e170d3131313030313138353835325a170d3132303933303138353835325a301e311c301a060355040a131354657374696e67204365727469666963617465305a300b06092a864886f70d010101034b003048024100bced6e32368599eeddf18796bfd03958a154f87e5b084f96e85136a56b886733592f493f0fc68b0d6b3551781cb95e13c5de458b28d6fb60d20a9129313261410203010001a31a301830160603551d11040f300d820b6578616d706c652e636f6d300b06092a864886f70d0101050341001a0b419d2c74474c6450654e5f10b32bf426ffdf55cad1c52602e7a9151513a3424c70f5960dcd682db0c33769cc1daa3fcdd3db10809d2392ed4a1bf50ced18` - -var certWildcardExampleCom = `308201423081efa003020102020101300b06092a864886f70d010105301e311c301a060355040a131354657374696e67204365727469666963617465301e170d3131313030313139303034365a170d3132303933303139303034365a301e311c301a060355040a131354657374696e67204365727469666963617465305a300b06092a864886f70d010101034b003048024100bced6e32368599eeddf18796bfd03958a154f87e5b084f96e85136a56b886733592f493f0fc68b0d6b3551781cb95e13c5de458b28d6fb60d20a9129313261410203010001a31c301a30180603551d110411300f820d2a2e6578616d706c652e636f6d300b06092a864886f70d0101050341001676f0c9e7c33c1b656ed5a6476c4e2ee9ec8e62df7407accb1875272b2edd0a22096cb2c22598d11604104d604f810eb4b5987ca6bb319c7e6ce48725c54059` - -var certFooExampleCom = `308201443081f1a003020102020101300b06092a864886f70d010105301e311c301a060355040a131354657374696e67204365727469666963617465301e170d3131313030313139303131345a170d3132303933303139303131345a301e311c301a060355040a131354657374696e67204365727469666963617465305a300b06092a864886f70d010101034b003048024100bced6e32368599eeddf18796bfd03958a154f87e5b084f96e85136a56b886733592f493f0fc68b0d6b3551781cb95e13c5de458b28d6fb60d20a9129313261410203010001a31e301c301a0603551d1104133011820f666f6f2e6578616d706c652e636f6d300b06092a864886f70d010105034100646a2a51f2aa2477add854b462cf5207ba16d3213ffb5d3d0eed473fbf09935019192d1d5b8ca6a2407b424cf04d97c4cd9197c83ecf81f0eab9464a1109d09f` - -var certDoubleWildcardExampleCom = `308201443081f1a003020102020101300b06092a864886f70d010105301e311c301a060355040a131354657374696e67204365727469666963617465301e170d3131313030313139303134315a170d3132303933303139303134315a301e311c301a060355040a131354657374696e67204365727469666963617465305a300b06092a864886f70d010101034b003048024100bced6e32368599eeddf18796bfd03958a154f87e5b084f96e85136a56b886733592f493f0fc68b0d6b3551781cb95e13c5de458b28d6fb60d20a9129313261410203010001a31e301c301a0603551d1104133011820f2a2e2a2e6578616d706c652e636f6d300b06092a864886f70d0101050341001c3de267975f56ef57771c6218ef95ecc65102e57bd1defe6f7efea90d9b26cf40de5bd7ad75e46201c7f2a92aaa3e907451e9409f65e28ddb6db80d726290f6` - -func TestCertificateSelection(t *testing.T) { - config := Config{ - Certificates: []Certificate{ - { - Certificate: [][]byte{fromHex(certExampleCom)}, - }, - { - Certificate: [][]byte{fromHex(certWildcardExampleCom)}, - }, - { - Certificate: [][]byte{fromHex(certFooExampleCom)}, - }, - { - Certificate: [][]byte{fromHex(certDoubleWildcardExampleCom)}, - }, - }, - } - - config.BuildNameToCertificate() - - pointerToIndex := func(c *Certificate) int { - for i := range config.Certificates { - if c == &config.Certificates[i] { - return i - } - } - return -1 - } - - if n := pointerToIndex(config.getCertificateForName("example.com")); n != 0 { - t.Errorf("example.com returned certificate %d, not 0", n) - } - if n := pointerToIndex(config.getCertificateForName("bar.example.com")); n != 1 { - t.Errorf("bar.example.com returned certificate %d, not 1", n) - } - if n := pointerToIndex(config.getCertificateForName("foo.example.com")); n != 2 { - t.Errorf("foo.example.com returned certificate %d, not 2", n) - } - if n := pointerToIndex(config.getCertificateForName("foo.bar.example.com")); n != 3 { - t.Errorf("foo.bar.example.com returned certificate %d, not 3", n) - } - if n := pointerToIndex(config.getCertificateForName("foo.bar.baz.example.com")); n != 0 { - t.Errorf("foo.bar.baz.example.com returned certificate %d, not 0", n) - } -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/handshake_client_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/handshake_client_test.go deleted file mode 100644 index 6c564001b0..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/handshake_client_test.go +++ /dev/null @@ -1,3050 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package tls - -import ( - "bytes" - "flag" - "io" - "net" - "os" - "testing" -) - -func testClientScript(t *testing.T, name string, clientScript [][]byte, config *Config) { - c, s := net.Pipe() - cli := Client(c, config) - go func() { - cli.Write([]byte("hello\n")) - cli.Close() - c.Close() - }() - - defer c.Close() - for i, b := range clientScript { - if i%2 == 1 { - s.Write(b) - continue - } - bb := make([]byte, len(b)) - _, err := io.ReadFull(s, bb) - if err != nil { - t.Fatalf("%s #%d: %s", name, i, err) - } - if !bytes.Equal(b, bb) { - t.Fatalf("%s #%d: mismatch on read: got:%x want:%x", name, i, bb, b) - } - } -} - -func TestHandshakeClientRSARC4(t *testing.T) { - var config = *testConfig - config.CipherSuites = []uint16{TLS_RSA_WITH_RC4_128_SHA} - testClientScript(t, "RSA-RC4", rsaRC4ClientScript, &config) -} - -func TestHandshakeClientECDHERSAAES(t *testing.T) { - var config = *testConfig - config.CipherSuites = []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA} - testClientScript(t, "ECDHE-RSA-AES", ecdheRSAAESClientScript, &config) -} - -func TestHandshakeClientECDHECDSAAES(t *testing.T) { - var config = *testConfig - config.CipherSuites = []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA} - config.Certificates = nil - config.BuildNameToCertificate() - testClientScript(t, "ECDHE-ECDSA-AES", ecdheECDSAAESClientScript, &config) -} - -func TestLongClientCerticiateChain(t *testing.T) { - config := *testConfig - cert, _ := X509KeyPair(testClientChainCertificate, testClientChainCertificate) - config.Certificates = []Certificate{cert} - testClientScript(t, "Long client certificate chains", clientChainCertificateScript, &config) -} - -func TestHandshakeClientTLS11(t *testing.T) { - var config = *testConfig - config.MaxVersion = VersionTLS11 - config.CipherSuites = []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA} - testClientScript(t, "TLS11-ECDHE-AES", tls11ECDHEAESClientScript, &config) -} - -func TestHandshakeClientTLS12(t *testing.T) { - config := *testConfig - config.MaxVersion = VersionTLS12 - config.CipherSuites = []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA} - cert, _ := X509KeyPair(testClientChainCertificate, testClientChainCertificate) - config.Certificates = []Certificate{cert} - testClientScript(t, "TLS12", clientTLS12Script, &config) -} - -func TestHandshakeClientTLS12ClientCert(t *testing.T) { - config := *testConfig - config.MaxVersion = VersionTLS12 - config.CipherSuites = []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256} - cert, _ := X509KeyPair(testClientChainCertificate, testClientChainCertificate) - config.Certificates = []Certificate{cert} - testClientScript(t, "TLS12ClientCert", clientTLS12ClientCertScript, &config) -} - -var connect = flag.Bool("connect", false, "connect to a TLS server on :10443") - -func TestRunClient(t *testing.T) { - if !*connect { - return - } - - tcpConn, err := net.Dial("tcp", "127.0.0.1:10443") - if err != nil { - t.Fatal(err) - } - - record := &recordingConn{ - Conn: tcpConn, - } - - config := GetTestConfig() - conn := Client(record, config) - if err := conn.Handshake(); err != nil { - t.Fatalf("error from TLS handshake: %s", err) - } - - conn.Write([]byte("hello\n")) - conn.Close() - - record.WriteTo(os.Stdout) -} - -func TestEmptyRecords(t *testing.T) { - // emptyRecordScript contains a TLS connection with an empty record as - // the first application data from the server. This test ensures that - // the empty record doesn't cause (0, nil) to be returned from - // Conn.Read. - config := *testConfig - config.CipherSuites = []uint16{TLS_RSA_WITH_AES_256_CBC_SHA} - - c, s := net.Pipe() - cli := Client(c, &config) - go func() { - buf := make([]byte, 1024) - n, err := cli.Read(buf) - defer c.Close() - defer cli.Close() - - if err != nil { - t.Fatalf("error reading from tls.Client: %s", err) - } - const expectedLength = 197 - if n != expectedLength { - t.Fatalf("incorrect length reading from tls.Client, got %d, want %d", n, expectedLength) - } - }() - - defer c.Close() - for i, b := range emptyRecordScript { - if i%2 == 1 { - s.Write(b) - continue - } - bb := make([]byte, len(b)) - _, err := io.ReadFull(s, bb) - if err != nil { - t.Fatalf("#%d: %s", i, err) - } - if !bytes.Equal(b, bb) { - t.Fatalf("#%d: mismatch on read: got:%x want:%x", i, bb, b) - } - } -} - -// Script of interaction with gnutls implementation. -// The values for this test are obtained by building and running in client mode: -// % go test -test.run "TestRunClient" -connect -// The recorded bytes are written to stdout. -// -// The server private key is: -// -----BEGIN RSA PRIVATE KEY----- -// MIIBPAIBAAJBAJ+zw4Qnlf8SMVIPFe9GEcStgOY2Ww/dgNdhjeD8ckUJNP5VZkVD -// TGiXav6ooKXfX3j/7tdkuD8Ey2//Kv7+ue0CAwEAAQJAN6W31vDEP2DjdqhzCDDu -// OA4NACqoiFqyblo7yc2tM4h4xMbC3Yx5UKMN9ZkCtX0gzrz6DyF47bdKcWBzNWCj -// gQIhANEoojVt7hq+SQ6MCN6FTAysGgQf56Q3TYoJMoWvdiXVAiEAw3e3rc+VJpOz -// rHuDo6bgpjUAAXM+v3fcpsfZSNO6V7kCIQCtbVjanpUwvZkMI9by02oUk9taki3b -// PzPfAfNPYAbCJQIhAJXNQDWyqwn/lGmR11cqY2y9nZ1+5w3yHGatLrcDnQHxAiEA -// vnlEGo8K85u+KwIOimM48ZG8oTk7iFdkqLJR1utT3aU= -// -----END RSA PRIVATE KEY----- -// -// and certificate is: -// -----BEGIN CERTIFICATE----- -// MIICKzCCAdWgAwIBAgIJALE1E2URIMWSMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV -// BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX -// aWRnaXRzIFB0eSBMdGQwHhcNMTIwNDA2MTcxMDEzWhcNMTUwNDA2MTcxMDEzWjBF -// MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 -// ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJ+z -// w4Qnlf8SMVIPFe9GEcStgOY2Ww/dgNdhjeD8ckUJNP5VZkVDTGiXav6ooKXfX3j/ -// 7tdkuD8Ey2//Kv7+ue0CAwEAAaOBpzCBpDAdBgNVHQ4EFgQUeKaXmmO1xaGlM7oi -// fCNuWxt6zCswdQYDVR0jBG4wbIAUeKaXmmO1xaGlM7oifCNuWxt6zCuhSaRHMEUx -// CzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRl -// cm5ldCBXaWRnaXRzIFB0eSBMdGSCCQCxNRNlESDFkjAMBgNVHRMEBTADAQH/MA0G -// CSqGSIb3DQEBBQUAA0EAhTZAc8G7GtrUWZ8tonAxRnTsg26oyDxRrzms7EC86CJG -// HZnWRiok1IsFCEv7NRFukrt3uuQSu/TIXpyBqJdgTA== -// -----END CERTIFICATE----- -var rsaRC4ClientScript = [][]byte{ - { - 0x16, 0x03, 0x01, 0x00, 0x4a, 0x01, 0x00, 0x00, - 0x46, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x05, - 0x01, 0x00, 0x00, 0x1b, 0x00, 0x05, 0x00, 0x05, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, - 0x08, 0x00, 0x06, 0x00, 0x17, 0x00, 0x18, 0x00, - 0x19, 0x00, 0x0b, 0x00, 0x02, 0x01, 0x00, - }, - - { - 0x16, 0x03, 0x01, 0x00, 0x4a, 0x02, 0x00, 0x00, - 0x46, 0x03, 0x01, 0x4d, 0x0a, 0x56, 0x16, 0xb5, - 0x91, 0xd1, 0xcb, 0x80, 0x4d, 0xc7, 0x46, 0xf3, - 0x37, 0x0c, 0xef, 0xea, 0x64, 0x11, 0x14, 0x56, - 0x97, 0x9b, 0xc5, 0x67, 0x08, 0xb7, 0x13, 0xea, - 0xf8, 0xc9, 0xb3, 0x20, 0xe2, 0xfc, 0x41, 0xf6, - 0x96, 0x90, 0x9d, 0x43, 0x9b, 0xe9, 0x6e, 0xf8, - 0x41, 0x16, 0xcc, 0xf3, 0xc7, 0xde, 0xda, 0x5a, - 0xa1, 0x33, 0x69, 0xe2, 0xde, 0x5b, 0xaf, 0x2a, - 0x92, 0xe7, 0xd4, 0xa0, 0x00, 0x05, 0x00, 0x16, - 0x03, 0x01, 0x01, 0xf7, 0x0b, 0x00, 0x01, 0xf3, - 0x00, 0x01, 0xf0, 0x00, 0x01, 0xed, 0x30, 0x82, - 0x01, 0xe9, 0x30, 0x82, 0x01, 0x52, 0x02, 0x01, - 0x06, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, - 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x04, 0x05, 0x00, - 0x30, 0x5b, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, - 0x55, 0x04, 0x06, 0x13, 0x02, 0x41, 0x55, 0x31, - 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, - 0x13, 0x0a, 0x51, 0x75, 0x65, 0x65, 0x6e, 0x73, - 0x6c, 0x61, 0x6e, 0x64, 0x31, 0x1a, 0x30, 0x18, - 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x11, 0x43, - 0x72, 0x79, 0x70, 0x74, 0x53, 0x6f, 0x66, 0x74, - 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, 0x74, 0x64, - 0x31, 0x1b, 0x30, 0x19, 0x06, 0x03, 0x55, 0x04, - 0x03, 0x13, 0x12, 0x54, 0x65, 0x73, 0x74, 0x20, - 0x43, 0x41, 0x20, 0x28, 0x31, 0x30, 0x32, 0x34, - 0x20, 0x62, 0x69, 0x74, 0x29, 0x30, 0x1e, 0x17, - 0x0d, 0x30, 0x30, 0x31, 0x30, 0x31, 0x36, 0x32, - 0x32, 0x33, 0x31, 0x30, 0x33, 0x5a, 0x17, 0x0d, - 0x30, 0x33, 0x30, 0x31, 0x31, 0x34, 0x32, 0x32, - 0x33, 0x31, 0x30, 0x33, 0x5a, 0x30, 0x63, 0x31, - 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, - 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, - 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x51, - 0x75, 0x65, 0x65, 0x6e, 0x73, 0x6c, 0x61, 0x6e, - 0x64, 0x31, 0x1a, 0x30, 0x18, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x13, 0x11, 0x43, 0x72, 0x79, 0x70, - 0x74, 0x53, 0x6f, 0x66, 0x74, 0x20, 0x50, 0x74, - 0x79, 0x20, 0x4c, 0x74, 0x64, 0x31, 0x23, 0x30, - 0x21, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x1a, - 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x74, - 0x65, 0x73, 0x74, 0x20, 0x63, 0x65, 0x72, 0x74, - 0x20, 0x28, 0x35, 0x31, 0x32, 0x20, 0x62, 0x69, - 0x74, 0x29, 0x30, 0x5c, 0x30, 0x0d, 0x06, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x01, 0x05, 0x00, 0x03, 0x4b, 0x00, 0x30, 0x48, - 0x02, 0x41, 0x00, 0x9f, 0xb3, 0xc3, 0x84, 0x27, - 0x95, 0xff, 0x12, 0x31, 0x52, 0x0f, 0x15, 0xef, - 0x46, 0x11, 0xc4, 0xad, 0x80, 0xe6, 0x36, 0x5b, - 0x0f, 0xdd, 0x80, 0xd7, 0x61, 0x8d, 0xe0, 0xfc, - 0x72, 0x45, 0x09, 0x34, 0xfe, 0x55, 0x66, 0x45, - 0x43, 0x4c, 0x68, 0x97, 0x6a, 0xfe, 0xa8, 0xa0, - 0xa5, 0xdf, 0x5f, 0x78, 0xff, 0xee, 0xd7, 0x64, - 0xb8, 0x3f, 0x04, 0xcb, 0x6f, 0xff, 0x2a, 0xfe, - 0xfe, 0xb9, 0xed, 0x02, 0x03, 0x01, 0x00, 0x01, - 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, - 0xf7, 0x0d, 0x01, 0x01, 0x04, 0x05, 0x00, 0x03, - 0x81, 0x81, 0x00, 0x93, 0xd2, 0x0a, 0xc5, 0x41, - 0xe6, 0x5a, 0xa9, 0x86, 0xf9, 0x11, 0x87, 0xe4, - 0xdb, 0x45, 0xe2, 0xc5, 0x95, 0x78, 0x1a, 0x6c, - 0x80, 0x6d, 0x73, 0x1f, 0xb4, 0x6d, 0x44, 0xa3, - 0xba, 0x86, 0x88, 0xc8, 0x58, 0xcd, 0x1c, 0x06, - 0x35, 0x6c, 0x44, 0x62, 0x88, 0xdf, 0xe4, 0xf6, - 0x64, 0x61, 0x95, 0xef, 0x4a, 0xa6, 0x7f, 0x65, - 0x71, 0xd7, 0x6b, 0x88, 0x39, 0xf6, 0x32, 0xbf, - 0xac, 0x93, 0x67, 0x69, 0x51, 0x8c, 0x93, 0xec, - 0x48, 0x5f, 0xc9, 0xb1, 0x42, 0xf9, 0x55, 0xd2, - 0x7e, 0x4e, 0xf4, 0xf2, 0x21, 0x6b, 0x90, 0x57, - 0xe6, 0xd7, 0x99, 0x9e, 0x41, 0xca, 0x80, 0xbf, - 0x1a, 0x28, 0xa2, 0xca, 0x5b, 0x50, 0x4a, 0xed, - 0x84, 0xe7, 0x82, 0xc7, 0xd2, 0xcf, 0x36, 0x9e, - 0x6a, 0x67, 0xb9, 0x88, 0xa7, 0xf3, 0x8a, 0xd0, - 0x04, 0xf8, 0xe8, 0xc6, 0x17, 0xe3, 0xc5, 0x29, - 0xbc, 0x17, 0xf1, 0x16, 0x03, 0x01, 0x00, 0x04, - 0x0e, 0x00, 0x00, 0x00, - }, - - { - 0x16, 0x03, 0x01, 0x00, 0x46, 0x10, 0x00, 0x00, - 0x42, 0x00, 0x40, 0x87, 0xa1, 0x1f, 0x14, 0xe1, - 0xfb, 0x91, 0xac, 0x58, 0x2e, 0xf3, 0x71, 0xce, - 0x01, 0x85, 0x2c, 0xc7, 0xfe, 0x84, 0x87, 0x82, - 0xb7, 0x57, 0xdb, 0x37, 0x4d, 0x46, 0x83, 0x67, - 0x52, 0x82, 0x51, 0x01, 0x95, 0x23, 0x68, 0x69, - 0x6b, 0xd0, 0xa7, 0xa7, 0xe5, 0x88, 0xd0, 0x47, - 0x71, 0xb8, 0xd2, 0x03, 0x05, 0x25, 0x56, 0x5c, - 0x10, 0x08, 0xc6, 0x9b, 0xd4, 0x67, 0xcd, 0x28, - 0xbe, 0x9c, 0x48, 0x14, 0x03, 0x01, 0x00, 0x01, - 0x01, 0x16, 0x03, 0x01, 0x00, 0x24, 0xc1, 0xb8, - 0xd3, 0x7f, 0xc5, 0xc2, 0x5a, 0x1d, 0x6d, 0x5b, - 0x2d, 0x5c, 0x82, 0x87, 0xc2, 0x6f, 0x0d, 0x63, - 0x7b, 0x72, 0x2b, 0xda, 0x69, 0xc4, 0xfe, 0x3c, - 0x84, 0xa1, 0x5a, 0x62, 0x38, 0x37, 0xc6, 0x54, - 0x25, 0x2a, - }, - - { - 0x14, 0x03, 0x01, 0x00, 0x01, 0x01, 0x16, 0x03, - 0x01, 0x00, 0x24, 0xea, 0x88, 0x9c, 0x00, 0xf6, - 0x35, 0xb8, 0x42, 0x7f, 0x15, 0x17, 0x76, 0x5e, - 0x4b, 0x24, 0xcb, 0x7e, 0xa0, 0x7b, 0xc3, 0x70, - 0x52, 0x0a, 0x88, 0x2a, 0x7a, 0x45, 0x59, 0x90, - 0x59, 0xac, 0xc6, 0xb5, 0x56, 0x55, 0x96, - }, -} - -var ecdheRSAAESClientScript = [][]byte{ - { - 0x16, 0x03, 0x01, 0x00, 0x4a, 0x01, 0x00, 0x00, - 0x46, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xc0, 0x13, - 0x01, 0x00, 0x00, 0x1b, 0x00, 0x05, 0x00, 0x05, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, - 0x08, 0x00, 0x06, 0x00, 0x17, 0x00, 0x18, 0x00, - 0x19, 0x00, 0x0b, 0x00, 0x02, 0x01, 0x00, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x52, 0x02, 0x00, 0x00, - 0x4e, 0x03, 0x01, 0x50, 0xad, 0x72, 0xb1, 0x14, - 0x45, 0xce, 0x0a, 0x95, 0xf9, 0x63, 0xef, 0xa8, - 0xe5, 0x07, 0x34, 0x04, 0xe9, 0x08, 0x0f, 0x38, - 0xe4, 0x28, 0x27, 0x91, 0x07, 0x03, 0xe2, 0xfe, - 0xe3, 0x25, 0xf7, 0x20, 0x08, 0x42, 0xa2, 0x01, - 0x69, 0x53, 0xf0, 0xd9, 0x4c, 0xfa, 0x01, 0xa1, - 0xce, 0x4b, 0xf8, 0x28, 0x21, 0xad, 0x06, 0xbe, - 0xe0, 0x1b, 0x3b, 0xf7, 0xec, 0xd2, 0x52, 0xae, - 0x2a, 0x57, 0xb7, 0xa8, 0xc0, 0x13, 0x00, 0x00, - 0x06, 0x00, 0x0b, 0x00, 0x02, 0x01, 0x00, 0x16, - 0x03, 0x01, 0x02, 0x39, 0x0b, 0x00, 0x02, 0x35, - 0x00, 0x02, 0x32, 0x00, 0x02, 0x2f, 0x30, 0x82, - 0x02, 0x2b, 0x30, 0x82, 0x01, 0xd5, 0xa0, 0x03, - 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0xb1, 0x35, - 0x13, 0x65, 0x11, 0x20, 0xc5, 0x92, 0x30, 0x0d, - 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, - 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x45, 0x31, - 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, - 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, - 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, - 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, - 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, - 0x20, 0x4c, 0x74, 0x64, 0x30, 0x1e, 0x17, 0x0d, - 0x31, 0x32, 0x30, 0x34, 0x30, 0x36, 0x31, 0x37, - 0x31, 0x30, 0x31, 0x33, 0x5a, 0x17, 0x0d, 0x31, - 0x35, 0x30, 0x34, 0x30, 0x36, 0x31, 0x37, 0x31, - 0x30, 0x31, 0x33, 0x5a, 0x30, 0x45, 0x31, 0x0b, - 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, - 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, - 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, - 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, - 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, - 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, - 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, - 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, - 0x4c, 0x74, 0x64, 0x30, 0x5c, 0x30, 0x0d, 0x06, - 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, - 0x01, 0x01, 0x05, 0x00, 0x03, 0x4b, 0x00, 0x30, - 0x48, 0x02, 0x41, 0x00, 0x9f, 0xb3, 0xc3, 0x84, - 0x27, 0x95, 0xff, 0x12, 0x31, 0x52, 0x0f, 0x15, - 0xef, 0x46, 0x11, 0xc4, 0xad, 0x80, 0xe6, 0x36, - 0x5b, 0x0f, 0xdd, 0x80, 0xd7, 0x61, 0x8d, 0xe0, - 0xfc, 0x72, 0x45, 0x09, 0x34, 0xfe, 0x55, 0x66, - 0x45, 0x43, 0x4c, 0x68, 0x97, 0x6a, 0xfe, 0xa8, - 0xa0, 0xa5, 0xdf, 0x5f, 0x78, 0xff, 0xee, 0xd7, - 0x64, 0xb8, 0x3f, 0x04, 0xcb, 0x6f, 0xff, 0x2a, - 0xfe, 0xfe, 0xb9, 0xed, 0x02, 0x03, 0x01, 0x00, - 0x01, 0xa3, 0x81, 0xa7, 0x30, 0x81, 0xa4, 0x30, - 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, - 0x04, 0x14, 0x78, 0xa6, 0x97, 0x9a, 0x63, 0xb5, - 0xc5, 0xa1, 0xa5, 0x33, 0xba, 0x22, 0x7c, 0x23, - 0x6e, 0x5b, 0x1b, 0x7a, 0xcc, 0x2b, 0x30, 0x75, - 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x6e, 0x30, - 0x6c, 0x80, 0x14, 0x78, 0xa6, 0x97, 0x9a, 0x63, - 0xb5, 0xc5, 0xa1, 0xa5, 0x33, 0xba, 0x22, 0x7c, - 0x23, 0x6e, 0x5b, 0x1b, 0x7a, 0xcc, 0x2b, 0xa1, - 0x49, 0xa4, 0x47, 0x30, 0x45, 0x31, 0x0b, 0x30, - 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, - 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, - 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, 0x6d, - 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, - 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, - 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, - 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, - 0x74, 0x64, 0x82, 0x09, 0x00, 0xb1, 0x35, 0x13, - 0x65, 0x11, 0x20, 0xc5, 0x92, 0x30, 0x0c, 0x06, - 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, - 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, 0x09, 0x2a, - 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, - 0x05, 0x00, 0x03, 0x41, 0x00, 0x85, 0x36, 0x40, - 0x73, 0xc1, 0xbb, 0x1a, 0xda, 0xd4, 0x59, 0x9f, - 0x2d, 0xa2, 0x70, 0x31, 0x46, 0x74, 0xec, 0x83, - 0x6e, 0xa8, 0xc8, 0x3c, 0x51, 0xaf, 0x39, 0xac, - 0xec, 0x40, 0xbc, 0xe8, 0x22, 0x46, 0x1d, 0x99, - 0xd6, 0x46, 0x2a, 0x24, 0xd4, 0x8b, 0x05, 0x08, - 0x4b, 0xfb, 0x35, 0x11, 0x6e, 0x92, 0xbb, 0x77, - 0xba, 0xe4, 0x12, 0xbb, 0xf4, 0xc8, 0x5e, 0x9c, - 0x81, 0xa8, 0x97, 0x60, 0x4c, 0x16, 0x03, 0x01, - 0x00, 0x8b, 0x0c, 0x00, 0x00, 0x87, 0x03, 0x00, - 0x17, 0x41, 0x04, 0x1c, 0x8f, 0x9c, 0x6d, 0xe7, - 0xab, 0x3e, 0xf8, 0x0a, 0x5d, 0xe1, 0x86, 0xb4, - 0xe2, 0x8e, 0xb2, 0x1c, 0x3b, 0xd9, 0xb6, 0x08, - 0x80, 0x58, 0x21, 0xe9, 0x0e, 0xc6, 0x66, 0x67, - 0x97, 0xcb, 0xb9, 0x92, 0x07, 0x00, 0xc4, 0xe5, - 0xec, 0x5f, 0xb4, 0xe2, 0x20, 0xa9, 0xc9, 0x62, - 0xd0, 0x98, 0xd5, 0xe3, 0x53, 0xff, 0xd0, 0x0a, - 0x6e, 0x29, 0x69, 0x39, 0x2a, 0x4b, 0x5c, 0xd8, - 0x6c, 0xf5, 0xfe, 0x00, 0x40, 0x35, 0xa7, 0x26, - 0x2e, 0xc2, 0x48, 0x93, 0x32, 0xf7, 0x7d, 0x0f, - 0x0d, 0x77, 0x56, 0x9a, 0x85, 0x0c, 0xa6, 0x74, - 0x06, 0xb8, 0x3d, 0x90, 0x56, 0x12, 0x63, 0xff, - 0x00, 0x5e, 0x0f, 0xf7, 0x24, 0xf7, 0xdb, 0x48, - 0x71, 0xe9, 0x2e, 0x03, 0xd3, 0xfa, 0x3a, 0xae, - 0xa0, 0xc1, 0x77, 0x3c, 0x4c, 0x59, 0xce, 0x33, - 0x1a, 0xd2, 0x47, 0x83, 0xfa, 0xea, 0xd8, 0x1e, - 0x06, 0xe7, 0x7d, 0xa0, 0x9b, 0x16, 0x03, 0x01, - 0x00, 0x04, 0x0e, 0x00, 0x00, 0x00, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x46, 0x10, 0x00, 0x00, - 0x42, 0x41, 0x04, 0x1e, 0x18, 0x37, 0xef, 0x0d, - 0x19, 0x51, 0x88, 0x35, 0x75, 0x71, 0xb5, 0xe5, - 0x54, 0x5b, 0x12, 0x2e, 0x8f, 0x09, 0x67, 0xfd, - 0xa7, 0x24, 0x20, 0x3e, 0xb2, 0x56, 0x1c, 0xce, - 0x97, 0x28, 0x5e, 0xf8, 0x2b, 0x2d, 0x4f, 0x9e, - 0xf1, 0x07, 0x9f, 0x6c, 0x4b, 0x5b, 0x83, 0x56, - 0xe2, 0x32, 0x42, 0xe9, 0x58, 0xb6, 0xd7, 0x49, - 0xa6, 0xb5, 0x68, 0x1a, 0x41, 0x03, 0x56, 0x6b, - 0xdc, 0x5a, 0x89, 0x14, 0x03, 0x01, 0x00, 0x01, - 0x01, 0x16, 0x03, 0x01, 0x00, 0x30, 0xd9, 0xa7, - 0x80, 0x56, 0x3f, 0xa3, 0x8f, 0x96, 0x72, 0x4e, - 0x4e, 0x6e, 0x23, 0x41, 0x8f, 0xda, 0x91, 0xb2, - 0x9e, 0x63, 0x23, 0x82, 0x64, 0xcd, 0x07, 0x24, - 0xd3, 0x40, 0x20, 0x22, 0x4c, 0xe3, 0xff, 0x38, - 0xbb, 0x43, 0x9d, 0x57, 0x11, 0xd5, 0x46, 0xa5, - 0x05, 0x29, 0x92, 0x02, 0xce, 0xdf, - }, - { - 0x14, 0x03, 0x01, 0x00, 0x01, 0x01, 0x16, 0x03, - 0x01, 0x00, 0x90, 0xe7, 0xba, 0x0e, 0xb1, 0xda, - 0x92, 0xb5, 0x77, 0x56, 0x38, 0xa6, 0x22, 0xc1, - 0x72, 0xeb, 0x8a, 0x68, 0x09, 0xb6, 0x74, 0xad, - 0xb3, 0x4a, 0xf2, 0xdd, 0x09, 0x9b, 0xc9, 0x4f, - 0x84, 0x73, 0x8b, 0xd6, 0x97, 0x50, 0x23, 0x1c, - 0xa0, 0xc2, 0x0c, 0x25, 0x18, 0xdd, 0x5e, 0x15, - 0x4d, 0xd9, 0xef, 0x4f, 0x6a, 0x43, 0x61, 0x9c, - 0x95, 0xde, 0x3c, 0x66, 0xc4, 0xc1, 0x33, 0x56, - 0xdd, 0x2f, 0x90, 0xaf, 0x68, 0x5c, 0x9c, 0xa4, - 0x90, 0x6d, 0xbf, 0x51, 0x1d, 0x68, 0xcb, 0x81, - 0x77, 0x52, 0xa0, 0x93, 0x2a, 0xf8, 0xc7, 0x61, - 0x87, 0x76, 0xca, 0x93, 0x9e, 0xd6, 0xee, 0x6f, - 0x3f, 0xeb, 0x7d, 0x06, 0xdd, 0x73, 0x4e, 0x27, - 0x16, 0x63, 0x92, 0xe4, 0xb2, 0x3f, 0x91, 0x23, - 0x21, 0x97, 0x90, 0xce, 0x53, 0xb8, 0xb0, 0x9d, - 0xbd, 0xbd, 0x33, 0x84, 0xad, 0x6b, 0x2e, 0x7b, - 0xf5, 0xeb, 0x1d, 0x64, 0x37, 0x2e, 0x29, 0x4e, - 0xb0, 0x93, 0xdb, 0x92, 0xc7, 0xaa, 0x94, 0xa5, - 0x3b, 0x64, 0xd0, - }, - { - 0x17, 0x03, 0x01, 0x00, 0x20, 0x11, 0xd8, 0x6b, - 0x3c, 0xf6, 0xbe, 0xf4, 0x54, 0x87, 0xec, 0x75, - 0x0c, 0x44, 0xdb, 0x92, 0xfc, 0xde, 0x7e, 0x0f, - 0x9f, 0x87, 0x87, 0x9c, 0x03, 0xd5, 0x07, 0x84, - 0xe0, 0x3a, 0xf8, 0xae, 0x14, 0x17, 0x03, 0x01, - 0x00, 0x20, 0xba, 0x54, 0xef, 0x5b, 0xce, 0xfd, - 0x47, 0x76, 0x6d, 0xa1, 0x8b, 0xfd, 0x48, 0xde, - 0x6e, 0x26, 0xc1, 0x0c, 0x9d, 0x54, 0xbf, 0x98, - 0xf6, 0x1c, 0x80, 0xb9, 0xca, 0x93, 0x81, 0x0a, - 0x2e, 0x06, 0x15, 0x03, 0x01, 0x00, 0x20, 0x93, - 0x3e, 0x38, 0x17, 0xc9, 0x0a, 0xc3, 0xea, 0xd3, - 0x92, 0x75, 0xa6, 0x53, 0x37, 0x4d, 0x74, 0x94, - 0xbe, 0x01, 0xdc, 0x5c, 0x5a, 0x0f, 0x09, 0xf6, - 0x57, 0x33, 0xc3, 0xbc, 0x3f, 0x7a, 0x4d, - }, -} - -var emptyRecordScript = [][]byte{ - { - 0x16, 0x03, 0x01, 0x00, 0x4a, 0x01, 0x00, 0x00, - 0x46, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x35, - 0x01, 0x00, 0x00, 0x1b, 0x00, 0x05, 0x00, 0x05, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, - 0x08, 0x00, 0x06, 0x00, 0x17, 0x00, 0x18, 0x00, - 0x19, 0x00, 0x0b, 0x00, 0x02, 0x01, 0x00, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x4a, 0x02, 0x00, 0x00, - 0x46, 0x03, 0x01, 0x51, 0x71, 0x8e, 0x03, 0x02, - 0xef, 0x09, 0xf2, 0x0e, 0xf5, 0x3b, 0x29, 0x9a, - 0xa8, 0x8b, 0x46, 0xa3, 0xd4, 0xb4, 0xc1, 0x14, - 0xc3, 0x19, 0x99, 0xba, 0x3d, 0x78, 0xcf, 0x50, - 0xd1, 0xe7, 0x26, 0x20, 0xa0, 0x37, 0x6d, 0xc9, - 0xae, 0x93, 0x33, 0x81, 0x20, 0xe3, 0xc1, 0x90, - 0x64, 0x6e, 0x67, 0x93, 0xdb, 0xb4, 0x04, 0x16, - 0xc4, 0x25, 0xdd, 0x10, 0x79, 0x3c, 0x18, 0x0a, - 0x7c, 0xfd, 0x28, 0x65, 0x00, 0x35, 0x00, 0x16, - 0x03, 0x01, 0x09, 0x9e, 0x0b, 0x00, 0x09, 0x9a, - 0x00, 0x09, 0x97, 0x00, 0x04, 0xea, 0x30, 0x82, - 0x04, 0xe6, 0x30, 0x82, 0x03, 0xce, 0xa0, 0x03, - 0x02, 0x01, 0x02, 0x02, 0x11, 0x00, 0xff, 0xab, - 0x02, 0x93, 0xe0, 0x72, 0x99, 0x18, 0x6c, 0x9e, - 0x96, 0xb8, 0xb9, 0xf7, 0x47, 0xcb, 0x30, 0x0d, - 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, - 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x41, 0x31, - 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, - 0x13, 0x02, 0x46, 0x52, 0x31, 0x12, 0x30, 0x10, - 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x09, 0x47, - 0x41, 0x4e, 0x44, 0x49, 0x20, 0x53, 0x41, 0x53, - 0x31, 0x1e, 0x30, 0x1c, 0x06, 0x03, 0x55, 0x04, - 0x03, 0x13, 0x15, 0x47, 0x61, 0x6e, 0x64, 0x69, - 0x20, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, - 0x64, 0x20, 0x53, 0x53, 0x4c, 0x20, 0x43, 0x41, - 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x33, 0x30, 0x31, - 0x31, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, - 0x5a, 0x17, 0x0d, 0x31, 0x34, 0x30, 0x31, 0x31, - 0x34, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a, - 0x30, 0x62, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, - 0x55, 0x04, 0x0b, 0x13, 0x18, 0x44, 0x6f, 0x6d, - 0x61, 0x69, 0x6e, 0x20, 0x43, 0x6f, 0x6e, 0x74, - 0x72, 0x6f, 0x6c, 0x20, 0x56, 0x61, 0x6c, 0x69, - 0x64, 0x61, 0x74, 0x65, 0x64, 0x31, 0x24, 0x30, - 0x22, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x1b, - 0x47, 0x61, 0x6e, 0x64, 0x69, 0x20, 0x53, 0x74, - 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x20, 0x57, - 0x69, 0x6c, 0x64, 0x63, 0x61, 0x72, 0x64, 0x20, - 0x53, 0x53, 0x4c, 0x31, 0x17, 0x30, 0x15, 0x06, - 0x03, 0x55, 0x04, 0x03, 0x14, 0x0e, 0x2a, 0x2e, - 0x66, 0x72, 0x65, 0x65, 0x6e, 0x6f, 0x64, 0x65, - 0x2e, 0x6e, 0x65, 0x74, 0x30, 0x82, 0x01, 0x22, - 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, - 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, - 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, - 0x02, 0x82, 0x01, 0x01, 0x00, 0xdc, 0xe3, 0xfd, - 0xce, 0xc1, 0x66, 0x62, 0x28, 0x8b, 0x99, 0x65, - 0x72, 0x52, 0x88, 0x93, 0x5b, 0x3f, 0x8d, 0xde, - 0x2b, 0xb0, 0xa0, 0xf4, 0xbd, 0xb4, 0x07, 0x5f, - 0x9e, 0x01, 0x47, 0x60, 0x57, 0x5f, 0xdf, 0xdc, - 0x63, 0x28, 0x1c, 0x1e, 0x5b, 0xc8, 0xe6, 0x29, - 0xdd, 0xeb, 0x26, 0x63, 0xd5, 0xbf, 0x83, 0xb2, - 0x2d, 0xcd, 0x2c, 0xa0, 0xb6, 0x91, 0xad, 0xaf, - 0x95, 0x21, 0x1d, 0x1f, 0x39, 0x8d, 0x3e, 0x17, - 0xd6, 0xbd, 0x99, 0xf5, 0x6c, 0xd4, 0xcb, 0x79, - 0x12, 0x3e, 0x11, 0xb9, 0x7e, 0x62, 0xbc, 0x2d, - 0xbf, 0xe0, 0x55, 0x1b, 0x5c, 0x1e, 0xce, 0x31, - 0xd9, 0xf8, 0x56, 0x68, 0x95, 0x2b, 0x15, 0x84, - 0x35, 0xae, 0x98, 0x2c, 0x63, 0x01, 0xb2, 0x0d, - 0xab, 0xa8, 0x61, 0xef, 0x7f, 0x15, 0x2c, 0x6d, - 0xf7, 0x67, 0x1d, 0xb8, 0x8d, 0xf6, 0xa2, 0x1c, - 0x4e, 0x85, 0xf0, 0xea, 0x1a, 0x2b, 0xc8, 0xac, - 0x70, 0x86, 0x9a, 0xbb, 0x9e, 0x9d, 0xbd, 0xc9, - 0x87, 0x2b, 0x9f, 0x5e, 0x40, 0x44, 0x9b, 0xba, - 0x96, 0x45, 0x24, 0xbc, 0x49, 0xb8, 0xfe, 0x26, - 0x3a, 0x1d, 0x1a, 0x0a, 0x3a, 0x90, 0x9c, 0x75, - 0x51, 0x59, 0x89, 0x98, 0x1a, 0x56, 0xe1, 0x3a, - 0x1a, 0xba, 0xff, 0xb4, 0x37, 0x7d, 0xd8, 0x99, - 0xe2, 0xeb, 0x45, 0x27, 0xe2, 0x42, 0x42, 0x46, - 0xbb, 0x00, 0x29, 0x9f, 0x30, 0xc9, 0x1e, 0x6c, - 0xce, 0x59, 0x0e, 0xbe, 0x16, 0x03, 0x31, 0xec, - 0x10, 0xc1, 0x6d, 0xca, 0x9d, 0x5f, 0x6d, 0xf1, - 0x26, 0x11, 0xe5, 0x50, 0xa1, 0xbb, 0x67, 0xb2, - 0xe0, 0x2b, 0xed, 0x76, 0x5b, 0xc7, 0x68, 0xc0, - 0x18, 0xad, 0x91, 0x9e, 0xb5, 0xd4, 0x4d, 0x21, - 0xcd, 0x98, 0xd9, 0xe0, 0x05, 0x0a, 0x4d, 0x24, - 0xa3, 0xe6, 0x12, 0x04, 0xdd, 0x50, 0xe6, 0xc8, - 0x7a, 0x69, 0xb9, 0x32, 0x43, 0x02, 0x03, 0x01, - 0x00, 0x01, 0xa3, 0x82, 0x01, 0xb6, 0x30, 0x82, - 0x01, 0xb2, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, - 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0xb6, - 0xa8, 0xff, 0xa2, 0xa8, 0x2f, 0xd0, 0xa6, 0xcd, - 0x4b, 0xb1, 0x68, 0xf3, 0xe7, 0x50, 0x10, 0x31, - 0xa7, 0x79, 0x21, 0x30, 0x1d, 0x06, 0x03, 0x55, - 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x62, 0x37, - 0xd4, 0x3c, 0xbf, 0xd9, 0xc2, 0x99, 0xf3, 0x28, - 0x3e, 0xdb, 0xca, 0xee, 0xf3, 0xb3, 0xc8, 0x73, - 0xb0, 0x3c, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, - 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, - 0x05, 0xa0, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, - 0x13, 0x01, 0x01, 0xff, 0x04, 0x02, 0x30, 0x00, - 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x25, 0x04, - 0x16, 0x30, 0x14, 0x06, 0x08, 0x2b, 0x06, 0x01, - 0x05, 0x05, 0x07, 0x03, 0x01, 0x06, 0x08, 0x2b, - 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x02, 0x30, - 0x60, 0x06, 0x03, 0x55, 0x1d, 0x20, 0x04, 0x59, - 0x30, 0x57, 0x30, 0x4b, 0x06, 0x0b, 0x2b, 0x06, - 0x01, 0x04, 0x01, 0xb2, 0x31, 0x01, 0x02, 0x02, - 0x1a, 0x30, 0x3c, 0x30, 0x3a, 0x06, 0x08, 0x2b, - 0x06, 0x01, 0x05, 0x05, 0x07, 0x02, 0x01, 0x16, - 0x2e, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, - 0x77, 0x77, 0x77, 0x2e, 0x67, 0x61, 0x6e, 0x64, - 0x69, 0x2e, 0x6e, 0x65, 0x74, 0x2f, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x73, 0x2f, - 0x66, 0x72, 0x2f, 0x73, 0x73, 0x6c, 0x2f, 0x63, - 0x70, 0x73, 0x2f, 0x70, 0x64, 0x66, 0x2f, 0x30, - 0x08, 0x06, 0x06, 0x67, 0x81, 0x0c, 0x01, 0x02, - 0x01, 0x30, 0x3c, 0x06, 0x03, 0x55, 0x1d, 0x1f, - 0x04, 0x35, 0x30, 0x33, 0x30, 0x31, 0xa0, 0x2f, - 0xa0, 0x2d, 0x86, 0x2b, 0x68, 0x74, 0x74, 0x70, - 0x3a, 0x2f, 0x2f, 0x63, 0x72, 0x6c, 0x2e, 0x67, - 0x61, 0x6e, 0x64, 0x69, 0x2e, 0x6e, 0x65, 0x74, - 0x2f, 0x47, 0x61, 0x6e, 0x64, 0x69, 0x53, 0x74, - 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x53, 0x53, - 0x4c, 0x43, 0x41, 0x2e, 0x63, 0x72, 0x6c, 0x30, - 0x6a, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, - 0x07, 0x01, 0x01, 0x04, 0x5e, 0x30, 0x5c, 0x30, - 0x37, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, - 0x07, 0x30, 0x02, 0x86, 0x2b, 0x68, 0x74, 0x74, - 0x70, 0x3a, 0x2f, 0x2f, 0x63, 0x72, 0x74, 0x2e, - 0x67, 0x61, 0x6e, 0x64, 0x69, 0x2e, 0x6e, 0x65, - 0x74, 0x2f, 0x47, 0x61, 0x6e, 0x64, 0x69, 0x53, - 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x53, - 0x53, 0x4c, 0x43, 0x41, 0x2e, 0x63, 0x72, 0x74, - 0x30, 0x21, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, - 0x05, 0x07, 0x30, 0x01, 0x86, 0x15, 0x68, 0x74, - 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6f, 0x63, 0x73, - 0x70, 0x2e, 0x67, 0x61, 0x6e, 0x64, 0x69, 0x2e, - 0x6e, 0x65, 0x74, 0x30, 0x27, 0x06, 0x03, 0x55, - 0x1d, 0x11, 0x04, 0x20, 0x30, 0x1e, 0x82, 0x0e, - 0x2a, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x6e, 0x6f, - 0x64, 0x65, 0x2e, 0x6e, 0x65, 0x74, 0x82, 0x0c, - 0x66, 0x72, 0x65, 0x65, 0x6e, 0x6f, 0x64, 0x65, - 0x2e, 0x6e, 0x65, 0x74, 0x30, 0x0d, 0x06, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x05, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, - 0x5b, 0x4a, 0x3a, 0x1d, 0x75, 0xe0, 0xc0, 0x9e, - 0xc9, 0x16, 0x66, 0x7f, 0x73, 0x95, 0x6e, 0x35, - 0xe4, 0x27, 0xfa, 0x8c, 0x9d, 0xee, 0xb1, 0x37, - 0x42, 0x3f, 0x54, 0x6a, 0x9d, 0x41, 0x84, 0x57, - 0xe1, 0x03, 0x3d, 0x69, 0x61, 0x77, 0x3b, 0x91, - 0xa2, 0x70, 0x94, 0xb6, 0x8e, 0x41, 0x63, 0x70, - 0xf2, 0x16, 0x04, 0x50, 0x05, 0x14, 0xfb, 0x59, - 0x7d, 0x89, 0x09, 0x3f, 0xb6, 0xef, 0xca, 0x3c, - 0x89, 0x88, 0x08, 0xe9, 0xa1, 0xf3, 0x33, 0x31, - 0x05, 0x4d, 0x70, 0xff, 0xdd, 0xa7, 0xd2, 0xe2, - 0xa0, 0x94, 0x3a, 0xf7, 0xc2, 0x9f, 0xad, 0x2b, - 0x2e, 0x20, 0xfa, 0x6c, 0xe1, 0xfc, 0xe6, 0x62, - 0x22, 0xa1, 0x38, 0x93, 0xec, 0x3e, 0xce, 0xfd, - 0x1f, 0xdd, 0xd4, 0x7c, 0x39, 0x46, 0x8b, 0xb4, - 0x64, 0xfa, 0xa1, 0x46, 0x87, 0x78, 0x2c, 0xd7, - 0x9c, 0xdd, 0x60, 0xd6, 0xda, 0x8e, 0xd8, 0x29, - 0x6d, 0x61, 0xa7, 0x29, 0x07, 0x76, 0xfc, 0xf9, - 0xbd, 0xfd, 0x14, 0xeb, 0x44, 0x70, 0xff, 0xd0, - 0x23, 0x99, 0x83, 0xc5, 0x5c, 0x56, 0x88, 0xaa, - 0x34, 0xda, 0xa6, 0xb3, 0x9a, 0xbf, 0xda, 0x58, - 0x1e, 0xa4, 0xb8, 0xc0, 0x40, 0x9d, 0xf0, 0xfc, - 0xf1, 0x23, 0xc2, 0xbc, 0x59, 0xe1, 0x82, 0xed, - 0x5d, 0xfb, 0x99, 0xaf, 0xf5, 0xf5, 0x15, 0xb8, - 0x8b, 0x59, 0xce, 0xaa, 0xca, 0xdf, 0xdc, 0x94, - 0x11, 0xe0, 0x96, 0xbf, 0x9f, 0x54, 0xa4, 0x9f, - 0x54, 0x36, 0x4a, 0xe8, 0x93, 0xda, 0xf4, 0x8c, - 0xb0, 0x6b, 0x8d, 0x4a, 0x9e, 0x11, 0xae, 0xcb, - 0xcb, 0x33, 0x8a, 0x4d, 0xcd, 0x4e, 0xa5, 0x9b, - 0xe9, 0x14, 0x46, 0x43, 0x9b, 0x96, 0x5f, 0x6d, - 0xf2, 0xea, 0x40, 0xef, 0x14, 0xc3, 0x99, 0x9f, - 0x23, 0x1e, 0xa5, 0x13, 0xab, 0x08, 0xea, 0x8f, - 0x68, 0x5b, 0x7d, 0x71, 0xdf, 0x18, 0xd1, 0x57, - 0x00, 0x04, 0xa7, 0x30, 0x82, 0x04, 0xa3, 0x30, - 0x82, 0x03, 0x8b, 0xa0, 0x03, 0x02, 0x01, 0x02, - 0x02, 0x10, 0x5a, 0xb6, 0x1d, 0xac, 0x1e, 0x4d, - 0xa2, 0x06, 0x14, 0xc7, 0x55, 0x3d, 0x3d, 0xa9, - 0xb2, 0xdc, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, - 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, - 0x00, 0x30, 0x81, 0x97, 0x31, 0x0b, 0x30, 0x09, - 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, - 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, - 0x04, 0x08, 0x13, 0x02, 0x55, 0x54, 0x31, 0x17, - 0x30, 0x15, 0x06, 0x03, 0x55, 0x04, 0x07, 0x13, - 0x0e, 0x53, 0x61, 0x6c, 0x74, 0x20, 0x4c, 0x61, - 0x6b, 0x65, 0x20, 0x43, 0x69, 0x74, 0x79, 0x31, - 0x1e, 0x30, 0x1c, 0x06, 0x03, 0x55, 0x04, 0x0a, - 0x13, 0x15, 0x54, 0x68, 0x65, 0x20, 0x55, 0x53, - 0x45, 0x52, 0x54, 0x52, 0x55, 0x53, 0x54, 0x20, - 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x31, - 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0b, - 0x13, 0x18, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, - 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x75, 0x73, 0x65, - 0x72, 0x74, 0x72, 0x75, 0x73, 0x74, 0x2e, 0x63, - 0x6f, 0x6d, 0x31, 0x1f, 0x30, 0x1d, 0x06, 0x03, - 0x55, 0x04, 0x03, 0x13, 0x16, 0x55, 0x54, 0x4e, - 0x2d, 0x55, 0x53, 0x45, 0x52, 0x46, 0x69, 0x72, - 0x73, 0x74, 0x2d, 0x48, 0x61, 0x72, 0x64, 0x77, - 0x61, 0x72, 0x65, 0x30, 0x1e, 0x17, 0x0d, 0x30, - 0x38, 0x31, 0x30, 0x32, 0x33, 0x30, 0x30, 0x30, - 0x30, 0x30, 0x30, 0x5a, 0x17, 0x0d, 0x32, 0x30, - 0x30, 0x35, 0x33, 0x30, 0x31, 0x30, 0x34, 0x38, - 0x33, 0x38, 0x5a, 0x30, 0x41, 0x31, 0x0b, 0x30, - 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, - 0x46, 0x52, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, - 0x55, 0x04, 0x0a, 0x13, 0x09, 0x47, 0x41, 0x4e, - 0x44, 0x49, 0x20, 0x53, 0x41, 0x53, 0x31, 0x1e, - 0x30, 0x1c, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, - 0x15, 0x47, 0x61, 0x6e, 0x64, 0x69, 0x20, 0x53, - 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x20, - 0x53, 0x53, 0x4c, 0x20, 0x43, 0x41, 0x30, 0x82, - 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, - 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, - 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, - 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xb6, - 0x54, 0x3d, 0xa5, 0xdb, 0x0d, 0x22, 0x78, 0x50, - 0x6a, 0x5a, 0x23, 0x89, 0x3f, 0x97, 0xa1, 0xd4, - 0x07, 0x1a, 0xa9, 0x58, 0x08, 0x9b, 0xa0, 0x15, - 0xc3, 0x32, 0xb6, 0xb7, 0xf1, 0xe8, 0xb9, 0xa5, - 0x6f, 0xad, 0x37, 0xf6, 0x6e, 0x71, 0x1b, 0xb4, - 0x75, 0x2d, 0x48, 0x5e, 0x9f, 0xc6, 0x15, 0xaa, - 0x81, 0xef, 0xe5, 0xc4, 0x88, 0x95, 0x8a, 0x3a, - 0x6c, 0x77, 0xcc, 0xb5, 0xcd, 0x65, 0xe4, 0x67, - 0xe5, 0x73, 0xc9, 0x50, 0x52, 0x94, 0xc1, 0x27, - 0x49, 0x3e, 0xa0, 0x6b, 0x41, 0x16, 0x41, 0xb6, - 0x94, 0x99, 0x41, 0xae, 0x3e, 0xcb, 0xe2, 0x06, - 0x46, 0x09, 0xe9, 0x4d, 0xbe, 0xc9, 0x4c, 0x55, - 0xa9, 0x18, 0x7e, 0xa6, 0xdf, 0x6e, 0xfd, 0x4a, - 0xb2, 0xcc, 0x6c, 0x4e, 0xd9, 0xc8, 0x50, 0x15, - 0x93, 0xb3, 0xf2, 0xe9, 0xe3, 0xc2, 0x6a, 0xad, - 0x3a, 0xd5, 0xfb, 0xc3, 0x79, 0x50, 0x9f, 0x25, - 0x79, 0x29, 0xb2, 0x47, 0x64, 0x7c, 0x20, 0x3e, - 0xe2, 0x08, 0x4d, 0x93, 0x29, 0x14, 0xb6, 0x34, - 0x6e, 0xcf, 0x71, 0x46, 0x7e, 0x76, 0x10, 0xf4, - 0xfd, 0x6c, 0xaa, 0x01, 0xd2, 0xc2, 0x06, 0xde, - 0x92, 0x83, 0xcc, 0x58, 0x90, 0x2e, 0x92, 0xde, - 0x1e, 0x65, 0xb7, 0x63, 0x2f, 0x3d, 0xb2, 0xeb, - 0x70, 0x8c, 0x4c, 0xe0, 0xbe, 0x15, 0x9d, 0xde, - 0xc1, 0x4d, 0x56, 0xf8, 0x0b, 0xc6, 0x8e, 0x07, - 0xb9, 0x5d, 0xdf, 0x95, 0xf0, 0x7b, 0x40, 0x1f, - 0x1a, 0x2c, 0xd7, 0x9c, 0x2b, 0x4b, 0x76, 0xf4, - 0x59, 0xf5, 0x43, 0xc1, 0x2c, 0x66, 0x10, 0x9e, - 0x9e, 0x66, 0x96, 0x60, 0x9d, 0x1c, 0x74, 0x1b, - 0x4e, 0x18, 0x5c, 0x08, 0xb0, 0x6e, 0x6c, 0xca, - 0x69, 0x1a, 0x02, 0xe9, 0xbb, 0xca, 0x78, 0xef, - 0x66, 0x2e, 0xe3, 0x32, 0xfd, 0x41, 0x5c, 0x95, - 0x74, 0x81, 0x4d, 0xf4, 0xda, 0xfe, 0x4b, 0x02, - 0x03, 0x01, 0x00, 0x01, 0xa3, 0x82, 0x01, 0x3e, - 0x30, 0x82, 0x01, 0x3a, 0x30, 0x1f, 0x06, 0x03, - 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, - 0x14, 0xa1, 0x72, 0x5f, 0x26, 0x1b, 0x28, 0x98, - 0x43, 0x95, 0x5d, 0x07, 0x37, 0xd5, 0x85, 0x96, - 0x9d, 0x4b, 0xd2, 0xc3, 0x45, 0x30, 0x1d, 0x06, - 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, - 0xb6, 0xa8, 0xff, 0xa2, 0xa8, 0x2f, 0xd0, 0xa6, - 0xcd, 0x4b, 0xb1, 0x68, 0xf3, 0xe7, 0x50, 0x10, - 0x31, 0xa7, 0x79, 0x21, 0x30, 0x0e, 0x06, 0x03, - 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, - 0x03, 0x02, 0x01, 0x06, 0x30, 0x12, 0x06, 0x03, - 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, - 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x00, - 0x30, 0x18, 0x06, 0x03, 0x55, 0x1d, 0x20, 0x04, - 0x11, 0x30, 0x0f, 0x30, 0x0d, 0x06, 0x0b, 0x2b, - 0x06, 0x01, 0x04, 0x01, 0xb2, 0x31, 0x01, 0x02, - 0x02, 0x1a, 0x30, 0x44, 0x06, 0x03, 0x55, 0x1d, - 0x1f, 0x04, 0x3d, 0x30, 0x3b, 0x30, 0x39, 0xa0, - 0x37, 0xa0, 0x35, 0x86, 0x33, 0x68, 0x74, 0x74, - 0x70, 0x3a, 0x2f, 0x2f, 0x63, 0x72, 0x6c, 0x2e, - 0x75, 0x73, 0x65, 0x72, 0x74, 0x72, 0x75, 0x73, - 0x74, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x55, 0x54, - 0x4e, 0x2d, 0x55, 0x53, 0x45, 0x52, 0x46, 0x69, - 0x72, 0x73, 0x74, 0x2d, 0x48, 0x61, 0x72, 0x64, - 0x77, 0x61, 0x72, 0x65, 0x2e, 0x63, 0x72, 0x6c, - 0x30, 0x74, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, - 0x05, 0x07, 0x01, 0x01, 0x04, 0x68, 0x30, 0x66, - 0x30, 0x3d, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, - 0x05, 0x07, 0x30, 0x02, 0x86, 0x31, 0x68, 0x74, - 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x63, 0x72, 0x74, - 0x2e, 0x75, 0x73, 0x65, 0x72, 0x74, 0x72, 0x75, - 0x73, 0x74, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x55, - 0x54, 0x4e, 0x41, 0x64, 0x64, 0x54, 0x72, 0x75, - 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x5f, 0x43, 0x41, 0x2e, 0x63, 0x72, 0x74, 0x30, - 0x25, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, - 0x07, 0x30, 0x01, 0x86, 0x19, 0x68, 0x74, 0x74, - 0x70, 0x3a, 0x2f, 0x2f, 0x6f, 0x63, 0x73, 0x70, - 0x2e, 0x75, 0x73, 0x65, 0x72, 0x74, 0x72, 0x75, - 0x73, 0x74, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x0d, - 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, - 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x82, 0x01, - 0x01, 0x00, 0x19, 0x53, 0xbf, 0x03, 0x3d, 0x9b, - 0xe2, 0x6b, 0x5a, 0xfd, 0xba, 0x49, 0x1f, 0x4f, - 0xec, 0xe1, 0xc6, 0x82, 0x39, 0x3c, 0xd2, 0x03, - 0x04, 0x0f, 0xab, 0x7b, 0x3e, 0x82, 0xa9, 0x85, - 0x10, 0x1f, 0xf4, 0xde, 0x32, 0xaf, 0x58, 0x3f, - 0xff, 0x70, 0xf3, 0x30, 0x1d, 0x97, 0x2d, 0x4c, - 0x9a, 0xe2, 0xec, 0x0c, 0x3e, 0x14, 0x2d, 0x2f, - 0x98, 0x48, 0x9d, 0xae, 0x16, 0x6a, 0xac, 0x2d, - 0x42, 0xaa, 0xb5, 0x64, 0xa4, 0x70, 0xbb, 0xeb, - 0x73, 0x94, 0x7b, 0x46, 0x4c, 0xe7, 0x7a, 0x14, - 0x76, 0x5b, 0x4c, 0x1d, 0x84, 0xa1, 0x20, 0x74, - 0x1f, 0x2e, 0x4b, 0x5c, 0x70, 0x88, 0xdc, 0xbd, - 0xf7, 0x19, 0x3d, 0xed, 0x59, 0x0d, 0xe2, 0x3f, - 0x26, 0xe2, 0x9c, 0xac, 0xa4, 0x3c, 0x95, 0x1c, - 0xf8, 0xbe, 0x8c, 0x03, 0xae, 0xf0, 0xe5, 0x9c, - 0x4d, 0xbc, 0xc7, 0x9b, 0x58, 0x00, 0xbf, 0xaf, - 0xad, 0xfa, 0x37, 0x6e, 0x71, 0x6d, 0x18, 0x34, - 0x0e, 0xc1, 0xea, 0x6a, 0xf8, 0x0d, 0xdf, 0x69, - 0x54, 0x56, 0x15, 0xf2, 0x28, 0xb3, 0xfe, 0xa4, - 0x63, 0xec, 0xc5, 0x04, 0x64, 0x60, 0xbb, 0xfe, - 0x2a, 0xf0, 0xf4, 0x87, 0xa1, 0xb0, 0xae, 0xbd, - 0xaa, 0xe4, 0x2f, 0xe3, 0x03, 0x0b, 0x2f, 0x66, - 0x5f, 0x85, 0xa4, 0x32, 0x7b, 0x46, 0xed, 0x25, - 0x0c, 0xe7, 0xf1, 0xb7, 0xe7, 0x19, 0xfd, 0x60, - 0xba, 0x5f, 0x87, 0x77, 0xde, 0x98, 0x07, 0x96, - 0xe4, 0x5e, 0xea, 0x63, 0x7d, 0xa8, 0xde, 0x55, - 0xda, 0x61, 0x5c, 0x3c, 0x90, 0x83, 0x43, 0x04, - 0x07, 0x3c, 0xdd, 0xf3, 0xf8, 0x9f, 0x06, 0x52, - 0x0a, 0xde, 0xc7, 0xb6, 0x7b, 0x8f, 0xe1, 0x11, - 0xf7, 0x04, 0x7a, 0x35, 0xff, 0x6a, 0xbc, 0x5b, - 0xc7, 0x50, 0x49, 0x08, 0x70, 0x6f, 0x94, 0x43, - 0xcd, 0x9e, 0xc7, 0x70, 0xf1, 0xdb, 0xd0, 0x6d, - 0xda, 0x8f, 0x16, 0x03, 0x01, 0x00, 0x0e, 0x0d, - 0x00, 0x00, 0x06, 0x03, 0x01, 0x02, 0x40, 0x00, - 0x00, 0x0e, 0x00, 0x00, 0x00, - }, - { - 0x16, 0x03, 0x01, 0x02, 0xbe, 0x0b, 0x00, 0x02, - 0xba, 0x00, 0x02, 0xb7, 0x00, 0x02, 0xb4, 0x30, - 0x82, 0x02, 0xb0, 0x30, 0x82, 0x02, 0x19, 0xa0, - 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0x85, - 0xb0, 0xbb, 0xa4, 0x8a, 0x7f, 0xb8, 0xca, 0x30, - 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, - 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x45, - 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, - 0x06, 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, - 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, - 0x53, 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, - 0x74, 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, - 0x55, 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, - 0x64, 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, - 0x79, 0x20, 0x4c, 0x74, 0x64, 0x30, 0x1e, 0x17, - 0x0d, 0x31, 0x30, 0x30, 0x34, 0x32, 0x34, 0x30, - 0x39, 0x30, 0x39, 0x33, 0x38, 0x5a, 0x17, 0x0d, - 0x31, 0x31, 0x30, 0x34, 0x32, 0x34, 0x30, 0x39, - 0x30, 0x39, 0x33, 0x38, 0x5a, 0x30, 0x45, 0x31, - 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, - 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, - 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, - 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, - 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, - 0x20, 0x4c, 0x74, 0x64, 0x30, 0x81, 0x9f, 0x30, - 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, - 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, - 0x8d, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, - 0x00, 0xbb, 0x79, 0xd6, 0xf5, 0x17, 0xb5, 0xe5, - 0xbf, 0x46, 0x10, 0xd0, 0xdc, 0x69, 0xbe, 0xe6, - 0x2b, 0x07, 0x43, 0x5a, 0xd0, 0x03, 0x2d, 0x8a, - 0x7a, 0x43, 0x85, 0xb7, 0x14, 0x52, 0xe7, 0xa5, - 0x65, 0x4c, 0x2c, 0x78, 0xb8, 0x23, 0x8c, 0xb5, - 0xb4, 0x82, 0xe5, 0xde, 0x1f, 0x95, 0x3b, 0x7e, - 0x62, 0xa5, 0x2c, 0xa5, 0x33, 0xd6, 0xfe, 0x12, - 0x5c, 0x7a, 0x56, 0xfc, 0xf5, 0x06, 0xbf, 0xfa, - 0x58, 0x7b, 0x26, 0x3f, 0xb5, 0xcd, 0x04, 0xd3, - 0xd0, 0xc9, 0x21, 0x96, 0x4a, 0xc7, 0xf4, 0x54, - 0x9f, 0x5a, 0xbf, 0xef, 0x42, 0x71, 0x00, 0xfe, - 0x18, 0x99, 0x07, 0x7f, 0x7e, 0x88, 0x7d, 0x7d, - 0xf1, 0x04, 0x39, 0xc4, 0xa2, 0x2e, 0xdb, 0x51, - 0xc9, 0x7c, 0xe3, 0xc0, 0x4c, 0x3b, 0x32, 0x66, - 0x01, 0xcf, 0xaf, 0xb1, 0x1d, 0xb8, 0x71, 0x9a, - 0x1d, 0xdb, 0xdb, 0x89, 0x6b, 0xae, 0xda, 0x2d, - 0x79, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x81, - 0xa7, 0x30, 0x81, 0xa4, 0x30, 0x1d, 0x06, 0x03, - 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xb1, - 0xad, 0xe2, 0x85, 0x5a, 0xcf, 0xcb, 0x28, 0xdb, - 0x69, 0xce, 0x23, 0x69, 0xde, 0xd3, 0x26, 0x8e, - 0x18, 0x88, 0x39, 0x30, 0x75, 0x06, 0x03, 0x55, - 0x1d, 0x23, 0x04, 0x6e, 0x30, 0x6c, 0x80, 0x14, - 0xb1, 0xad, 0xe2, 0x85, 0x5a, 0xcf, 0xcb, 0x28, - 0xdb, 0x69, 0xce, 0x23, 0x69, 0xde, 0xd3, 0x26, - 0x8e, 0x18, 0x88, 0x39, 0xa1, 0x49, 0xa4, 0x47, - 0x30, 0x45, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, - 0x55, 0x04, 0x06, 0x13, 0x02, 0x41, 0x55, 0x31, - 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, - 0x13, 0x0a, 0x53, 0x6f, 0x6d, 0x65, 0x2d, 0x53, - 0x74, 0x61, 0x74, 0x65, 0x31, 0x21, 0x30, 0x1f, - 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x18, 0x49, - 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x20, - 0x57, 0x69, 0x64, 0x67, 0x69, 0x74, 0x73, 0x20, - 0x50, 0x74, 0x79, 0x20, 0x4c, 0x74, 0x64, 0x82, - 0x09, 0x00, 0x85, 0xb0, 0xbb, 0xa4, 0x8a, 0x7f, - 0xb8, 0xca, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, - 0x13, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, - 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, - 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, - 0x81, 0x81, 0x00, 0x08, 0x6c, 0x45, 0x24, 0xc7, - 0x6b, 0xb1, 0x59, 0xab, 0x0c, 0x52, 0xcc, 0xf2, - 0xb0, 0x14, 0xd7, 0x87, 0x9d, 0x7a, 0x64, 0x75, - 0xb5, 0x5a, 0x95, 0x66, 0xe4, 0xc5, 0x2b, 0x8e, - 0xae, 0x12, 0x66, 0x1f, 0xeb, 0x4f, 0x38, 0xb3, - 0x6e, 0x60, 0xd3, 0x92, 0xfd, 0xf7, 0x41, 0x08, - 0xb5, 0x25, 0x13, 0xb1, 0x18, 0x7a, 0x24, 0xfb, - 0x30, 0x1d, 0xba, 0xed, 0x98, 0xb9, 0x17, 0xec, - 0xe7, 0xd7, 0x31, 0x59, 0xdb, 0x95, 0xd3, 0x1d, - 0x78, 0xea, 0x50, 0x56, 0x5c, 0xd5, 0x82, 0x5a, - 0x2d, 0x5a, 0x5f, 0x33, 0xc4, 0xb6, 0xd8, 0xc9, - 0x75, 0x90, 0x96, 0x8c, 0x0f, 0x52, 0x98, 0xb5, - 0xcd, 0x98, 0x1f, 0x89, 0x20, 0x5f, 0xf2, 0xa0, - 0x1c, 0xa3, 0x1b, 0x96, 0x94, 0xdd, 0xa9, 0xfd, - 0x57, 0xe9, 0x70, 0xe8, 0x26, 0x6d, 0x71, 0x99, - 0x9b, 0x26, 0x6e, 0x38, 0x50, 0x29, 0x6c, 0x90, - 0xa7, 0xbd, 0xd9, 0x16, 0x03, 0x01, 0x01, 0x06, - 0x10, 0x00, 0x01, 0x02, 0x01, 0x00, 0x25, 0x48, - 0x6c, 0x0a, 0xde, 0x9d, 0x3a, 0x57, 0xe4, 0x2e, - 0xb9, 0xfc, 0xb4, 0x46, 0x1f, 0x20, 0x4f, 0x58, - 0x4d, 0x12, 0x08, 0xb4, 0x3e, 0x4c, 0xf5, 0xa8, - 0xa5, 0x16, 0x40, 0x29, 0x19, 0x04, 0x4d, 0xf9, - 0x54, 0x3a, 0x32, 0xd7, 0x79, 0xf2, 0x0e, 0xc1, - 0x7b, 0x0c, 0x62, 0x71, 0xbb, 0xb4, 0x8c, 0xe7, - 0x84, 0xd5, 0xf8, 0x11, 0x77, 0x7f, 0x87, 0x6c, - 0xfc, 0x25, 0xf3, 0x2d, 0x97, 0x3d, 0x1f, 0xf5, - 0xfc, 0x64, 0x94, 0x9f, 0xdd, 0x90, 0x82, 0xdd, - 0x11, 0x74, 0x74, 0x59, 0xa2, 0x1a, 0x71, 0xb2, - 0x55, 0x6d, 0x18, 0xca, 0x85, 0x47, 0x8b, 0x79, - 0x73, 0x06, 0x24, 0x38, 0xc3, 0x34, 0x98, 0x84, - 0x62, 0x81, 0xd8, 0xad, 0x54, 0xad, 0x13, 0xa5, - 0xf4, 0xe4, 0x82, 0x85, 0xd3, 0xe3, 0x9e, 0xeb, - 0xb5, 0xf5, 0x95, 0x83, 0x0e, 0xb9, 0x7d, 0xb6, - 0xda, 0x0c, 0xf6, 0x14, 0x6a, 0x60, 0x8c, 0x75, - 0x56, 0xf0, 0xe9, 0x60, 0xe0, 0x4c, 0xf4, 0x4e, - 0x84, 0x8b, 0x4f, 0xf4, 0x2f, 0xde, 0xb7, 0xec, - 0x61, 0xd3, 0x77, 0x07, 0x6e, 0x41, 0x57, 0xc9, - 0xd9, 0x1d, 0x75, 0xee, 0x42, 0x63, 0xdc, 0x58, - 0xad, 0xfc, 0xc7, 0xe1, 0x77, 0x49, 0xb1, 0x58, - 0x21, 0x96, 0x00, 0x55, 0x90, 0x6b, 0xf6, 0x2a, - 0x5a, 0x19, 0x25, 0x93, 0x59, 0x9d, 0xaf, 0x79, - 0x9b, 0x18, 0x5d, 0xf6, 0x5d, 0x64, 0x4b, 0x9a, - 0xf4, 0xde, 0xf2, 0x7f, 0xbd, 0x93, 0x7e, 0x45, - 0x3e, 0x17, 0xae, 0xbf, 0x52, 0xe1, 0xba, 0x8e, - 0x0b, 0xbc, 0x1e, 0x91, 0x9d, 0xf1, 0x4e, 0x0b, - 0xab, 0x9e, 0x5c, 0x4c, 0x6f, 0xf7, 0xf3, 0x8d, - 0x8c, 0x6d, 0xeb, 0x46, 0x05, 0x36, 0x7e, 0x2f, - 0x9c, 0xa1, 0x86, 0x15, 0xe1, 0xe4, 0xb4, 0x20, - 0x06, 0x44, 0x7b, 0x3c, 0x8b, 0x13, 0x96, 0xf5, - 0x02, 0xb1, 0x4f, 0x3c, 0x2d, 0x4a, 0x16, 0x03, - 0x01, 0x00, 0x86, 0x0f, 0x00, 0x00, 0x82, 0x00, - 0x80, 0x52, 0xb1, 0x0d, 0xfc, 0x85, 0x34, 0x56, - 0xb9, 0xdf, 0xa7, 0x8e, 0xf4, 0xfd, 0x02, 0x46, - 0x8a, 0x23, 0xcc, 0x53, 0x3b, 0x0f, 0xa7, 0x61, - 0xf3, 0xb5, 0xbf, 0xfe, 0x59, 0x77, 0x10, 0xd6, - 0x56, 0x93, 0x19, 0x6b, 0x2c, 0xf1, 0x35, 0x71, - 0xe3, 0x36, 0x2f, 0xa0, 0x90, 0x4e, 0x5a, 0xdf, - 0x8d, 0x06, 0x88, 0xcf, 0xb1, 0x06, 0x56, 0x8b, - 0x74, 0x8f, 0x02, 0x8e, 0x10, 0xd2, 0xab, 0x8d, - 0x3f, 0x3e, 0x02, 0xf1, 0x1a, 0x80, 0x6d, 0x0f, - 0x9e, 0x77, 0xd8, 0xfa, 0x92, 0xb3, 0x16, 0x40, - 0xeb, 0x9e, 0xca, 0xd7, 0xe4, 0x31, 0xcc, 0x63, - 0x5f, 0xe2, 0x4c, 0x85, 0x0e, 0xf2, 0xdd, 0xd3, - 0xfe, 0x7e, 0xa7, 0x60, 0x1c, 0xb4, 0x00, 0xd8, - 0xbe, 0x4b, 0x9b, 0x66, 0x78, 0x0f, 0xfb, 0x3b, - 0x52, 0x30, 0x2b, 0x8b, 0xd9, 0xef, 0x82, 0x0a, - 0xa4, 0x18, 0x1d, 0xb0, 0xb5, 0xbf, 0x54, 0x97, - 0x0c, 0x14, 0x03, 0x01, 0x00, 0x01, 0x01, 0x16, - 0x03, 0x01, 0x00, 0x30, 0xa1, 0x74, 0x22, 0xd8, - 0x86, 0x6a, 0xbe, 0x53, 0x34, 0x1d, 0xb3, 0x73, - 0xff, 0x51, 0xc0, 0xce, 0x8e, 0x7d, 0x9b, 0xab, - 0xcb, 0x8b, 0x79, 0xae, 0x04, 0x01, 0xa7, 0xf2, - 0x8e, 0x9d, 0xab, 0xa3, 0x73, 0x80, 0x5c, 0xff, - 0x96, 0x20, 0xbb, 0x8d, 0xc0, 0x02, 0x66, 0x6c, - 0x83, 0x4b, 0x78, 0x20, - }, - { - 0x14, 0x03, 0x01, 0x00, 0x01, 0x01, 0x16, 0x03, - 0x01, 0x00, 0x30, 0x29, 0xd4, 0xfd, 0x03, 0x8b, - 0x30, 0x20, 0xf7, 0xca, 0xc0, 0x6c, 0x83, 0x5d, - 0x73, 0xcb, 0x81, 0x60, 0xe0, 0x9a, 0x09, 0xcb, - 0x33, 0x03, 0x80, 0x81, 0x4e, 0x84, 0x47, 0xd5, - 0x74, 0x6c, 0x3b, 0xb5, 0xc0, 0x48, 0x0d, 0x52, - 0xdd, 0xbe, 0xc2, 0x06, 0xf5, 0x79, 0x2b, 0x3e, - 0x99, 0x56, 0x94, 0x17, 0x03, 0x01, 0x00, 0x20, - 0x26, 0x46, 0x90, 0x9d, 0xef, 0x59, 0x00, 0xb6, - 0x70, 0xe8, 0x1e, 0x1a, 0x80, 0x8b, 0x04, 0xb2, - 0xfc, 0x51, 0xf8, 0x93, 0xbe, 0x00, 0x28, 0xba, - 0xb8, 0xdc, 0x51, 0x7e, 0x92, 0x80, 0xfa, 0xf2, - 0x17, 0x03, 0x01, 0x00, 0xe0, 0xb8, 0x2e, 0xc4, - 0x6b, 0x3f, 0xda, 0x39, 0x87, 0x7f, 0x03, 0x43, - 0x28, 0xdd, 0xb9, 0xf9, 0x9e, 0x16, 0xf5, 0xce, - 0x3f, 0x7e, 0x6a, 0x7b, 0xb3, 0x60, 0x14, 0xe1, - 0xea, 0x54, 0xc5, 0xe6, 0x05, 0x0a, 0x6c, 0xe0, - 0xef, 0x58, 0x29, 0x8a, 0x77, 0x64, 0x77, 0x5d, - 0x9c, 0xe2, 0xe0, 0x3c, 0x6d, 0x87, 0x82, 0xbe, - 0x47, 0x63, 0xd4, 0xfd, 0x0c, 0x25, 0xc4, 0xb1, - 0xfe, 0x29, 0x6f, 0x84, 0xfb, 0xab, 0x6e, 0xa7, - 0xf9, 0x22, 0x89, 0x97, 0x5b, 0x91, 0x0a, 0x07, - 0xe0, 0xef, 0x3d, 0x67, 0xee, 0x87, 0xa8, 0x33, - 0x02, 0x64, 0x33, 0xca, 0x15, 0x10, 0xb9, 0x57, - 0xd8, 0xe5, 0x1a, 0x4b, 0xe3, 0x45, 0xc1, 0x62, - 0x85, 0x50, 0xf1, 0x79, 0x54, 0xe1, 0x2e, 0x25, - 0x01, 0x3c, 0xdb, 0x2d, 0x39, 0x14, 0x2f, 0x9b, - 0xd0, 0x1d, 0xc1, 0xac, 0x73, 0x7d, 0xa4, 0xed, - 0x89, 0x98, 0xb1, 0xae, 0x8a, 0x9e, 0xc8, 0xa7, - 0xfe, 0x55, 0x27, 0xb5, 0xb5, 0xa2, 0xec, 0x7e, - 0xe3, 0x6b, 0x45, 0x19, 0xfa, 0x20, 0x1c, 0x33, - 0x83, 0x22, 0x33, 0x97, 0xd2, 0x5a, 0xc4, 0xf8, - 0x9a, 0x03, 0x13, 0x85, 0xf2, 0x2b, 0x04, 0x59, - 0x27, 0xd7, 0x0b, 0x42, 0x47, 0x9b, 0x7d, 0x4d, - 0xb2, 0x1a, 0x85, 0x7f, 0x97, 0xc2, 0xf2, 0x10, - 0xf0, 0xfa, 0x4e, 0x4b, 0x62, 0x43, 0x3a, 0x09, - 0x2e, 0xcd, 0x8f, 0xa8, 0xb6, 0x0b, 0x5f, 0x34, - 0xd7, 0x3b, 0xba, 0xd9, 0xe5, 0x01, 0x2d, 0x35, - 0xae, 0xc5, 0x4c, 0xab, 0x40, 0x64, 0xc2, 0xc9, - 0x8c, 0x69, 0x44, 0xf4, 0xb8, 0xb5, 0x3a, 0x05, - 0x3c, 0x29, 0x19, 0xb4, 0x09, 0x17, 0x03, 0x01, - 0x00, 0x20, 0xc8, 0xc5, 0xb7, 0xe3, 0xd2, 0x3e, - 0x27, 0xb5, 0x71, 0x8f, 0x52, 0x0b, 0xce, 0x17, - 0x64, 0x86, 0xa4, 0x34, 0x16, 0x1b, 0x61, 0x64, - 0x7c, 0xb3, 0xf2, 0xe5, 0x3e, 0xfd, 0xdd, 0xfb, - 0x40, 0x78, 0x17, 0x03, 0x01, 0x00, 0x50, 0x8e, - 0x79, 0xf0, 0x8e, 0x76, 0x5d, 0x34, 0x09, 0xdc, - 0xec, 0x6d, 0xc3, 0x43, 0x1d, 0xcb, 0x2d, 0xaa, - 0x08, 0x7a, 0x51, 0x94, 0x4e, 0xc5, 0x26, 0xe4, - 0x0b, 0x8e, 0x8f, 0x51, 0xf2, 0x9f, 0xeb, 0xc3, - 0x18, 0x43, 0x95, 0x15, 0xfc, 0x59, 0x18, 0x25, - 0x47, 0xb6, 0x4a, 0x6e, 0xa3, 0xa4, 0x3b, 0xa3, - 0x47, 0x34, 0x74, 0x6b, 0xc5, 0x3d, 0x41, 0x14, - 0x64, 0xd5, 0x69, 0x5f, 0x77, 0xf3, 0x7c, 0x41, - 0xc6, 0xed, 0x2e, 0xcf, 0xff, 0x40, 0xf2, 0xce, - 0xbb, 0xa7, 0x4e, 0x73, 0x88, 0x98, 0x10, - }, - { - 0x15, 0x03, 0x01, 0x00, 0x20, 0x1a, 0xbc, 0x70, - 0x24, 0xf8, 0xfb, 0xf2, 0x4a, 0xf9, 0x44, 0x1e, - 0x58, 0xf8, 0xaa, 0x41, 0x24, 0xe8, 0x80, 0x33, - 0x45, 0x18, 0xa1, 0x5d, 0xee, 0x16, 0x80, 0xae, - 0x40, 0x41, 0x8e, 0x41, 0x9b, - }, -} - -var tls11ECDHEAESClientScript = [][]byte{ - { - 0x16, 0x03, 0x01, 0x00, 0x4a, 0x01, 0x00, 0x00, - 0x46, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xc0, 0x13, - 0x01, 0x00, 0x00, 0x1b, 0x00, 0x05, 0x00, 0x05, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, - 0x08, 0x00, 0x06, 0x00, 0x17, 0x00, 0x18, 0x00, - 0x19, 0x00, 0x0b, 0x00, 0x02, 0x01, 0x00, - }, - { - 0x16, 0x03, 0x02, 0x00, 0x54, 0x02, 0x00, 0x00, - 0x50, 0x03, 0x02, 0x51, 0x9f, 0xa2, 0x21, 0x1a, - 0xb7, 0x75, 0x42, 0x69, 0xd3, 0x14, 0xdd, 0x05, - 0x1e, 0xda, 0x13, 0x71, 0x8d, 0x6a, 0x45, 0x97, - 0xcb, 0xee, 0x0e, 0x77, 0x01, 0x0d, 0x6e, 0xe5, - 0x22, 0x70, 0x16, 0x20, 0x69, 0xfc, 0xa6, 0x9a, - 0xe8, 0x21, 0xcc, 0x46, 0x65, 0x05, 0xb4, 0x48, - 0x0f, 0x34, 0x63, 0x2c, 0xac, 0xa4, 0xf5, 0x4b, - 0x64, 0xd1, 0x07, 0x13, 0xa7, 0xe4, 0x5b, 0xa3, - 0x4d, 0x31, 0x41, 0x53, 0xc0, 0x13, 0x00, 0x00, - 0x08, 0x00, 0x0b, 0x00, 0x04, 0x03, 0x00, 0x01, - 0x02, 0x16, 0x03, 0x02, 0x02, 0x39, 0x0b, 0x00, - 0x02, 0x35, 0x00, 0x02, 0x32, 0x00, 0x02, 0x2f, - 0x30, 0x82, 0x02, 0x2b, 0x30, 0x82, 0x01, 0xd5, - 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, - 0xb1, 0x35, 0x13, 0x65, 0x11, 0x20, 0xc5, 0x92, - 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, - 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, - 0x45, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, - 0x04, 0x06, 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, - 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, - 0x0a, 0x53, 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, - 0x61, 0x74, 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, - 0x03, 0x55, 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, - 0x69, 0x64, 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, - 0x74, 0x79, 0x20, 0x4c, 0x74, 0x64, 0x30, 0x1e, - 0x17, 0x0d, 0x31, 0x32, 0x30, 0x34, 0x30, 0x36, - 0x31, 0x37, 0x31, 0x30, 0x31, 0x33, 0x5a, 0x17, - 0x0d, 0x31, 0x35, 0x30, 0x34, 0x30, 0x36, 0x31, - 0x37, 0x31, 0x30, 0x31, 0x33, 0x5a, 0x30, 0x45, - 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, - 0x06, 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, - 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, - 0x53, 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, - 0x74, 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, - 0x55, 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, - 0x64, 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, - 0x79, 0x20, 0x4c, 0x74, 0x64, 0x30, 0x5c, 0x30, - 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, - 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x4b, - 0x00, 0x30, 0x48, 0x02, 0x41, 0x00, 0x9f, 0xb3, - 0xc3, 0x84, 0x27, 0x95, 0xff, 0x12, 0x31, 0x52, - 0x0f, 0x15, 0xef, 0x46, 0x11, 0xc4, 0xad, 0x80, - 0xe6, 0x36, 0x5b, 0x0f, 0xdd, 0x80, 0xd7, 0x61, - 0x8d, 0xe0, 0xfc, 0x72, 0x45, 0x09, 0x34, 0xfe, - 0x55, 0x66, 0x45, 0x43, 0x4c, 0x68, 0x97, 0x6a, - 0xfe, 0xa8, 0xa0, 0xa5, 0xdf, 0x5f, 0x78, 0xff, - 0xee, 0xd7, 0x64, 0xb8, 0x3f, 0x04, 0xcb, 0x6f, - 0xff, 0x2a, 0xfe, 0xfe, 0xb9, 0xed, 0x02, 0x03, - 0x01, 0x00, 0x01, 0xa3, 0x81, 0xa7, 0x30, 0x81, - 0xa4, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, - 0x04, 0x16, 0x04, 0x14, 0x78, 0xa6, 0x97, 0x9a, - 0x63, 0xb5, 0xc5, 0xa1, 0xa5, 0x33, 0xba, 0x22, - 0x7c, 0x23, 0x6e, 0x5b, 0x1b, 0x7a, 0xcc, 0x2b, - 0x30, 0x75, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, - 0x6e, 0x30, 0x6c, 0x80, 0x14, 0x78, 0xa6, 0x97, - 0x9a, 0x63, 0xb5, 0xc5, 0xa1, 0xa5, 0x33, 0xba, - 0x22, 0x7c, 0x23, 0x6e, 0x5b, 0x1b, 0x7a, 0xcc, - 0x2b, 0xa1, 0x49, 0xa4, 0x47, 0x30, 0x45, 0x31, - 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, - 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, - 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, - 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, - 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, - 0x20, 0x4c, 0x74, 0x64, 0x82, 0x09, 0x00, 0xb1, - 0x35, 0x13, 0x65, 0x11, 0x20, 0xc5, 0x92, 0x30, - 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, - 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, - 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, - 0x01, 0x05, 0x05, 0x00, 0x03, 0x41, 0x00, 0x85, - 0x36, 0x40, 0x73, 0xc1, 0xbb, 0x1a, 0xda, 0xd4, - 0x59, 0x9f, 0x2d, 0xa2, 0x70, 0x31, 0x46, 0x74, - 0xec, 0x83, 0x6e, 0xa8, 0xc8, 0x3c, 0x51, 0xaf, - 0x39, 0xac, 0xec, 0x40, 0xbc, 0xe8, 0x22, 0x46, - 0x1d, 0x99, 0xd6, 0x46, 0x2a, 0x24, 0xd4, 0x8b, - 0x05, 0x08, 0x4b, 0xfb, 0x35, 0x11, 0x6e, 0x92, - 0xbb, 0x77, 0xba, 0xe4, 0x12, 0xbb, 0xf4, 0xc8, - 0x5e, 0x9c, 0x81, 0xa8, 0x97, 0x60, 0x4c, 0x16, - 0x03, 0x02, 0x00, 0x8b, 0x0c, 0x00, 0x00, 0x87, - 0x03, 0x00, 0x17, 0x41, 0x04, 0x34, 0xde, 0x50, - 0x32, 0x8f, 0x25, 0x6b, 0x37, 0x2c, 0x36, 0x24, - 0x27, 0x0e, 0xf9, 0x67, 0xb4, 0xf8, 0x29, 0x1c, - 0xa5, 0xa4, 0x59, 0x9a, 0xca, 0x40, 0x26, 0x15, - 0x61, 0x72, 0x34, 0x4a, 0xd3, 0x0c, 0xac, 0x69, - 0xcb, 0x2a, 0x9e, 0xf8, 0x80, 0xfb, 0x7a, 0xc4, - 0xd4, 0x4b, 0x91, 0x1b, 0xbe, 0x24, 0x26, 0xad, - 0x19, 0x24, 0xbe, 0x32, 0x58, 0xfb, 0xc7, 0x77, - 0xce, 0x7e, 0x71, 0x51, 0x1a, 0x00, 0x40, 0x1a, - 0x0b, 0xe8, 0x91, 0x84, 0x64, 0x54, 0xb6, 0x19, - 0xe8, 0xd4, 0x43, 0x7c, 0x09, 0x0c, 0x2e, 0xba, - 0x42, 0xb9, 0x74, 0xc3, 0x6c, 0x06, 0x9b, 0xa6, - 0x7e, 0x92, 0xe9, 0xee, 0x7c, 0x74, 0xa9, 0xd3, - 0x63, 0xf0, 0x16, 0x20, 0x60, 0x71, 0x8e, 0x24, - 0xc7, 0x7f, 0xc5, 0x5b, 0x9c, 0x19, 0x0c, 0x80, - 0x15, 0x61, 0xbf, 0xb6, 0xed, 0x5b, 0x7b, 0x90, - 0xc5, 0x05, 0x13, 0x72, 0x45, 0x79, 0xdf, 0x16, - 0x03, 0x02, 0x00, 0x04, 0x0e, 0x00, 0x00, 0x00, - }, - { - 0x16, 0x03, 0x02, 0x00, 0x46, 0x10, 0x00, 0x00, - 0x42, 0x41, 0x04, 0x1e, 0x18, 0x37, 0xef, 0x0d, - 0x19, 0x51, 0x88, 0x35, 0x75, 0x71, 0xb5, 0xe5, - 0x54, 0x5b, 0x12, 0x2e, 0x8f, 0x09, 0x67, 0xfd, - 0xa7, 0x24, 0x20, 0x3e, 0xb2, 0x56, 0x1c, 0xce, - 0x97, 0x28, 0x5e, 0xf8, 0x2b, 0x2d, 0x4f, 0x9e, - 0xf1, 0x07, 0x9f, 0x6c, 0x4b, 0x5b, 0x83, 0x56, - 0xe2, 0x32, 0x42, 0xe9, 0x58, 0xb6, 0xd7, 0x49, - 0xa6, 0xb5, 0x68, 0x1a, 0x41, 0x03, 0x56, 0x6b, - 0xdc, 0x5a, 0x89, 0x14, 0x03, 0x02, 0x00, 0x01, - 0x01, 0x16, 0x03, 0x02, 0x00, 0x40, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x50, - 0x32, 0x26, 0x51, 0xbd, 0xbd, 0x3c, 0x4f, 0x72, - 0xbf, 0xbc, 0x91, 0x70, 0x4b, 0x5d, 0x43, 0x4a, - 0x65, 0x26, 0x0d, 0xaa, 0xed, 0x00, 0x91, 0xaf, - 0x4f, 0x47, 0x09, 0xaa, 0x79, 0xc4, 0x47, 0x21, - 0x71, 0xd8, 0x2b, 0xc1, 0x51, 0xc8, 0xef, 0xed, - 0x67, 0xde, 0x97, 0xef, 0x18, 0x53, - }, - { - 0x14, 0x03, 0x02, 0x00, 0x01, 0x01, 0x16, 0x03, - 0x02, 0x00, 0x40, 0x72, 0x20, 0xbf, 0xd1, 0xbd, - 0x83, 0x53, 0x57, 0xb0, 0x4e, 0xac, 0xba, 0x1a, - 0x2b, 0x2d, 0xeb, 0x8a, 0x48, 0x17, 0xfa, 0x69, - 0xf9, 0xb5, 0x94, 0x8e, 0x6f, 0x9c, 0xda, 0x59, - 0xba, 0x6c, 0x7c, 0x82, 0xe2, 0x53, 0xa9, 0x46, - 0xdc, 0x33, 0xa0, 0x9b, 0xf0, 0x1e, 0xf1, 0x53, - 0x83, 0x48, 0xbf, 0x5e, 0xef, 0x03, 0x2b, 0x50, - 0x7a, 0xa6, 0xf8, 0xc3, 0x9e, 0x24, 0x43, 0x3a, - 0xdf, 0x44, 0x3e, - }, - { - 0x17, 0x03, 0x02, 0x00, 0x30, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x0b, 0x8f, - 0x6b, 0xf9, 0xd3, 0x9f, 0x2b, 0x49, 0xe0, 0x62, - 0x9a, 0x0b, 0x3e, 0xa2, 0x72, 0x8b, 0x96, 0x0c, - 0x41, 0x09, 0x95, 0x9e, 0x6b, 0x26, 0xa1, 0x46, - 0xca, 0xb8, 0xb6, 0xd2, 0xd4, 0x15, 0x03, 0x02, - 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xa0, 0xd4, 0x84, 0xc6, 0x7e, 0x1c, - 0x2f, 0xbd, 0x6b, 0x45, 0x31, 0x1d, 0x7d, 0x8f, - 0x31, 0x39, 0x5a, 0x4e, 0xaa, 0xf1, 0x0a, 0x8a, - 0x6c, 0x33, 0x59, 0x19, 0xd8, 0x75, 0x80, 0xab, - 0x93, 0x81, - }, -} - -var clientChainCertificateScript = [][]byte{ - { - 0x16, 0x03, 0x01, 0x00, 0x4a, 0x01, 0x00, 0x00, - 0x46, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x05, - 0x01, 0x00, 0x00, 0x1b, 0x00, 0x05, 0x00, 0x05, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, - 0x08, 0x00, 0x06, 0x00, 0x17, 0x00, 0x18, 0x00, - 0x19, 0x00, 0x0b, 0x00, 0x02, 0x01, 0x00, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x4a, 0x02, 0x00, 0x00, - 0x46, 0x03, 0x01, 0x51, 0xa2, 0x9b, 0x8b, 0xd4, - 0xe6, 0x33, 0xa2, 0x70, 0x38, 0x37, 0xba, 0x55, - 0x86, 0xcf, 0x87, 0xea, 0x6d, 0x2c, 0x3e, 0x17, - 0xc2, 0x09, 0xf8, 0x4d, 0xb0, 0x5d, 0x93, 0x2b, - 0x15, 0x99, 0x0c, 0x20, 0x5d, 0x61, 0x21, 0x2c, - 0xed, 0x49, 0x32, 0x29, 0x08, 0x6e, 0x21, 0x58, - 0x00, 0xdb, 0x34, 0xb7, 0x37, 0xcd, 0x27, 0x75, - 0x31, 0x1e, 0x6c, 0x74, 0xa6, 0xef, 0xa2, 0xc4, - 0x2b, 0x6c, 0xc3, 0x03, 0x00, 0x05, 0x00, 0x16, - 0x03, 0x01, 0x03, 0xef, 0x0b, 0x00, 0x03, 0xeb, - 0x00, 0x03, 0xe8, 0x00, 0x03, 0xe5, 0x30, 0x82, - 0x03, 0xe1, 0x30, 0x82, 0x02, 0xc9, 0xa0, 0x03, - 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0xcc, 0x22, - 0x4c, 0x4b, 0x98, 0xa2, 0x88, 0xfc, 0x30, 0x0d, - 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, - 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x81, 0x86, - 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, - 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x0b, 0x30, - 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x02, - 0x4e, 0x59, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, - 0x55, 0x04, 0x07, 0x0c, 0x08, 0x42, 0x72, 0x6f, - 0x6f, 0x6b, 0x6c, 0x79, 0x6e, 0x31, 0x21, 0x30, - 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x18, - 0x4d, 0x79, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, - 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x20, 0x41, - 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, - 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, - 0x03, 0x0c, 0x08, 0x6d, 0x79, 0x63, 0x61, 0x2e, - 0x6f, 0x72, 0x67, 0x31, 0x21, 0x30, 0x1f, 0x06, - 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, - 0x09, 0x01, 0x16, 0x12, 0x6a, 0x76, 0x73, 0x68, - 0x61, 0x68, 0x69, 0x64, 0x40, 0x67, 0x6d, 0x61, - 0x69, 0x6c, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x1e, - 0x17, 0x0d, 0x31, 0x33, 0x30, 0x35, 0x32, 0x36, - 0x32, 0x31, 0x30, 0x35, 0x30, 0x31, 0x5a, 0x17, - 0x0d, 0x32, 0x33, 0x30, 0x35, 0x32, 0x34, 0x32, - 0x31, 0x30, 0x35, 0x30, 0x31, 0x5a, 0x30, 0x81, - 0x86, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, - 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x0b, - 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, - 0x02, 0x4e, 0x59, 0x31, 0x11, 0x30, 0x0f, 0x06, - 0x03, 0x55, 0x04, 0x07, 0x0c, 0x08, 0x42, 0x72, - 0x6f, 0x6f, 0x6b, 0x6c, 0x79, 0x6e, 0x31, 0x21, - 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, - 0x18, 0x4d, 0x79, 0x20, 0x43, 0x65, 0x72, 0x74, - 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x20, - 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, - 0x79, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, - 0x04, 0x03, 0x0c, 0x08, 0x6d, 0x79, 0x63, 0x61, - 0x2e, 0x6f, 0x72, 0x67, 0x31, 0x21, 0x30, 0x1f, - 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, - 0x01, 0x09, 0x01, 0x16, 0x12, 0x6a, 0x76, 0x73, - 0x68, 0x61, 0x68, 0x69, 0x64, 0x40, 0x67, 0x6d, - 0x61, 0x69, 0x6c, 0x2e, 0x63, 0x6f, 0x6d, 0x30, - 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, - 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, - 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, - 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, - 0xf0, 0xfb, 0xad, 0x80, 0x5e, 0x37, 0xd3, 0x6d, - 0xee, 0x2e, 0xcc, 0xbc, 0x0c, 0xd7, 0x56, 0x4b, - 0x56, 0x45, 0xcd, 0x28, 0xb6, 0x22, 0xe9, 0xe2, - 0x0f, 0xd1, 0x87, 0x2a, 0x27, 0xce, 0x77, 0x8d, - 0x6e, 0x0e, 0x0f, 0xfb, 0x66, 0xe1, 0xb5, 0x0e, - 0x9a, 0xb6, 0x05, 0x8e, 0xb3, 0xe1, 0xc5, 0x77, - 0x86, 0x5b, 0x46, 0xd2, 0x0b, 0x92, 0x03, 0x1b, - 0x89, 0x0c, 0x1b, 0x10, 0x0e, 0x99, 0x8f, 0xe2, - 0x17, 0xe8, 0xc2, 0x30, 0x00, 0x47, 0xd6, 0xfc, - 0xf9, 0x0f, 0x3b, 0x75, 0x34, 0x8d, 0x4d, 0xb0, - 0x99, 0xb7, 0xa0, 0x6d, 0xa0, 0xb6, 0xad, 0xda, - 0x07, 0x5e, 0x38, 0x2e, 0x02, 0xe4, 0x30, 0x6d, - 0xae, 0x13, 0x72, 0xd4, 0xc8, 0xce, 0x14, 0x07, - 0xae, 0x23, 0x8c, 0x8f, 0x9e, 0x8c, 0x60, 0xd6, - 0x06, 0xb9, 0xef, 0x00, 0x18, 0xc0, 0x1d, 0x25, - 0x1e, 0xda, 0x3e, 0x2f, 0xcf, 0x2b, 0x56, 0x84, - 0x9e, 0x30, 0x21, 0xc7, 0x29, 0xf6, 0x03, 0x8a, - 0x24, 0xf9, 0x34, 0xac, 0x65, 0x9d, 0x80, 0x36, - 0xc8, 0x3b, 0x15, 0x10, 0xbd, 0x51, 0xe9, 0xbc, - 0x02, 0xe1, 0xe9, 0xb3, 0x5a, 0x9a, 0x99, 0x41, - 0x1b, 0x27, 0xa0, 0x4d, 0x50, 0x9e, 0x27, 0x7f, - 0xa1, 0x7d, 0x09, 0x87, 0xbd, 0x8a, 0xca, 0x5f, - 0xb1, 0xa5, 0x08, 0xb8, 0x04, 0xd4, 0x52, 0x89, - 0xaa, 0xe0, 0x7d, 0x42, 0x2e, 0x2f, 0x15, 0xee, - 0x66, 0x57, 0x0f, 0x13, 0x19, 0x45, 0xa8, 0x4b, - 0x5d, 0x81, 0x66, 0xcc, 0x12, 0x37, 0x94, 0x5e, - 0xfd, 0x3c, 0x10, 0x81, 0x51, 0x3f, 0xfa, 0x0f, - 0xdd, 0xa1, 0x89, 0x03, 0xa9, 0x78, 0x91, 0xf5, - 0x3b, 0xf3, 0xbc, 0xac, 0xbe, 0x93, 0x30, 0x2e, - 0xbe, 0xca, 0x7f, 0x46, 0xd3, 0x28, 0xb4, 0x4e, - 0x91, 0x7b, 0x5b, 0x43, 0x6c, 0xaf, 0x9b, 0x5c, - 0x6a, 0x6d, 0x5a, 0xdb, 0x79, 0x5e, 0x6a, 0x6b, - 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x50, 0x30, - 0x4e, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, - 0x04, 0x16, 0x04, 0x14, 0x6b, 0x1e, 0x00, 0xa8, - 0x9f, 0xfa, 0x7d, 0x00, 0xf9, 0xe0, 0x9d, 0x0f, - 0x90, 0x8c, 0x90, 0xa8, 0xa1, 0x37, 0x6b, 0xda, - 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, - 0x18, 0x30, 0x16, 0x80, 0x14, 0x6b, 0x1e, 0x00, - 0xa8, 0x9f, 0xfa, 0x7d, 0x00, 0xf9, 0xe0, 0x9d, - 0x0f, 0x90, 0x8c, 0x90, 0xa8, 0xa1, 0x37, 0x6b, - 0xda, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, - 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, - 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, - 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x82, - 0x01, 0x01, 0x00, 0xcd, 0x6f, 0x73, 0x4d, 0x56, - 0x0b, 0xf3, 0x2e, 0x1c, 0xe2, 0x02, 0x0c, 0x14, - 0xbb, 0x2f, 0xdd, 0x3c, 0x43, 0xfe, 0xdf, 0x94, - 0x2d, 0xa9, 0x89, 0x81, 0x51, 0xf8, 0x5f, 0xa7, - 0xa0, 0x13, 0xaa, 0xcc, 0xb0, 0x18, 0xe2, 0x57, - 0x3e, 0x0d, 0x29, 0x93, 0xe8, 0x95, 0xd5, 0x1b, - 0x53, 0xd2, 0x51, 0xf2, 0xbd, 0xf5, 0x9e, 0x7b, - 0x22, 0x65, 0x62, 0x5c, 0xc4, 0x4c, 0x1d, 0xe8, - 0xe9, 0xc3, 0xd4, 0x2b, 0xe7, 0x78, 0xcb, 0x10, - 0xf3, 0xfe, 0x06, 0x83, 0xdc, 0x3a, 0x1e, 0x62, - 0x10, 0xc0, 0x46, 0x77, 0xc6, 0x9d, 0x9f, 0xab, - 0x96, 0x25, 0x5c, 0xfb, 0x26, 0xc1, 0x15, 0x1f, - 0xa5, 0x33, 0xee, 0x4f, 0x9a, 0x14, 0x6a, 0x14, - 0x97, 0x93, 0x2b, 0x95, 0x0b, 0xdc, 0xa8, 0xd7, - 0x69, 0x2e, 0xf0, 0x01, 0x0e, 0xfd, 0x4e, 0xd0, - 0xd9, 0xa8, 0xe5, 0x65, 0xde, 0xfb, 0xca, 0xca, - 0x1c, 0x5f, 0xf9, 0x53, 0xa0, 0x87, 0xe7, 0x33, - 0x9b, 0x2f, 0xcf, 0xe4, 0x13, 0xfc, 0xec, 0x7a, - 0x6c, 0xb0, 0x90, 0x13, 0x9b, 0xb6, 0xc5, 0x03, - 0xf6, 0x0e, 0x5e, 0xe2, 0xe4, 0x26, 0xc1, 0x7e, - 0x53, 0xfe, 0x69, 0xa3, 0xc7, 0xd8, 0x8e, 0x6e, - 0x94, 0x32, 0xa0, 0xde, 0xca, 0xb6, 0xcc, 0xd6, - 0x01, 0xd5, 0x78, 0x40, 0x28, 0x63, 0x9b, 0xee, - 0xcf, 0x09, 0x3b, 0x35, 0x04, 0xf0, 0x14, 0x02, - 0xf6, 0x80, 0x0e, 0x90, 0xb2, 0x94, 0xd2, 0x25, - 0x16, 0xb8, 0x7a, 0x76, 0x87, 0x84, 0x9f, 0x84, - 0xc5, 0xaf, 0xc2, 0x6d, 0x68, 0x7a, 0x84, 0x9c, - 0xc6, 0x8a, 0x63, 0x60, 0x87, 0x6a, 0x25, 0xc1, - 0xa1, 0x78, 0x0f, 0xba, 0xe8, 0x5f, 0xe1, 0xba, - 0xac, 0xa4, 0x6f, 0xdd, 0x09, 0x3f, 0x12, 0xcb, - 0x1d, 0xf3, 0xcf, 0x48, 0xd7, 0xd3, 0x26, 0xe8, - 0x9c, 0xc3, 0x53, 0xb3, 0xba, 0xdc, 0x32, 0x99, - 0x98, 0x96, 0xd6, 0x16, 0x03, 0x01, 0x00, 0x99, - 0x0d, 0x00, 0x00, 0x91, 0x03, 0x01, 0x02, 0x40, - 0x00, 0x8b, 0x00, 0x89, 0x30, 0x81, 0x86, 0x31, - 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, - 0x13, 0x02, 0x55, 0x53, 0x31, 0x0b, 0x30, 0x09, - 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x02, 0x4e, - 0x59, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, - 0x04, 0x07, 0x0c, 0x08, 0x42, 0x72, 0x6f, 0x6f, - 0x6b, 0x6c, 0x79, 0x6e, 0x31, 0x21, 0x30, 0x1f, - 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x18, 0x4d, - 0x79, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, - 0x69, 0x63, 0x61, 0x74, 0x65, 0x20, 0x41, 0x75, - 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x31, - 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x03, - 0x0c, 0x08, 0x6d, 0x79, 0x63, 0x61, 0x2e, 0x6f, - 0x72, 0x67, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, - 0x01, 0x16, 0x12, 0x6a, 0x76, 0x73, 0x68, 0x61, - 0x68, 0x69, 0x64, 0x40, 0x67, 0x6d, 0x61, 0x69, - 0x6c, 0x2e, 0x63, 0x6f, 0x6d, 0x0e, 0x00, 0x00, - 0x00, - }, - { - 0x16, 0x03, 0x01, 0x0a, 0xfb, 0x0b, 0x00, 0x0a, - 0xf7, 0x00, 0x0a, 0xf4, 0x00, 0x03, 0x7e, 0x30, - 0x82, 0x03, 0x7a, 0x30, 0x82, 0x02, 0x62, 0x02, - 0x09, 0x00, 0xb4, 0x47, 0x58, 0x57, 0x2b, 0x67, - 0xc8, 0xc2, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, - 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, - 0x00, 0x30, 0x81, 0x80, 0x31, 0x0b, 0x30, 0x09, - 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, - 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, - 0x04, 0x08, 0x0c, 0x02, 0x4e, 0x59, 0x31, 0x11, - 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, - 0x08, 0x42, 0x72, 0x6f, 0x6f, 0x6b, 0x6c, 0x79, - 0x6e, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x0c, 0x0c, 0x4d, 0x79, 0x20, 0x43, - 0x41, 0x20, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, - 0x31, 0x17, 0x30, 0x15, 0x06, 0x03, 0x55, 0x04, - 0x03, 0x0c, 0x0e, 0x6d, 0x79, 0x63, 0x61, 0x63, - 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x63, 0x6f, - 0x6d, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x09, 0x2a, - 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, - 0x16, 0x12, 0x6a, 0x76, 0x73, 0x68, 0x61, 0x68, - 0x69, 0x64, 0x40, 0x67, 0x6d, 0x61, 0x69, 0x6c, - 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x1e, 0x17, 0x0d, - 0x31, 0x33, 0x30, 0x35, 0x32, 0x36, 0x32, 0x31, - 0x34, 0x34, 0x30, 0x30, 0x5a, 0x17, 0x0d, 0x31, - 0x33, 0x30, 0x36, 0x32, 0x35, 0x32, 0x31, 0x34, - 0x34, 0x30, 0x30, 0x5a, 0x30, 0x7d, 0x31, 0x0b, - 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, - 0x02, 0x55, 0x53, 0x31, 0x11, 0x30, 0x0f, 0x06, - 0x03, 0x55, 0x04, 0x08, 0x0c, 0x08, 0x4e, 0x65, - 0x77, 0x20, 0x59, 0x6f, 0x72, 0x6b, 0x31, 0x11, - 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, - 0x08, 0x42, 0x72, 0x6f, 0x6f, 0x6b, 0x6c, 0x79, - 0x6e, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x0c, 0x07, 0x4d, 0x79, 0x20, 0x4c, - 0x65, 0x61, 0x66, 0x31, 0x13, 0x30, 0x11, 0x06, - 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0a, 0x6d, 0x79, - 0x6c, 0x65, 0x61, 0x66, 0x2e, 0x63, 0x6f, 0x6d, - 0x31, 0x21, 0x30, 0x1f, 0x06, 0x09, 0x2a, 0x86, - 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, - 0x12, 0x6a, 0x76, 0x73, 0x68, 0x61, 0x68, 0x69, - 0x64, 0x40, 0x67, 0x6d, 0x61, 0x69, 0x6c, 0x2e, - 0x63, 0x6f, 0x6d, 0x30, 0x82, 0x01, 0x22, 0x30, - 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, - 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, - 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, - 0x82, 0x01, 0x01, 0x00, 0xa0, 0xa3, 0xef, 0xc1, - 0x44, 0x7d, 0xa2, 0xe3, 0x71, 0x98, 0x27, 0x63, - 0xb3, 0x1d, 0x71, 0x50, 0xa6, 0x34, 0x15, 0xcb, - 0xc9, 0x2a, 0xc3, 0xea, 0xe4, 0x9e, 0x9c, 0x49, - 0xa6, 0x01, 0x9b, 0x7e, 0xa9, 0xb5, 0x7a, 0xff, - 0x15, 0x92, 0x71, 0xc8, 0x97, 0x9c, 0x25, 0xb7, - 0x79, 0x2b, 0xff, 0xab, 0xc6, 0xb1, 0xa7, 0x00, - 0x90, 0xb2, 0x8b, 0xd7, 0x71, 0xd5, 0xc2, 0x3a, - 0xe6, 0x82, 0x42, 0x37, 0x89, 0x41, 0x04, 0xb0, - 0xba, 0xc7, 0x5b, 0x8a, 0x43, 0x9f, 0x97, 0x39, - 0x0c, 0x0f, 0xd5, 0x6d, 0x9e, 0x8d, 0xeb, 0xc0, - 0x26, 0xc5, 0x18, 0xe8, 0x7a, 0x3d, 0x32, 0x2e, - 0x38, 0x90, 0x40, 0x5b, 0x39, 0x2c, 0x07, 0xcb, - 0x24, 0x10, 0xc5, 0xc9, 0x3b, 0xe3, 0x66, 0x47, - 0x57, 0xb9, 0x6a, 0xad, 0x44, 0xf8, 0xd0, 0x70, - 0x62, 0x3b, 0x8e, 0xed, 0x60, 0x5f, 0x22, 0xf8, - 0xb8, 0x0c, 0xc9, 0x41, 0x2b, 0xc9, 0x80, 0x6e, - 0x4e, 0x1b, 0xe1, 0x20, 0xfc, 0x47, 0xa4, 0xac, - 0xc3, 0x3f, 0xe6, 0xc2, 0x81, 0x79, 0x03, 0x37, - 0x25, 0x89, 0xca, 0xd6, 0xa5, 0x46, 0x91, 0x63, - 0x41, 0xc5, 0x3e, 0xd5, 0xed, 0x7f, 0x4f, 0x8d, - 0x06, 0xc0, 0x89, 0x00, 0xbe, 0x37, 0x7b, 0x7e, - 0x73, 0xca, 0x70, 0x00, 0x14, 0x34, 0xbe, 0x47, - 0xbc, 0xb2, 0x6a, 0x28, 0xa5, 0x29, 0x84, 0xa8, - 0x9d, 0xc8, 0x1e, 0x77, 0x66, 0x1f, 0x9f, 0xaa, - 0x2b, 0x47, 0xdb, 0xdd, 0x6b, 0x9c, 0xa8, 0xfc, - 0x82, 0x36, 0x94, 0x62, 0x0d, 0x5c, 0x3f, 0xb2, - 0x01, 0xb4, 0xa5, 0xb8, 0xc6, 0x0e, 0x94, 0x5b, - 0xec, 0x5e, 0xbb, 0x7a, 0x63, 0x24, 0xf1, 0xf9, - 0xd6, 0x50, 0x08, 0xc1, 0xa3, 0xcc, 0x90, 0x07, - 0x5b, 0x04, 0x04, 0x42, 0x74, 0xcf, 0x37, 0xfa, - 0xf0, 0xa5, 0xd9, 0xd3, 0x86, 0x89, 0x89, 0x18, - 0xf3, 0x4c, 0xe2, 0x11, 0x02, 0x03, 0x01, 0x00, - 0x01, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, - 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, - 0x03, 0x82, 0x01, 0x01, 0x00, 0x90, 0xbb, 0xf9, - 0x5e, 0xba, 0x17, 0x1f, 0xac, 0x21, 0x9f, 0x6b, - 0x4a, 0x46, 0xd0, 0x6d, 0x3c, 0x8f, 0x3d, 0xf8, - 0x5e, 0x3e, 0x72, 0xaf, 0xa0, 0x1a, 0xf3, 0xff, - 0x89, 0xac, 0x5b, 0x7a, 0xe2, 0x91, 0x2a, 0x23, - 0x85, 0xc6, 0x4d, 0x47, 0x67, 0x01, 0x08, 0xa8, - 0x05, 0x1d, 0x01, 0x60, 0x50, 0x5f, 0x59, 0xad, - 0xfe, 0x7b, 0xc6, 0x0c, 0x54, 0x90, 0x68, 0x70, - 0x67, 0x2e, 0xed, 0x87, 0xf8, 0x69, 0x8a, 0xac, - 0x32, 0xfe, 0x6f, 0x90, 0x19, 0x2a, 0x64, 0x8d, - 0x82, 0x66, 0x05, 0x43, 0x88, 0xee, 0xf2, 0x30, - 0xed, 0xa4, 0x8f, 0xbf, 0xd6, 0x57, 0x20, 0xd4, - 0x43, 0x1d, 0x52, 0x96, 0x6f, 0xae, 0x09, 0x96, - 0x01, 0x52, 0x38, 0xe3, 0xaf, 0x99, 0xd7, 0xdc, - 0x14, 0x99, 0xc4, 0x8b, 0x0e, 0x04, 0x0f, 0xb3, - 0x14, 0x14, 0xd4, 0xa5, 0x93, 0xe1, 0xc9, 0x8a, - 0x81, 0xef, 0x63, 0xfc, 0x36, 0x77, 0x05, 0x06, - 0xf0, 0x2a, 0x04, 0x0a, 0xbe, 0x2e, 0xce, 0x81, - 0x3d, 0x23, 0xa1, 0xda, 0xd8, 0xeb, 0xc6, 0xea, - 0x5e, 0xcf, 0x28, 0x36, 0x51, 0x31, 0x95, 0x5e, - 0x40, 0x04, 0xed, 0xac, 0xc1, 0xc8, 0x56, 0x69, - 0x87, 0xec, 0x3b, 0x03, 0x3e, 0x9d, 0x0f, 0x4c, - 0x4c, 0xeb, 0xd7, 0xba, 0x26, 0xdf, 0xe3, 0xde, - 0x10, 0xee, 0x93, 0x62, 0x8d, 0x73, 0x52, 0x6e, - 0xff, 0x37, 0x36, 0x98, 0x7b, 0x2d, 0x56, 0x4c, - 0xba, 0x09, 0xb8, 0xa7, 0xf0, 0x3b, 0x16, 0x81, - 0xca, 0xdb, 0x43, 0xab, 0xec, 0x4c, 0x6e, 0x7c, - 0xc1, 0x0b, 0x22, 0x22, 0x43, 0x1d, 0xb6, 0x0c, - 0xc1, 0xb9, 0xcf, 0xe4, 0x53, 0xee, 0x1d, 0x3e, - 0x88, 0xa7, 0x13, 0xbe, 0x7f, 0xbd, 0xae, 0x72, - 0xcf, 0xcd, 0x63, 0xd2, 0xc3, 0x18, 0x58, 0x92, - 0xa2, 0xad, 0xb5, 0x09, 0x9d, 0x91, 0x03, 0xdd, - 0x3c, 0xe2, 0x1c, 0xde, 0x78, 0x00, 0x03, 0x88, - 0x30, 0x82, 0x03, 0x84, 0x30, 0x82, 0x02, 0x6c, - 0x02, 0x09, 0x00, 0xab, 0xed, 0xa6, 0xe4, 0x4a, - 0x2b, 0x2b, 0xf8, 0x30, 0x0d, 0x06, 0x09, 0x2a, - 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, - 0x05, 0x00, 0x30, 0x81, 0x86, 0x31, 0x0b, 0x30, - 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, - 0x55, 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, - 0x55, 0x04, 0x08, 0x0c, 0x02, 0x4e, 0x59, 0x31, - 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x07, - 0x0c, 0x08, 0x42, 0x72, 0x6f, 0x6f, 0x6b, 0x6c, - 0x79, 0x6e, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, - 0x55, 0x04, 0x0a, 0x0c, 0x18, 0x4d, 0x79, 0x20, - 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, - 0x61, 0x74, 0x65, 0x20, 0x41, 0x75, 0x74, 0x68, - 0x6f, 0x72, 0x69, 0x74, 0x79, 0x31, 0x11, 0x30, - 0x0f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x08, - 0x6d, 0x79, 0x63, 0x61, 0x2e, 0x6f, 0x72, 0x67, - 0x31, 0x21, 0x30, 0x1f, 0x06, 0x09, 0x2a, 0x86, - 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, - 0x12, 0x6a, 0x76, 0x73, 0x68, 0x61, 0x68, 0x69, - 0x64, 0x40, 0x67, 0x6d, 0x61, 0x69, 0x6c, 0x2e, - 0x63, 0x6f, 0x6d, 0x30, 0x1e, 0x17, 0x0d, 0x31, - 0x33, 0x30, 0x35, 0x32, 0x36, 0x32, 0x31, 0x31, - 0x38, 0x34, 0x30, 0x5a, 0x17, 0x0d, 0x31, 0x33, - 0x30, 0x36, 0x32, 0x35, 0x32, 0x31, 0x31, 0x38, - 0x34, 0x30, 0x5a, 0x30, 0x81, 0x80, 0x31, 0x0b, - 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, - 0x02, 0x55, 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, - 0x03, 0x55, 0x04, 0x08, 0x0c, 0x02, 0x4e, 0x59, - 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, - 0x07, 0x0c, 0x08, 0x42, 0x72, 0x6f, 0x6f, 0x6b, - 0x6c, 0x79, 0x6e, 0x31, 0x15, 0x30, 0x13, 0x06, - 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0c, 0x4d, 0x79, - 0x20, 0x43, 0x41, 0x20, 0x43, 0x6c, 0x69, 0x65, - 0x6e, 0x74, 0x31, 0x17, 0x30, 0x15, 0x06, 0x03, - 0x55, 0x04, 0x03, 0x0c, 0x0e, 0x6d, 0x79, 0x63, - 0x61, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, - 0x63, 0x6f, 0x6d, 0x31, 0x21, 0x30, 0x1f, 0x06, - 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, - 0x09, 0x01, 0x16, 0x12, 0x6a, 0x76, 0x73, 0x68, - 0x61, 0x68, 0x69, 0x64, 0x40, 0x67, 0x6d, 0x61, - 0x69, 0x6c, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x82, - 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, - 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, - 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, - 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xce, - 0x13, 0xf0, 0x72, 0xb0, 0x61, 0xc8, 0x18, 0x37, - 0x8a, 0x41, 0x3d, 0x20, 0xa1, 0x1c, 0xcb, 0xbf, - 0xf6, 0x3b, 0x74, 0x26, 0x2a, 0x96, 0x11, 0xec, - 0x53, 0xa1, 0xcc, 0x7d, 0x77, 0x56, 0x45, 0x0f, - 0x36, 0xb7, 0xf2, 0x48, 0x92, 0x1a, 0x62, 0xcc, - 0xb6, 0xc0, 0xa1, 0x2f, 0x44, 0x2b, 0xc1, 0x89, - 0xcb, 0x6e, 0x1e, 0xdb, 0x57, 0x92, 0xd5, 0x97, - 0x60, 0x8c, 0x41, 0x2c, 0xd9, 0x20, 0xfe, 0xe9, - 0x1f, 0x8e, 0xfc, 0x7f, 0x02, 0x44, 0x0f, 0x28, - 0x81, 0xd6, 0x0c, 0xcd, 0xbc, 0xf0, 0x57, 0x6c, - 0xcc, 0xa7, 0xba, 0x06, 0xa0, 0xa6, 0x91, 0xda, - 0xef, 0x46, 0x8a, 0x60, 0x0f, 0x52, 0x6c, 0x90, - 0x6c, 0x8c, 0x44, 0xaf, 0xb0, 0x9d, 0x90, 0xba, - 0x21, 0x58, 0xa0, 0x3c, 0xee, 0x54, 0xb5, 0x29, - 0x26, 0x1f, 0x0a, 0xac, 0xef, 0x48, 0x68, 0x33, - 0xd0, 0x33, 0xd0, 0x8b, 0x1a, 0xec, 0x6e, 0x2f, - 0xb5, 0x4a, 0x53, 0xc2, 0x1a, 0xd2, 0xf1, 0x50, - 0x05, 0x59, 0x5c, 0xd9, 0xda, 0x03, 0x0a, 0x47, - 0xb7, 0xdd, 0xf7, 0x3a, 0x69, 0xf5, 0x4e, 0xea, - 0x4a, 0xc2, 0xca, 0x54, 0xb0, 0x8b, 0x76, 0xe1, - 0x02, 0x2d, 0x52, 0x67, 0xb9, 0xdd, 0x50, 0xc9, - 0x3b, 0x07, 0x24, 0x22, 0x6a, 0x00, 0x1d, 0x58, - 0x83, 0xa8, 0xec, 0x95, 0xf1, 0xda, 0xe2, 0x73, - 0xa0, 0xa1, 0x72, 0x60, 0x9e, 0x86, 0x53, 0xcb, - 0x45, 0xa8, 0xc2, 0xa0, 0x50, 0xa0, 0x53, 0xd6, - 0xfc, 0x18, 0x84, 0xb5, 0x4a, 0x26, 0xd0, 0xa2, - 0xaa, 0xd0, 0xff, 0xb6, 0xfe, 0x3a, 0x9c, 0xb5, - 0x19, 0x3b, 0x3f, 0xe1, 0x48, 0x0d, 0xa4, 0x09, - 0x4f, 0x83, 0xc9, 0xc0, 0xc9, 0xa6, 0x0b, 0x58, - 0x1f, 0x1c, 0x7b, 0xac, 0xa2, 0x42, 0xbc, 0x61, - 0xf4, 0x21, 0x8a, 0x00, 0xda, 0x14, 0xa0, 0x60, - 0x03, 0xfe, 0x93, 0x12, 0x6c, 0x56, 0xcd, 0x02, - 0x03, 0x01, 0x00, 0x01, 0x30, 0x0d, 0x06, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x05, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, - 0x25, 0x29, 0x3b, 0x1e, 0xc3, 0x58, 0x32, 0xe6, - 0x23, 0xc8, 0xee, 0x18, 0xf0, 0x1d, 0x62, 0x6d, - 0x3b, 0x59, 0x99, 0x3a, 0xfe, 0x49, 0x72, 0x07, - 0x3f, 0x58, 0x93, 0xdb, 0xc0, 0xaf, 0xb0, 0xb3, - 0x5c, 0xd1, 0x5c, 0x98, 0xc8, 0xea, 0x4a, 0xe4, - 0x58, 0x73, 0x0d, 0x57, 0xc5, 0x13, 0x7c, 0x5c, - 0x79, 0x66, 0xda, 0x04, 0x1d, 0xe5, 0x98, 0xda, - 0x35, 0x47, 0x44, 0xb0, 0xd2, 0x7a, 0x66, 0x9d, - 0xcd, 0x41, 0xa5, 0x8f, 0xa1, 0x11, 0xb2, 0x1a, - 0x87, 0xc0, 0xcd, 0x55, 0xed, 0xb4, 0x7b, 0x33, - 0x72, 0xeb, 0xf7, 0xe3, 0x7b, 0x8b, 0x02, 0x86, - 0xe9, 0x2b, 0x26, 0x32, 0x9f, 0x99, 0xf1, 0xcb, - 0x93, 0xab, 0xb9, 0x16, 0xb3, 0x9a, 0xb2, 0x22, - 0x13, 0x21, 0x1f, 0x5b, 0xcc, 0xa2, 0x59, 0xbb, - 0x69, 0xf2, 0xb8, 0x07, 0x80, 0xce, 0x0c, 0xf7, - 0x98, 0x4c, 0x85, 0xc2, 0x96, 0x6a, 0x22, 0x05, - 0xe9, 0xbe, 0x48, 0xb0, 0x02, 0x5b, 0x69, 0x28, - 0x18, 0x88, 0x96, 0xe3, 0xd7, 0xc6, 0x7a, 0xd3, - 0xe9, 0x99, 0xff, 0x9d, 0xc3, 0x61, 0x4d, 0x9a, - 0x96, 0xf2, 0xc6, 0x33, 0x4d, 0xe5, 0x5d, 0x5a, - 0x68, 0x64, 0x5a, 0x82, 0x35, 0x65, 0x25, 0xe3, - 0x8c, 0x5b, 0xb0, 0xf6, 0x96, 0x56, 0xbc, 0xbf, - 0x97, 0x76, 0x4b, 0x66, 0x44, 0x81, 0xa4, 0xc4, - 0xa7, 0x31, 0xc5, 0xa1, 0x4f, 0xe8, 0xa4, 0xca, - 0x20, 0xf5, 0x01, 0x5b, 0x99, 0x4f, 0x5a, 0xf4, - 0xf0, 0x78, 0xbf, 0x71, 0x49, 0xd5, 0xf1, 0xc1, - 0xa2, 0x18, 0xfd, 0x72, 0x5b, 0x16, 0xe8, 0x92, - 0xc7, 0x37, 0x48, 0xaf, 0xee, 0x24, 0xfc, 0x35, - 0x0b, 0xc2, 0xdd, 0x05, 0xc7, 0x6e, 0xa3, 0x29, - 0xbb, 0x29, 0x7d, 0xd3, 0x2b, 0x94, 0x80, 0xc3, - 0x40, 0x53, 0x0e, 0x03, 0x54, 0x3d, 0x7b, 0x8b, - 0xce, 0xf9, 0xa4, 0x03, 0x27, 0x63, 0xec, 0x51, - 0x00, 0x03, 0xe5, 0x30, 0x82, 0x03, 0xe1, 0x30, - 0x82, 0x02, 0xc9, 0xa0, 0x03, 0x02, 0x01, 0x02, - 0x02, 0x09, 0x00, 0xcc, 0x22, 0x4c, 0x4b, 0x98, - 0xa2, 0x88, 0xfc, 0x30, 0x0d, 0x06, 0x09, 0x2a, - 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, - 0x05, 0x00, 0x30, 0x81, 0x86, 0x31, 0x0b, 0x30, - 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, - 0x55, 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, - 0x55, 0x04, 0x08, 0x0c, 0x02, 0x4e, 0x59, 0x31, - 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x07, - 0x0c, 0x08, 0x42, 0x72, 0x6f, 0x6f, 0x6b, 0x6c, - 0x79, 0x6e, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, - 0x55, 0x04, 0x0a, 0x0c, 0x18, 0x4d, 0x79, 0x20, - 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, - 0x61, 0x74, 0x65, 0x20, 0x41, 0x75, 0x74, 0x68, - 0x6f, 0x72, 0x69, 0x74, 0x79, 0x31, 0x11, 0x30, - 0x0f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x08, - 0x6d, 0x79, 0x63, 0x61, 0x2e, 0x6f, 0x72, 0x67, - 0x31, 0x21, 0x30, 0x1f, 0x06, 0x09, 0x2a, 0x86, - 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, - 0x12, 0x6a, 0x76, 0x73, 0x68, 0x61, 0x68, 0x69, - 0x64, 0x40, 0x67, 0x6d, 0x61, 0x69, 0x6c, 0x2e, - 0x63, 0x6f, 0x6d, 0x30, 0x1e, 0x17, 0x0d, 0x31, - 0x33, 0x30, 0x35, 0x32, 0x36, 0x32, 0x31, 0x30, - 0x35, 0x30, 0x31, 0x5a, 0x17, 0x0d, 0x32, 0x33, - 0x30, 0x35, 0x32, 0x34, 0x32, 0x31, 0x30, 0x35, - 0x30, 0x31, 0x5a, 0x30, 0x81, 0x86, 0x31, 0x0b, - 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, - 0x02, 0x55, 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, - 0x03, 0x55, 0x04, 0x08, 0x0c, 0x02, 0x4e, 0x59, - 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, - 0x07, 0x0c, 0x08, 0x42, 0x72, 0x6f, 0x6f, 0x6b, - 0x6c, 0x79, 0x6e, 0x31, 0x21, 0x30, 0x1f, 0x06, - 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x18, 0x4d, 0x79, - 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, - 0x63, 0x61, 0x74, 0x65, 0x20, 0x41, 0x75, 0x74, - 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x31, 0x11, - 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, - 0x08, 0x6d, 0x79, 0x63, 0x61, 0x2e, 0x6f, 0x72, - 0x67, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x09, 0x2a, - 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, - 0x16, 0x12, 0x6a, 0x76, 0x73, 0x68, 0x61, 0x68, - 0x69, 0x64, 0x40, 0x67, 0x6d, 0x61, 0x69, 0x6c, - 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x82, 0x01, 0x22, - 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, - 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, - 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, - 0x02, 0x82, 0x01, 0x01, 0x00, 0xf0, 0xfb, 0xad, - 0x80, 0x5e, 0x37, 0xd3, 0x6d, 0xee, 0x2e, 0xcc, - 0xbc, 0x0c, 0xd7, 0x56, 0x4b, 0x56, 0x45, 0xcd, - 0x28, 0xb6, 0x22, 0xe9, 0xe2, 0x0f, 0xd1, 0x87, - 0x2a, 0x27, 0xce, 0x77, 0x8d, 0x6e, 0x0e, 0x0f, - 0xfb, 0x66, 0xe1, 0xb5, 0x0e, 0x9a, 0xb6, 0x05, - 0x8e, 0xb3, 0xe1, 0xc5, 0x77, 0x86, 0x5b, 0x46, - 0xd2, 0x0b, 0x92, 0x03, 0x1b, 0x89, 0x0c, 0x1b, - 0x10, 0x0e, 0x99, 0x8f, 0xe2, 0x17, 0xe8, 0xc2, - 0x30, 0x00, 0x47, 0xd6, 0xfc, 0xf9, 0x0f, 0x3b, - 0x75, 0x34, 0x8d, 0x4d, 0xb0, 0x99, 0xb7, 0xa0, - 0x6d, 0xa0, 0xb6, 0xad, 0xda, 0x07, 0x5e, 0x38, - 0x2e, 0x02, 0xe4, 0x30, 0x6d, 0xae, 0x13, 0x72, - 0xd4, 0xc8, 0xce, 0x14, 0x07, 0xae, 0x23, 0x8c, - 0x8f, 0x9e, 0x8c, 0x60, 0xd6, 0x06, 0xb9, 0xef, - 0x00, 0x18, 0xc0, 0x1d, 0x25, 0x1e, 0xda, 0x3e, - 0x2f, 0xcf, 0x2b, 0x56, 0x84, 0x9e, 0x30, 0x21, - 0xc7, 0x29, 0xf6, 0x03, 0x8a, 0x24, 0xf9, 0x34, - 0xac, 0x65, 0x9d, 0x80, 0x36, 0xc8, 0x3b, 0x15, - 0x10, 0xbd, 0x51, 0xe9, 0xbc, 0x02, 0xe1, 0xe9, - 0xb3, 0x5a, 0x9a, 0x99, 0x41, 0x1b, 0x27, 0xa0, - 0x4d, 0x50, 0x9e, 0x27, 0x7f, 0xa1, 0x7d, 0x09, - 0x87, 0xbd, 0x8a, 0xca, 0x5f, 0xb1, 0xa5, 0x08, - 0xb8, 0x04, 0xd4, 0x52, 0x89, 0xaa, 0xe0, 0x7d, - 0x42, 0x2e, 0x2f, 0x15, 0xee, 0x66, 0x57, 0x0f, - 0x13, 0x19, 0x45, 0xa8, 0x4b, 0x5d, 0x81, 0x66, - 0xcc, 0x12, 0x37, 0x94, 0x5e, 0xfd, 0x3c, 0x10, - 0x81, 0x51, 0x3f, 0xfa, 0x0f, 0xdd, 0xa1, 0x89, - 0x03, 0xa9, 0x78, 0x91, 0xf5, 0x3b, 0xf3, 0xbc, - 0xac, 0xbe, 0x93, 0x30, 0x2e, 0xbe, 0xca, 0x7f, - 0x46, 0xd3, 0x28, 0xb4, 0x4e, 0x91, 0x7b, 0x5b, - 0x43, 0x6c, 0xaf, 0x9b, 0x5c, 0x6a, 0x6d, 0x5a, - 0xdb, 0x79, 0x5e, 0x6a, 0x6b, 0x02, 0x03, 0x01, - 0x00, 0x01, 0xa3, 0x50, 0x30, 0x4e, 0x30, 0x1d, - 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, - 0x14, 0x6b, 0x1e, 0x00, 0xa8, 0x9f, 0xfa, 0x7d, - 0x00, 0xf9, 0xe0, 0x9d, 0x0f, 0x90, 0x8c, 0x90, - 0xa8, 0xa1, 0x37, 0x6b, 0xda, 0x30, 0x1f, 0x06, - 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, - 0x80, 0x14, 0x6b, 0x1e, 0x00, 0xa8, 0x9f, 0xfa, - 0x7d, 0x00, 0xf9, 0xe0, 0x9d, 0x0f, 0x90, 0x8c, - 0x90, 0xa8, 0xa1, 0x37, 0x6b, 0xda, 0x30, 0x0c, - 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, 0x30, - 0x03, 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x05, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, - 0xcd, 0x6f, 0x73, 0x4d, 0x56, 0x0b, 0xf3, 0x2e, - 0x1c, 0xe2, 0x02, 0x0c, 0x14, 0xbb, 0x2f, 0xdd, - 0x3c, 0x43, 0xfe, 0xdf, 0x94, 0x2d, 0xa9, 0x89, - 0x81, 0x51, 0xf8, 0x5f, 0xa7, 0xa0, 0x13, 0xaa, - 0xcc, 0xb0, 0x18, 0xe2, 0x57, 0x3e, 0x0d, 0x29, - 0x93, 0xe8, 0x95, 0xd5, 0x1b, 0x53, 0xd2, 0x51, - 0xf2, 0xbd, 0xf5, 0x9e, 0x7b, 0x22, 0x65, 0x62, - 0x5c, 0xc4, 0x4c, 0x1d, 0xe8, 0xe9, 0xc3, 0xd4, - 0x2b, 0xe7, 0x78, 0xcb, 0x10, 0xf3, 0xfe, 0x06, - 0x83, 0xdc, 0x3a, 0x1e, 0x62, 0x10, 0xc0, 0x46, - 0x77, 0xc6, 0x9d, 0x9f, 0xab, 0x96, 0x25, 0x5c, - 0xfb, 0x26, 0xc1, 0x15, 0x1f, 0xa5, 0x33, 0xee, - 0x4f, 0x9a, 0x14, 0x6a, 0x14, 0x97, 0x93, 0x2b, - 0x95, 0x0b, 0xdc, 0xa8, 0xd7, 0x69, 0x2e, 0xf0, - 0x01, 0x0e, 0xfd, 0x4e, 0xd0, 0xd9, 0xa8, 0xe5, - 0x65, 0xde, 0xfb, 0xca, 0xca, 0x1c, 0x5f, 0xf9, - 0x53, 0xa0, 0x87, 0xe7, 0x33, 0x9b, 0x2f, 0xcf, - 0xe4, 0x13, 0xfc, 0xec, 0x7a, 0x6c, 0xb0, 0x90, - 0x13, 0x9b, 0xb6, 0xc5, 0x03, 0xf6, 0x0e, 0x5e, - 0xe2, 0xe4, 0x26, 0xc1, 0x7e, 0x53, 0xfe, 0x69, - 0xa3, 0xc7, 0xd8, 0x8e, 0x6e, 0x94, 0x32, 0xa0, - 0xde, 0xca, 0xb6, 0xcc, 0xd6, 0x01, 0xd5, 0x78, - 0x40, 0x28, 0x63, 0x9b, 0xee, 0xcf, 0x09, 0x3b, - 0x35, 0x04, 0xf0, 0x14, 0x02, 0xf6, 0x80, 0x0e, - 0x90, 0xb2, 0x94, 0xd2, 0x25, 0x16, 0xb8, 0x7a, - 0x76, 0x87, 0x84, 0x9f, 0x84, 0xc5, 0xaf, 0xc2, - 0x6d, 0x68, 0x7a, 0x84, 0x9c, 0xc6, 0x8a, 0x63, - 0x60, 0x87, 0x6a, 0x25, 0xc1, 0xa1, 0x78, 0x0f, - 0xba, 0xe8, 0x5f, 0xe1, 0xba, 0xac, 0xa4, 0x6f, - 0xdd, 0x09, 0x3f, 0x12, 0xcb, 0x1d, 0xf3, 0xcf, - 0x48, 0xd7, 0xd3, 0x26, 0xe8, 0x9c, 0xc3, 0x53, - 0xb3, 0xba, 0xdc, 0x32, 0x99, 0x98, 0x96, 0xd6, - 0x16, 0x03, 0x01, 0x01, 0x06, 0x10, 0x00, 0x01, - 0x02, 0x01, 0x00, 0x6e, 0xea, 0x15, 0x6f, 0x21, - 0xbd, 0x2d, 0x14, 0xde, 0x9d, 0x02, 0xeb, 0xdf, - 0x3b, 0x09, 0x75, 0xaf, 0x32, 0x80, 0x0c, 0xe2, - 0xc2, 0x7b, 0x0d, 0xca, 0x24, 0x96, 0xf6, 0x3e, - 0xa5, 0x97, 0xba, 0x0c, 0x50, 0x7e, 0xb3, 0x68, - 0x58, 0xc6, 0xd8, 0xec, 0xab, 0xa9, 0xd9, 0x3a, - 0xb1, 0x49, 0xea, 0x2f, 0xd7, 0xdb, 0x15, 0x1b, - 0xb5, 0xaf, 0xec, 0xcc, 0x40, 0x5c, 0xe6, 0x0f, - 0xc4, 0x33, 0x71, 0xe7, 0x41, 0xc0, 0x04, 0x89, - 0x60, 0x3e, 0xb7, 0xe6, 0xda, 0x38, 0x62, 0x27, - 0x6a, 0xd9, 0xfb, 0x93, 0x94, 0x9d, 0xc1, 0x63, - 0x92, 0x5c, 0x88, 0x19, 0x38, 0x81, 0x79, 0x9d, - 0x59, 0x48, 0x5e, 0xd3, 0xc8, 0xea, 0xcb, 0x6e, - 0x66, 0x66, 0x03, 0xdc, 0x0c, 0x2d, 0x95, 0xb1, - 0x4d, 0x68, 0xc7, 0xc5, 0x6e, 0xfa, 0x94, 0x14, - 0xdf, 0x2c, 0x70, 0x69, 0x04, 0xf4, 0x69, 0xf1, - 0xf0, 0x07, 0xbd, 0x23, 0x53, 0x63, 0xb3, 0x41, - 0xec, 0xa7, 0x10, 0xa5, 0x04, 0x84, 0x24, 0xb5, - 0xf5, 0x0c, 0x0f, 0x5d, 0x02, 0x47, 0x79, 0x60, - 0x76, 0xbb, 0xdf, 0x60, 0xa6, 0xd7, 0x4d, 0x08, - 0x7d, 0xa6, 0x85, 0x4f, 0x61, 0xac, 0x96, 0x3d, - 0xbc, 0xaf, 0x07, 0xb0, 0x7c, 0xb6, 0x23, 0x3e, - 0x1f, 0x0a, 0x62, 0x77, 0x97, 0x77, 0xae, 0x33, - 0x55, 0x0f, 0x85, 0xdf, 0xdc, 0xbe, 0xc6, 0xe0, - 0xe0, 0x14, 0x83, 0x4c, 0x50, 0xf0, 0xe5, 0x2d, - 0xdc, 0x0b, 0x74, 0x7f, 0xc3, 0x28, 0x98, 0x16, - 0xda, 0x74, 0xe6, 0x40, 0xc2, 0xf0, 0xea, 0xc0, - 0x00, 0xd5, 0xfc, 0x16, 0xe4, 0x43, 0xa1, 0xfc, - 0x31, 0x19, 0x81, 0x62, 0xec, 0x2b, 0xfe, 0xcc, - 0xe8, 0x19, 0xed, 0xa1, 0x1e, 0x6a, 0x49, 0x73, - 0xde, 0xc4, 0xe9, 0x22, 0x0a, 0x21, 0xde, 0x45, - 0x1e, 0x55, 0x12, 0xd9, 0x44, 0xef, 0x4e, 0xaa, - 0x5e, 0x26, 0x57, 0x16, 0x03, 0x01, 0x01, 0x06, - 0x0f, 0x00, 0x01, 0x02, 0x01, 0x00, 0x23, 0xde, - 0xb0, 0x39, 0x60, 0xe9, 0x82, 0xb8, 0xed, 0x17, - 0x78, 0xd2, 0x37, 0x0e, 0x85, 0x69, 0xda, 0xcc, - 0x9f, 0x54, 0x4d, 0xda, 0xce, 0xe8, 0x5a, 0xeb, - 0x3c, 0x61, 0x4c, 0x7a, 0x84, 0x1f, 0x21, 0x03, - 0xb3, 0x8a, 0x74, 0x3b, 0x6a, 0x9e, 0x4f, 0x44, - 0xd9, 0x75, 0x0a, 0xd8, 0x7e, 0x56, 0xa3, 0xef, - 0x5a, 0xfe, 0x8a, 0x35, 0xce, 0x29, 0x18, 0xfe, - 0xa6, 0x61, 0x8e, 0x8f, 0x00, 0x90, 0x2d, 0x85, - 0xe3, 0x6c, 0x0e, 0x8d, 0x8c, 0x27, 0x80, 0x8c, - 0x9f, 0x51, 0xe9, 0xd3, 0xe6, 0x7d, 0x70, 0xe9, - 0xfb, 0xcb, 0xb8, 0x24, 0x94, 0x30, 0x9b, 0xba, - 0x01, 0x14, 0x49, 0x9f, 0xaf, 0x09, 0xd8, 0x26, - 0x1b, 0x23, 0xa4, 0xb8, 0xd9, 0x44, 0x0a, 0xdc, - 0x4e, 0x27, 0xe7, 0x32, 0xf5, 0x9c, 0xf3, 0x8d, - 0xa0, 0xc5, 0xc4, 0xbe, 0x92, 0x02, 0x85, 0x4f, - 0x33, 0x8f, 0xa7, 0xf7, 0x87, 0xa9, 0x44, 0xf3, - 0x64, 0xbd, 0x32, 0x04, 0xeb, 0xc5, 0xc3, 0x62, - 0xe9, 0xda, 0x2f, 0x95, 0x5c, 0xf7, 0x58, 0x3e, - 0xad, 0x35, 0xd7, 0x7e, 0xad, 0xdd, 0x32, 0x8d, - 0xce, 0x81, 0x08, 0xad, 0x49, 0xf7, 0xdb, 0xf7, - 0xaf, 0xe3, 0xc6, 0xb2, 0xdd, 0x76, 0x0c, 0xcf, - 0x0f, 0x87, 0x79, 0x90, 0x10, 0x79, 0xc6, 0xc8, - 0x7b, 0xe6, 0x23, 0xf2, 0xda, 0x33, 0xca, 0xe1, - 0xf0, 0x59, 0x42, 0x43, 0x03, 0x56, 0x19, 0xe3, - 0x8b, 0xe6, 0xa8, 0x70, 0xbc, 0x80, 0xfa, 0x24, - 0xae, 0x03, 0x13, 0x30, 0x0d, 0x1f, 0xab, 0xb7, - 0x82, 0xd9, 0x24, 0x90, 0x80, 0xbf, 0x75, 0xe1, - 0x0d, 0x1c, 0xb2, 0xfe, 0x92, 0x2c, 0x4d, 0x21, - 0xe9, 0x5d, 0xa1, 0x68, 0xf3, 0x16, 0xd8, 0x3f, - 0xb2, 0xc3, 0x00, 0x3e, 0xd8, 0x42, 0x25, 0x5c, - 0x90, 0x11, 0xc0, 0x1b, 0xd4, 0x26, 0x5c, 0x37, - 0x47, 0xbd, 0xf8, 0x1e, 0x34, 0xa9, 0x14, 0x03, - 0x01, 0x00, 0x01, 0x01, 0x16, 0x03, 0x01, 0x00, - 0x24, 0x8f, 0x94, 0x7e, 0x01, 0xee, 0xd5, 0x4f, - 0x83, 0x41, 0x31, 0xc0, 0x36, 0x81, 0x46, 0xc3, - 0xc0, 0xcc, 0x9c, 0xea, 0x0f, 0x29, 0x04, 0x10, - 0x43, 0x1e, 0x08, 0x6e, 0x08, 0xce, 0xb2, 0x62, - 0xa6, 0x0f, 0x68, 0x9f, 0x99, - }, - { - 0x14, 0x03, 0x01, 0x00, 0x01, 0x01, 0x16, 0x03, - 0x01, 0x00, 0x24, 0xd9, 0x46, 0x5b, 0xbf, 0xfd, - 0x8a, 0xa1, 0x08, 0xd5, 0xf3, 0x0c, 0x1c, 0xd8, - 0xa8, 0xb3, 0xe5, 0x89, 0x83, 0x9e, 0x23, 0x47, - 0x81, 0x66, 0x77, 0x11, 0x98, 0xe5, 0xf4, 0xac, - 0x06, 0xe9, 0x4c, 0x05, 0x8b, 0xc4, 0x16, - }, - { - 0x17, 0x03, 0x01, 0x00, 0x1a, 0xc5, 0x28, 0xfd, - 0x71, 0xc0, 0xe6, 0x89, 0xb8, 0x82, 0x92, 0x1b, - 0xdd, 0x39, 0xe5, 0xbf, 0x41, 0x82, 0x1f, 0xc1, - 0xbc, 0x85, 0xe5, 0x32, 0x1b, 0x93, 0x46, 0x15, - 0x03, 0x01, 0x00, 0x16, 0x1a, 0x8b, 0x10, 0x42, - 0x12, 0xb2, 0xbd, 0xd3, 0xf1, 0x74, 0x1f, 0xc2, - 0x10, 0x08, 0xc2, 0x79, 0x99, 0x2c, 0x55, 0xef, - 0x4a, 0xbd, - }, -} - -// $ openssl s_server -tls1_2 -cert server.crt -key server.key \ -// -cipher ECDHE-RSA-AES128-SHA -port 10443 -// $ go test -test.run "TestRunClient" -connect -ciphersuites=0xc013 \ -// -minversion=0x0303 -maxversion=0x0303 -var clientTLS12Script = [][]byte{ - { - 0x16, 0x03, 0x01, 0x00, 0x58, 0x01, 0x00, 0x00, - 0x54, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xc0, 0x13, - 0x01, 0x00, 0x00, 0x29, 0x00, 0x05, 0x00, 0x05, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, - 0x08, 0x00, 0x06, 0x00, 0x17, 0x00, 0x18, 0x00, - 0x19, 0x00, 0x0b, 0x00, 0x02, 0x01, 0x00, 0x00, - 0x0d, 0x00, 0x0a, 0x00, 0x08, 0x04, 0x01, 0x04, - 0x03, 0x02, 0x01, 0x02, 0x03, - }, - { - 0x16, 0x03, 0x03, 0x00, 0x54, 0x02, 0x00, 0x00, - 0x50, 0x03, 0x03, 0x52, 0x65, 0x67, 0xbd, 0xe8, - 0x72, 0x03, 0x6a, 0x52, 0x8d, 0x28, 0x2c, 0x9a, - 0x53, 0xff, 0xc2, 0xa1, 0x62, 0x5f, 0x54, 0xfb, - 0x73, 0x00, 0xcf, 0x4d, 0x28, 0x36, 0xc2, 0xee, - 0xfd, 0x78, 0xf0, 0x20, 0x6f, 0xbe, 0x49, 0xec, - 0x5b, 0x6f, 0xf9, 0x53, 0x42, 0x69, 0x0d, 0x6d, - 0x8b, 0x68, 0x2e, 0xca, 0x3c, 0x3c, 0x88, 0x9e, - 0x8b, 0xf9, 0x32, 0x65, 0x09, 0xd6, 0xa0, 0x7d, - 0xea, 0xc6, 0xd5, 0xc4, 0xc0, 0x13, 0x00, 0x00, - 0x08, 0x00, 0x0b, 0x00, 0x04, 0x03, 0x00, 0x01, - 0x02, 0x16, 0x03, 0x03, 0x02, 0x39, 0x0b, 0x00, - 0x02, 0x35, 0x00, 0x02, 0x32, 0x00, 0x02, 0x2f, - 0x30, 0x82, 0x02, 0x2b, 0x30, 0x82, 0x01, 0xd5, - 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, - 0xb1, 0x35, 0x13, 0x65, 0x11, 0x20, 0xc5, 0x92, - 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, - 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, - 0x45, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, - 0x04, 0x06, 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, - 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, - 0x0a, 0x53, 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, - 0x61, 0x74, 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, - 0x03, 0x55, 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, - 0x69, 0x64, 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, - 0x74, 0x79, 0x20, 0x4c, 0x74, 0x64, 0x30, 0x1e, - 0x17, 0x0d, 0x31, 0x32, 0x30, 0x34, 0x30, 0x36, - 0x31, 0x37, 0x31, 0x30, 0x31, 0x33, 0x5a, 0x17, - 0x0d, 0x31, 0x35, 0x30, 0x34, 0x30, 0x36, 0x31, - 0x37, 0x31, 0x30, 0x31, 0x33, 0x5a, 0x30, 0x45, - 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, - 0x06, 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, - 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, - 0x53, 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, - 0x74, 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, - 0x55, 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, - 0x64, 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, - 0x79, 0x20, 0x4c, 0x74, 0x64, 0x30, 0x5c, 0x30, - 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, - 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x4b, - 0x00, 0x30, 0x48, 0x02, 0x41, 0x00, 0x9f, 0xb3, - 0xc3, 0x84, 0x27, 0x95, 0xff, 0x12, 0x31, 0x52, - 0x0f, 0x15, 0xef, 0x46, 0x11, 0xc4, 0xad, 0x80, - 0xe6, 0x36, 0x5b, 0x0f, 0xdd, 0x80, 0xd7, 0x61, - 0x8d, 0xe0, 0xfc, 0x72, 0x45, 0x09, 0x34, 0xfe, - 0x55, 0x66, 0x45, 0x43, 0x4c, 0x68, 0x97, 0x6a, - 0xfe, 0xa8, 0xa0, 0xa5, 0xdf, 0x5f, 0x78, 0xff, - 0xee, 0xd7, 0x64, 0xb8, 0x3f, 0x04, 0xcb, 0x6f, - 0xff, 0x2a, 0xfe, 0xfe, 0xb9, 0xed, 0x02, 0x03, - 0x01, 0x00, 0x01, 0xa3, 0x81, 0xa7, 0x30, 0x81, - 0xa4, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, - 0x04, 0x16, 0x04, 0x14, 0x78, 0xa6, 0x97, 0x9a, - 0x63, 0xb5, 0xc5, 0xa1, 0xa5, 0x33, 0xba, 0x22, - 0x7c, 0x23, 0x6e, 0x5b, 0x1b, 0x7a, 0xcc, 0x2b, - 0x30, 0x75, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, - 0x6e, 0x30, 0x6c, 0x80, 0x14, 0x78, 0xa6, 0x97, - 0x9a, 0x63, 0xb5, 0xc5, 0xa1, 0xa5, 0x33, 0xba, - 0x22, 0x7c, 0x23, 0x6e, 0x5b, 0x1b, 0x7a, 0xcc, - 0x2b, 0xa1, 0x49, 0xa4, 0x47, 0x30, 0x45, 0x31, - 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, - 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, - 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, - 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, - 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, - 0x20, 0x4c, 0x74, 0x64, 0x82, 0x09, 0x00, 0xb1, - 0x35, 0x13, 0x65, 0x11, 0x20, 0xc5, 0x92, 0x30, - 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, - 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, - 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, - 0x01, 0x05, 0x05, 0x00, 0x03, 0x41, 0x00, 0x85, - 0x36, 0x40, 0x73, 0xc1, 0xbb, 0x1a, 0xda, 0xd4, - 0x59, 0x9f, 0x2d, 0xa2, 0x70, 0x31, 0x46, 0x74, - 0xec, 0x83, 0x6e, 0xa8, 0xc8, 0x3c, 0x51, 0xaf, - 0x39, 0xac, 0xec, 0x40, 0xbc, 0xe8, 0x22, 0x46, - 0x1d, 0x99, 0xd6, 0x46, 0x2a, 0x24, 0xd4, 0x8b, - 0x05, 0x08, 0x4b, 0xfb, 0x35, 0x11, 0x6e, 0x92, - 0xbb, 0x77, 0xba, 0xe4, 0x12, 0xbb, 0xf4, 0xc8, - 0x5e, 0x9c, 0x81, 0xa8, 0x97, 0x60, 0x4c, 0x16, - 0x03, 0x03, 0x00, 0x8d, 0x0c, 0x00, 0x00, 0x89, - 0x03, 0x00, 0x17, 0x41, 0x04, 0x48, 0x93, 0x62, - 0x6a, 0xf8, 0x7c, 0x94, 0xcc, 0xcc, 0x0a, 0x9b, - 0x5e, 0x11, 0xad, 0x0b, 0x30, 0xc4, 0x5d, 0xf7, - 0x63, 0x24, 0xc1, 0xb0, 0x40, 0x5f, 0xff, 0x9f, - 0x0d, 0x7e, 0xd5, 0xa5, 0xd0, 0x4f, 0x80, 0x16, - 0xa8, 0x66, 0x18, 0x31, 0x1f, 0x81, 0xb2, 0x9a, - 0x41, 0x62, 0x5b, 0xcf, 0x73, 0xac, 0x4a, 0x64, - 0xb5, 0xc1, 0x46, 0x4d, 0x8a, 0xac, 0x25, 0xba, - 0x81, 0x7f, 0xbe, 0x64, 0x68, 0x04, 0x01, 0x00, - 0x40, 0x4e, 0x3f, 0x1e, 0x04, 0x4c, 0xef, 0xd2, - 0xa6, 0x82, 0xe6, 0x7c, 0x76, 0x23, 0x17, 0xb9, - 0xe7, 0x52, 0x15, 0x6b, 0x3d, 0xb2, 0xb1, 0x17, - 0x7d, 0xe6, 0xde, 0x06, 0x87, 0x30, 0xb0, 0xb5, - 0x57, 0xae, 0xdf, 0xb2, 0xdc, 0x8d, 0xab, 0x76, - 0x9c, 0xaa, 0x45, 0x6d, 0x23, 0x5d, 0xc1, 0xa8, - 0x7b, 0x79, 0x79, 0xb1, 0x3c, 0xdc, 0xf5, 0x33, - 0x2c, 0xa1, 0x62, 0x3e, 0xbd, 0xf5, 0x5d, 0x6c, - 0x87, 0x16, 0x03, 0x03, 0x00, 0x04, 0x0e, 0x00, - 0x00, 0x00, - }, - { - 0x16, 0x03, 0x03, 0x00, 0x46, 0x10, 0x00, 0x00, - 0x42, 0x41, 0x04, 0x1e, 0x18, 0x37, 0xef, 0x0d, - 0x19, 0x51, 0x88, 0x35, 0x75, 0x71, 0xb5, 0xe5, - 0x54, 0x5b, 0x12, 0x2e, 0x8f, 0x09, 0x67, 0xfd, - 0xa7, 0x24, 0x20, 0x3e, 0xb2, 0x56, 0x1c, 0xce, - 0x97, 0x28, 0x5e, 0xf8, 0x2b, 0x2d, 0x4f, 0x9e, - 0xf1, 0x07, 0x9f, 0x6c, 0x4b, 0x5b, 0x83, 0x56, - 0xe2, 0x32, 0x42, 0xe9, 0x58, 0xb6, 0xd7, 0x49, - 0xa6, 0xb5, 0x68, 0x1a, 0x41, 0x03, 0x56, 0x6b, - 0xdc, 0x5a, 0x89, 0x14, 0x03, 0x03, 0x00, 0x01, - 0x01, 0x16, 0x03, 0x03, 0x00, 0x40, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xee, 0x17, - 0x54, 0x51, 0xb6, 0x1d, 0x8e, 0xe4, 0x6b, 0xed, - 0x5b, 0xa1, 0x27, 0x7f, 0xdc, 0xa9, 0xa5, 0xcf, - 0x38, 0xe6, 0x5d, 0x17, 0x34, 0xf9, 0xc0, 0x07, - 0xb8, 0xbe, 0x56, 0xe6, 0xd6, 0x6a, 0xb6, 0x26, - 0x4e, 0x45, 0x8d, 0x48, 0xe9, 0xc6, 0xb1, 0xa1, - 0xea, 0xdc, 0xb1, 0x37, 0xd9, 0xf6, - }, - { - 0x14, 0x03, 0x03, 0x00, 0x01, 0x01, 0x16, 0x03, - 0x03, 0x00, 0x40, 0x00, 0x68, 0xc5, 0x27, 0xd5, - 0x3d, 0xba, 0x04, 0xde, 0x63, 0xf1, 0x5b, 0xc3, - 0x86, 0xb9, 0x82, 0xc7, 0xb3, 0x90, 0x31, 0xea, - 0x15, 0xe1, 0x42, 0x76, 0x7d, 0x90, 0xcb, 0xc9, - 0xd1, 0x05, 0xe6, 0x8c, 0x76, 0xc7, 0x9a, 0x35, - 0x67, 0xa2, 0x70, 0x9a, 0x8a, 0x6c, 0xb5, 0x6b, - 0xc7, 0x87, 0xf3, 0x65, 0x0a, 0xa0, 0x98, 0xba, - 0x57, 0xbb, 0x31, 0x7b, 0x1f, 0x1a, 0xf7, 0x2a, - 0xf3, 0x12, 0xf6, - }, - { - 0x17, 0x03, 0x03, 0x00, 0x30, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x10, 0x80, - 0x54, 0x1e, 0x72, 0xd3, 0x1a, 0x86, 0x1c, 0xc4, - 0x4a, 0x9b, 0xd4, 0x80, 0xd2, 0x03, 0x35, 0x0d, - 0xe4, 0x12, 0xc2, 0x3d, 0x79, 0x4a, 0x2c, 0xba, - 0xc2, 0xad, 0xf3, 0xd2, 0x16, 0x15, 0x03, 0x03, - 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x04, 0x9b, 0x68, 0x78, 0x92, 0x28, - 0x62, 0x02, 0x65, 0x87, 0x90, 0xe4, 0x32, 0xd7, - 0x72, 0x08, 0x70, 0xb8, 0x52, 0x32, 0x1f, 0x97, - 0xd4, 0x6a, 0xc6, 0x28, 0x83, 0xb0, 0x1d, 0x6e, - 0x16, 0xd5, - }, -} - -// $ openssl s_server -tls1_2 -cert server.crt -key server.key \ -// -port 10443 -verify 0 -// $ go test -test.run "TestRunClient" -connect -ciphersuites=0xc02f \ -// -maxversion=0x0303 -var clientTLS12ClientCertScript = [][]byte{ - { - 0x16, 0x03, 0x01, 0x00, 0x58, 0x01, 0x00, 0x00, - 0x54, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xc0, 0x2f, - 0x01, 0x00, 0x00, 0x29, 0x00, 0x05, 0x00, 0x05, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, - 0x08, 0x00, 0x06, 0x00, 0x17, 0x00, 0x18, 0x00, - 0x19, 0x00, 0x0b, 0x00, 0x02, 0x01, 0x00, 0x00, - 0x0d, 0x00, 0x0a, 0x00, 0x08, 0x04, 0x01, 0x04, - 0x03, 0x02, 0x01, 0x02, 0x03, - }, - { - 0x16, 0x03, 0x03, 0x00, 0x54, 0x02, 0x00, 0x00, - 0x50, 0x03, 0x03, 0x52, 0x65, 0x67, 0xe0, 0xe8, - 0xf1, 0x13, 0x2a, 0x83, 0x28, 0xa8, 0x2e, 0x76, - 0x69, 0xe6, 0x89, 0x55, 0x6c, 0x48, 0x49, 0x2e, - 0x00, 0xf6, 0x87, 0x6c, 0x13, 0xa1, 0xd4, 0xaa, - 0xd0, 0x76, 0x3b, 0x20, 0xe4, 0xd6, 0x5b, 0x1d, - 0x11, 0xf2, 0x42, 0xf2, 0x82, 0x0c, 0x0d, 0x66, - 0x6d, 0xec, 0x52, 0xf8, 0x4a, 0xd9, 0x45, 0xcf, - 0xe4, 0x4a, 0xba, 0x8b, 0xf1, 0xab, 0x55, 0xe4, - 0x57, 0x18, 0xa9, 0x36, 0xc0, 0x2f, 0x00, 0x00, - 0x08, 0x00, 0x0b, 0x00, 0x04, 0x03, 0x00, 0x01, - 0x02, 0x16, 0x03, 0x03, 0x02, 0x39, 0x0b, 0x00, - 0x02, 0x35, 0x00, 0x02, 0x32, 0x00, 0x02, 0x2f, - 0x30, 0x82, 0x02, 0x2b, 0x30, 0x82, 0x01, 0xd5, - 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, - 0xb1, 0x35, 0x13, 0x65, 0x11, 0x20, 0xc5, 0x92, - 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, - 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, - 0x45, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, - 0x04, 0x06, 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, - 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, - 0x0a, 0x53, 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, - 0x61, 0x74, 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, - 0x03, 0x55, 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, - 0x69, 0x64, 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, - 0x74, 0x79, 0x20, 0x4c, 0x74, 0x64, 0x30, 0x1e, - 0x17, 0x0d, 0x31, 0x32, 0x30, 0x34, 0x30, 0x36, - 0x31, 0x37, 0x31, 0x30, 0x31, 0x33, 0x5a, 0x17, - 0x0d, 0x31, 0x35, 0x30, 0x34, 0x30, 0x36, 0x31, - 0x37, 0x31, 0x30, 0x31, 0x33, 0x5a, 0x30, 0x45, - 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, - 0x06, 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, - 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, - 0x53, 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, - 0x74, 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, - 0x55, 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, - 0x64, 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, - 0x79, 0x20, 0x4c, 0x74, 0x64, 0x30, 0x5c, 0x30, - 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, - 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x4b, - 0x00, 0x30, 0x48, 0x02, 0x41, 0x00, 0x9f, 0xb3, - 0xc3, 0x84, 0x27, 0x95, 0xff, 0x12, 0x31, 0x52, - 0x0f, 0x15, 0xef, 0x46, 0x11, 0xc4, 0xad, 0x80, - 0xe6, 0x36, 0x5b, 0x0f, 0xdd, 0x80, 0xd7, 0x61, - 0x8d, 0xe0, 0xfc, 0x72, 0x45, 0x09, 0x34, 0xfe, - 0x55, 0x66, 0x45, 0x43, 0x4c, 0x68, 0x97, 0x6a, - 0xfe, 0xa8, 0xa0, 0xa5, 0xdf, 0x5f, 0x78, 0xff, - 0xee, 0xd7, 0x64, 0xb8, 0x3f, 0x04, 0xcb, 0x6f, - 0xff, 0x2a, 0xfe, 0xfe, 0xb9, 0xed, 0x02, 0x03, - 0x01, 0x00, 0x01, 0xa3, 0x81, 0xa7, 0x30, 0x81, - 0xa4, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, - 0x04, 0x16, 0x04, 0x14, 0x78, 0xa6, 0x97, 0x9a, - 0x63, 0xb5, 0xc5, 0xa1, 0xa5, 0x33, 0xba, 0x22, - 0x7c, 0x23, 0x6e, 0x5b, 0x1b, 0x7a, 0xcc, 0x2b, - 0x30, 0x75, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, - 0x6e, 0x30, 0x6c, 0x80, 0x14, 0x78, 0xa6, 0x97, - 0x9a, 0x63, 0xb5, 0xc5, 0xa1, 0xa5, 0x33, 0xba, - 0x22, 0x7c, 0x23, 0x6e, 0x5b, 0x1b, 0x7a, 0xcc, - 0x2b, 0xa1, 0x49, 0xa4, 0x47, 0x30, 0x45, 0x31, - 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, - 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, - 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, - 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, - 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, - 0x20, 0x4c, 0x74, 0x64, 0x82, 0x09, 0x00, 0xb1, - 0x35, 0x13, 0x65, 0x11, 0x20, 0xc5, 0x92, 0x30, - 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, - 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, - 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, - 0x01, 0x05, 0x05, 0x00, 0x03, 0x41, 0x00, 0x85, - 0x36, 0x40, 0x73, 0xc1, 0xbb, 0x1a, 0xda, 0xd4, - 0x59, 0x9f, 0x2d, 0xa2, 0x70, 0x31, 0x46, 0x74, - 0xec, 0x83, 0x6e, 0xa8, 0xc8, 0x3c, 0x51, 0xaf, - 0x39, 0xac, 0xec, 0x40, 0xbc, 0xe8, 0x22, 0x46, - 0x1d, 0x99, 0xd6, 0x46, 0x2a, 0x24, 0xd4, 0x8b, - 0x05, 0x08, 0x4b, 0xfb, 0x35, 0x11, 0x6e, 0x92, - 0xbb, 0x77, 0xba, 0xe4, 0x12, 0xbb, 0xf4, 0xc8, - 0x5e, 0x9c, 0x81, 0xa8, 0x97, 0x60, 0x4c, 0x16, - 0x03, 0x03, 0x00, 0x8d, 0x0c, 0x00, 0x00, 0x89, - 0x03, 0x00, 0x17, 0x41, 0x04, 0xaa, 0xf0, 0x0c, - 0xa3, 0x60, 0xcf, 0x69, 0x1e, 0xad, 0x16, 0x9a, - 0x01, 0x40, 0xc6, 0x22, 0xc4, 0xbb, 0x06, 0x3b, - 0x84, 0x65, 0xea, 0xc7, 0xa2, 0x96, 0x79, 0x17, - 0x2f, 0xc7, 0xbe, 0x56, 0x39, 0xe4, 0x79, 0xf3, - 0xad, 0x17, 0xf3, 0x7e, 0xe2, 0x7b, 0xa2, 0x6f, - 0x3f, 0x96, 0xea, 0xe5, 0x0e, 0xea, 0x39, 0x79, - 0x77, 0xeb, 0x14, 0x18, 0xbb, 0x7c, 0x95, 0xda, - 0xa7, 0x51, 0x09, 0xba, 0xd7, 0x04, 0x01, 0x00, - 0x40, 0x82, 0x3e, 0xce, 0xee, 0x7e, 0xba, 0x3b, - 0x51, 0xb1, 0xba, 0x71, 0x2e, 0x54, 0xa9, 0xb9, - 0xe2, 0xb1, 0x59, 0x17, 0xa1, 0xac, 0x76, 0xb4, - 0x4e, 0xf1, 0xae, 0x65, 0x17, 0x2b, 0x43, 0x06, - 0x31, 0x29, 0x0b, 0xa0, 0x1e, 0xb6, 0xfa, 0x35, - 0xe8, 0x63, 0x06, 0xde, 0x13, 0x89, 0x83, 0x69, - 0x3b, 0xc2, 0x15, 0x73, 0x1c, 0xc5, 0x07, 0xe9, - 0x38, 0x9b, 0x06, 0x81, 0x1b, 0x97, 0x7c, 0xa6, - 0x89, 0x16, 0x03, 0x03, 0x00, 0x30, 0x0d, 0x00, - 0x00, 0x28, 0x03, 0x01, 0x02, 0x40, 0x00, 0x20, - 0x06, 0x01, 0x06, 0x02, 0x06, 0x03, 0x05, 0x01, - 0x05, 0x02, 0x05, 0x03, 0x04, 0x01, 0x04, 0x02, - 0x04, 0x03, 0x03, 0x01, 0x03, 0x02, 0x03, 0x03, - 0x02, 0x01, 0x02, 0x02, 0x02, 0x03, 0x01, 0x01, - 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, - }, - { - 0x16, 0x03, 0x03, 0x0a, 0xfb, 0x0b, 0x00, 0x0a, - 0xf7, 0x00, 0x0a, 0xf4, 0x00, 0x03, 0x7e, 0x30, - 0x82, 0x03, 0x7a, 0x30, 0x82, 0x02, 0x62, 0x02, - 0x09, 0x00, 0xb4, 0x47, 0x58, 0x57, 0x2b, 0x67, - 0xc8, 0xc2, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, - 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, - 0x00, 0x30, 0x81, 0x80, 0x31, 0x0b, 0x30, 0x09, - 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, - 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, - 0x04, 0x08, 0x0c, 0x02, 0x4e, 0x59, 0x31, 0x11, - 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, - 0x08, 0x42, 0x72, 0x6f, 0x6f, 0x6b, 0x6c, 0x79, - 0x6e, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x0c, 0x0c, 0x4d, 0x79, 0x20, 0x43, - 0x41, 0x20, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, - 0x31, 0x17, 0x30, 0x15, 0x06, 0x03, 0x55, 0x04, - 0x03, 0x0c, 0x0e, 0x6d, 0x79, 0x63, 0x61, 0x63, - 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x63, 0x6f, - 0x6d, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x09, 0x2a, - 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, - 0x16, 0x12, 0x6a, 0x76, 0x73, 0x68, 0x61, 0x68, - 0x69, 0x64, 0x40, 0x67, 0x6d, 0x61, 0x69, 0x6c, - 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x1e, 0x17, 0x0d, - 0x31, 0x33, 0x30, 0x35, 0x32, 0x36, 0x32, 0x31, - 0x34, 0x34, 0x30, 0x30, 0x5a, 0x17, 0x0d, 0x31, - 0x33, 0x30, 0x36, 0x32, 0x35, 0x32, 0x31, 0x34, - 0x34, 0x30, 0x30, 0x5a, 0x30, 0x7d, 0x31, 0x0b, - 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, - 0x02, 0x55, 0x53, 0x31, 0x11, 0x30, 0x0f, 0x06, - 0x03, 0x55, 0x04, 0x08, 0x0c, 0x08, 0x4e, 0x65, - 0x77, 0x20, 0x59, 0x6f, 0x72, 0x6b, 0x31, 0x11, - 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, - 0x08, 0x42, 0x72, 0x6f, 0x6f, 0x6b, 0x6c, 0x79, - 0x6e, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x0c, 0x07, 0x4d, 0x79, 0x20, 0x4c, - 0x65, 0x61, 0x66, 0x31, 0x13, 0x30, 0x11, 0x06, - 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0a, 0x6d, 0x79, - 0x6c, 0x65, 0x61, 0x66, 0x2e, 0x63, 0x6f, 0x6d, - 0x31, 0x21, 0x30, 0x1f, 0x06, 0x09, 0x2a, 0x86, - 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, - 0x12, 0x6a, 0x76, 0x73, 0x68, 0x61, 0x68, 0x69, - 0x64, 0x40, 0x67, 0x6d, 0x61, 0x69, 0x6c, 0x2e, - 0x63, 0x6f, 0x6d, 0x30, 0x82, 0x01, 0x22, 0x30, - 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, - 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, - 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, - 0x82, 0x01, 0x01, 0x00, 0xa0, 0xa3, 0xef, 0xc1, - 0x44, 0x7d, 0xa2, 0xe3, 0x71, 0x98, 0x27, 0x63, - 0xb3, 0x1d, 0x71, 0x50, 0xa6, 0x34, 0x15, 0xcb, - 0xc9, 0x2a, 0xc3, 0xea, 0xe4, 0x9e, 0x9c, 0x49, - 0xa6, 0x01, 0x9b, 0x7e, 0xa9, 0xb5, 0x7a, 0xff, - 0x15, 0x92, 0x71, 0xc8, 0x97, 0x9c, 0x25, 0xb7, - 0x79, 0x2b, 0xff, 0xab, 0xc6, 0xb1, 0xa7, 0x00, - 0x90, 0xb2, 0x8b, 0xd7, 0x71, 0xd5, 0xc2, 0x3a, - 0xe6, 0x82, 0x42, 0x37, 0x89, 0x41, 0x04, 0xb0, - 0xba, 0xc7, 0x5b, 0x8a, 0x43, 0x9f, 0x97, 0x39, - 0x0c, 0x0f, 0xd5, 0x6d, 0x9e, 0x8d, 0xeb, 0xc0, - 0x26, 0xc5, 0x18, 0xe8, 0x7a, 0x3d, 0x32, 0x2e, - 0x38, 0x90, 0x40, 0x5b, 0x39, 0x2c, 0x07, 0xcb, - 0x24, 0x10, 0xc5, 0xc9, 0x3b, 0xe3, 0x66, 0x47, - 0x57, 0xb9, 0x6a, 0xad, 0x44, 0xf8, 0xd0, 0x70, - 0x62, 0x3b, 0x8e, 0xed, 0x60, 0x5f, 0x22, 0xf8, - 0xb8, 0x0c, 0xc9, 0x41, 0x2b, 0xc9, 0x80, 0x6e, - 0x4e, 0x1b, 0xe1, 0x20, 0xfc, 0x47, 0xa4, 0xac, - 0xc3, 0x3f, 0xe6, 0xc2, 0x81, 0x79, 0x03, 0x37, - 0x25, 0x89, 0xca, 0xd6, 0xa5, 0x46, 0x91, 0x63, - 0x41, 0xc5, 0x3e, 0xd5, 0xed, 0x7f, 0x4f, 0x8d, - 0x06, 0xc0, 0x89, 0x00, 0xbe, 0x37, 0x7b, 0x7e, - 0x73, 0xca, 0x70, 0x00, 0x14, 0x34, 0xbe, 0x47, - 0xbc, 0xb2, 0x6a, 0x28, 0xa5, 0x29, 0x84, 0xa8, - 0x9d, 0xc8, 0x1e, 0x77, 0x66, 0x1f, 0x9f, 0xaa, - 0x2b, 0x47, 0xdb, 0xdd, 0x6b, 0x9c, 0xa8, 0xfc, - 0x82, 0x36, 0x94, 0x62, 0x0d, 0x5c, 0x3f, 0xb2, - 0x01, 0xb4, 0xa5, 0xb8, 0xc6, 0x0e, 0x94, 0x5b, - 0xec, 0x5e, 0xbb, 0x7a, 0x63, 0x24, 0xf1, 0xf9, - 0xd6, 0x50, 0x08, 0xc1, 0xa3, 0xcc, 0x90, 0x07, - 0x5b, 0x04, 0x04, 0x42, 0x74, 0xcf, 0x37, 0xfa, - 0xf0, 0xa5, 0xd9, 0xd3, 0x86, 0x89, 0x89, 0x18, - 0xf3, 0x4c, 0xe2, 0x11, 0x02, 0x03, 0x01, 0x00, - 0x01, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, - 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, - 0x03, 0x82, 0x01, 0x01, 0x00, 0x90, 0xbb, 0xf9, - 0x5e, 0xba, 0x17, 0x1f, 0xac, 0x21, 0x9f, 0x6b, - 0x4a, 0x46, 0xd0, 0x6d, 0x3c, 0x8f, 0x3d, 0xf8, - 0x5e, 0x3e, 0x72, 0xaf, 0xa0, 0x1a, 0xf3, 0xff, - 0x89, 0xac, 0x5b, 0x7a, 0xe2, 0x91, 0x2a, 0x23, - 0x85, 0xc6, 0x4d, 0x47, 0x67, 0x01, 0x08, 0xa8, - 0x05, 0x1d, 0x01, 0x60, 0x50, 0x5f, 0x59, 0xad, - 0xfe, 0x7b, 0xc6, 0x0c, 0x54, 0x90, 0x68, 0x70, - 0x67, 0x2e, 0xed, 0x87, 0xf8, 0x69, 0x8a, 0xac, - 0x32, 0xfe, 0x6f, 0x90, 0x19, 0x2a, 0x64, 0x8d, - 0x82, 0x66, 0x05, 0x43, 0x88, 0xee, 0xf2, 0x30, - 0xed, 0xa4, 0x8f, 0xbf, 0xd6, 0x57, 0x20, 0xd4, - 0x43, 0x1d, 0x52, 0x96, 0x6f, 0xae, 0x09, 0x96, - 0x01, 0x52, 0x38, 0xe3, 0xaf, 0x99, 0xd7, 0xdc, - 0x14, 0x99, 0xc4, 0x8b, 0x0e, 0x04, 0x0f, 0xb3, - 0x14, 0x14, 0xd4, 0xa5, 0x93, 0xe1, 0xc9, 0x8a, - 0x81, 0xef, 0x63, 0xfc, 0x36, 0x77, 0x05, 0x06, - 0xf0, 0x2a, 0x04, 0x0a, 0xbe, 0x2e, 0xce, 0x81, - 0x3d, 0x23, 0xa1, 0xda, 0xd8, 0xeb, 0xc6, 0xea, - 0x5e, 0xcf, 0x28, 0x36, 0x51, 0x31, 0x95, 0x5e, - 0x40, 0x04, 0xed, 0xac, 0xc1, 0xc8, 0x56, 0x69, - 0x87, 0xec, 0x3b, 0x03, 0x3e, 0x9d, 0x0f, 0x4c, - 0x4c, 0xeb, 0xd7, 0xba, 0x26, 0xdf, 0xe3, 0xde, - 0x10, 0xee, 0x93, 0x62, 0x8d, 0x73, 0x52, 0x6e, - 0xff, 0x37, 0x36, 0x98, 0x7b, 0x2d, 0x56, 0x4c, - 0xba, 0x09, 0xb8, 0xa7, 0xf0, 0x3b, 0x16, 0x81, - 0xca, 0xdb, 0x43, 0xab, 0xec, 0x4c, 0x6e, 0x7c, - 0xc1, 0x0b, 0x22, 0x22, 0x43, 0x1d, 0xb6, 0x0c, - 0xc1, 0xb9, 0xcf, 0xe4, 0x53, 0xee, 0x1d, 0x3e, - 0x88, 0xa7, 0x13, 0xbe, 0x7f, 0xbd, 0xae, 0x72, - 0xcf, 0xcd, 0x63, 0xd2, 0xc3, 0x18, 0x58, 0x92, - 0xa2, 0xad, 0xb5, 0x09, 0x9d, 0x91, 0x03, 0xdd, - 0x3c, 0xe2, 0x1c, 0xde, 0x78, 0x00, 0x03, 0x88, - 0x30, 0x82, 0x03, 0x84, 0x30, 0x82, 0x02, 0x6c, - 0x02, 0x09, 0x00, 0xab, 0xed, 0xa6, 0xe4, 0x4a, - 0x2b, 0x2b, 0xf8, 0x30, 0x0d, 0x06, 0x09, 0x2a, - 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, - 0x05, 0x00, 0x30, 0x81, 0x86, 0x31, 0x0b, 0x30, - 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, - 0x55, 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, - 0x55, 0x04, 0x08, 0x0c, 0x02, 0x4e, 0x59, 0x31, - 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x07, - 0x0c, 0x08, 0x42, 0x72, 0x6f, 0x6f, 0x6b, 0x6c, - 0x79, 0x6e, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, - 0x55, 0x04, 0x0a, 0x0c, 0x18, 0x4d, 0x79, 0x20, - 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, - 0x61, 0x74, 0x65, 0x20, 0x41, 0x75, 0x74, 0x68, - 0x6f, 0x72, 0x69, 0x74, 0x79, 0x31, 0x11, 0x30, - 0x0f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x08, - 0x6d, 0x79, 0x63, 0x61, 0x2e, 0x6f, 0x72, 0x67, - 0x31, 0x21, 0x30, 0x1f, 0x06, 0x09, 0x2a, 0x86, - 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, - 0x12, 0x6a, 0x76, 0x73, 0x68, 0x61, 0x68, 0x69, - 0x64, 0x40, 0x67, 0x6d, 0x61, 0x69, 0x6c, 0x2e, - 0x63, 0x6f, 0x6d, 0x30, 0x1e, 0x17, 0x0d, 0x31, - 0x33, 0x30, 0x35, 0x32, 0x36, 0x32, 0x31, 0x31, - 0x38, 0x34, 0x30, 0x5a, 0x17, 0x0d, 0x31, 0x33, - 0x30, 0x36, 0x32, 0x35, 0x32, 0x31, 0x31, 0x38, - 0x34, 0x30, 0x5a, 0x30, 0x81, 0x80, 0x31, 0x0b, - 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, - 0x02, 0x55, 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, - 0x03, 0x55, 0x04, 0x08, 0x0c, 0x02, 0x4e, 0x59, - 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, - 0x07, 0x0c, 0x08, 0x42, 0x72, 0x6f, 0x6f, 0x6b, - 0x6c, 0x79, 0x6e, 0x31, 0x15, 0x30, 0x13, 0x06, - 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0c, 0x4d, 0x79, - 0x20, 0x43, 0x41, 0x20, 0x43, 0x6c, 0x69, 0x65, - 0x6e, 0x74, 0x31, 0x17, 0x30, 0x15, 0x06, 0x03, - 0x55, 0x04, 0x03, 0x0c, 0x0e, 0x6d, 0x79, 0x63, - 0x61, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, - 0x63, 0x6f, 0x6d, 0x31, 0x21, 0x30, 0x1f, 0x06, - 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, - 0x09, 0x01, 0x16, 0x12, 0x6a, 0x76, 0x73, 0x68, - 0x61, 0x68, 0x69, 0x64, 0x40, 0x67, 0x6d, 0x61, - 0x69, 0x6c, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x82, - 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, - 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, - 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, - 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xce, - 0x13, 0xf0, 0x72, 0xb0, 0x61, 0xc8, 0x18, 0x37, - 0x8a, 0x41, 0x3d, 0x20, 0xa1, 0x1c, 0xcb, 0xbf, - 0xf6, 0x3b, 0x74, 0x26, 0x2a, 0x96, 0x11, 0xec, - 0x53, 0xa1, 0xcc, 0x7d, 0x77, 0x56, 0x45, 0x0f, - 0x36, 0xb7, 0xf2, 0x48, 0x92, 0x1a, 0x62, 0xcc, - 0xb6, 0xc0, 0xa1, 0x2f, 0x44, 0x2b, 0xc1, 0x89, - 0xcb, 0x6e, 0x1e, 0xdb, 0x57, 0x92, 0xd5, 0x97, - 0x60, 0x8c, 0x41, 0x2c, 0xd9, 0x20, 0xfe, 0xe9, - 0x1f, 0x8e, 0xfc, 0x7f, 0x02, 0x44, 0x0f, 0x28, - 0x81, 0xd6, 0x0c, 0xcd, 0xbc, 0xf0, 0x57, 0x6c, - 0xcc, 0xa7, 0xba, 0x06, 0xa0, 0xa6, 0x91, 0xda, - 0xef, 0x46, 0x8a, 0x60, 0x0f, 0x52, 0x6c, 0x90, - 0x6c, 0x8c, 0x44, 0xaf, 0xb0, 0x9d, 0x90, 0xba, - 0x21, 0x58, 0xa0, 0x3c, 0xee, 0x54, 0xb5, 0x29, - 0x26, 0x1f, 0x0a, 0xac, 0xef, 0x48, 0x68, 0x33, - 0xd0, 0x33, 0xd0, 0x8b, 0x1a, 0xec, 0x6e, 0x2f, - 0xb5, 0x4a, 0x53, 0xc2, 0x1a, 0xd2, 0xf1, 0x50, - 0x05, 0x59, 0x5c, 0xd9, 0xda, 0x03, 0x0a, 0x47, - 0xb7, 0xdd, 0xf7, 0x3a, 0x69, 0xf5, 0x4e, 0xea, - 0x4a, 0xc2, 0xca, 0x54, 0xb0, 0x8b, 0x76, 0xe1, - 0x02, 0x2d, 0x52, 0x67, 0xb9, 0xdd, 0x50, 0xc9, - 0x3b, 0x07, 0x24, 0x22, 0x6a, 0x00, 0x1d, 0x58, - 0x83, 0xa8, 0xec, 0x95, 0xf1, 0xda, 0xe2, 0x73, - 0xa0, 0xa1, 0x72, 0x60, 0x9e, 0x86, 0x53, 0xcb, - 0x45, 0xa8, 0xc2, 0xa0, 0x50, 0xa0, 0x53, 0xd6, - 0xfc, 0x18, 0x84, 0xb5, 0x4a, 0x26, 0xd0, 0xa2, - 0xaa, 0xd0, 0xff, 0xb6, 0xfe, 0x3a, 0x9c, 0xb5, - 0x19, 0x3b, 0x3f, 0xe1, 0x48, 0x0d, 0xa4, 0x09, - 0x4f, 0x83, 0xc9, 0xc0, 0xc9, 0xa6, 0x0b, 0x58, - 0x1f, 0x1c, 0x7b, 0xac, 0xa2, 0x42, 0xbc, 0x61, - 0xf4, 0x21, 0x8a, 0x00, 0xda, 0x14, 0xa0, 0x60, - 0x03, 0xfe, 0x93, 0x12, 0x6c, 0x56, 0xcd, 0x02, - 0x03, 0x01, 0x00, 0x01, 0x30, 0x0d, 0x06, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x05, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, - 0x25, 0x29, 0x3b, 0x1e, 0xc3, 0x58, 0x32, 0xe6, - 0x23, 0xc8, 0xee, 0x18, 0xf0, 0x1d, 0x62, 0x6d, - 0x3b, 0x59, 0x99, 0x3a, 0xfe, 0x49, 0x72, 0x07, - 0x3f, 0x58, 0x93, 0xdb, 0xc0, 0xaf, 0xb0, 0xb3, - 0x5c, 0xd1, 0x5c, 0x98, 0xc8, 0xea, 0x4a, 0xe4, - 0x58, 0x73, 0x0d, 0x57, 0xc5, 0x13, 0x7c, 0x5c, - 0x79, 0x66, 0xda, 0x04, 0x1d, 0xe5, 0x98, 0xda, - 0x35, 0x47, 0x44, 0xb0, 0xd2, 0x7a, 0x66, 0x9d, - 0xcd, 0x41, 0xa5, 0x8f, 0xa1, 0x11, 0xb2, 0x1a, - 0x87, 0xc0, 0xcd, 0x55, 0xed, 0xb4, 0x7b, 0x33, - 0x72, 0xeb, 0xf7, 0xe3, 0x7b, 0x8b, 0x02, 0x86, - 0xe9, 0x2b, 0x26, 0x32, 0x9f, 0x99, 0xf1, 0xcb, - 0x93, 0xab, 0xb9, 0x16, 0xb3, 0x9a, 0xb2, 0x22, - 0x13, 0x21, 0x1f, 0x5b, 0xcc, 0xa2, 0x59, 0xbb, - 0x69, 0xf2, 0xb8, 0x07, 0x80, 0xce, 0x0c, 0xf7, - 0x98, 0x4c, 0x85, 0xc2, 0x96, 0x6a, 0x22, 0x05, - 0xe9, 0xbe, 0x48, 0xb0, 0x02, 0x5b, 0x69, 0x28, - 0x18, 0x88, 0x96, 0xe3, 0xd7, 0xc6, 0x7a, 0xd3, - 0xe9, 0x99, 0xff, 0x9d, 0xc3, 0x61, 0x4d, 0x9a, - 0x96, 0xf2, 0xc6, 0x33, 0x4d, 0xe5, 0x5d, 0x5a, - 0x68, 0x64, 0x5a, 0x82, 0x35, 0x65, 0x25, 0xe3, - 0x8c, 0x5b, 0xb0, 0xf6, 0x96, 0x56, 0xbc, 0xbf, - 0x97, 0x76, 0x4b, 0x66, 0x44, 0x81, 0xa4, 0xc4, - 0xa7, 0x31, 0xc5, 0xa1, 0x4f, 0xe8, 0xa4, 0xca, - 0x20, 0xf5, 0x01, 0x5b, 0x99, 0x4f, 0x5a, 0xf4, - 0xf0, 0x78, 0xbf, 0x71, 0x49, 0xd5, 0xf1, 0xc1, - 0xa2, 0x18, 0xfd, 0x72, 0x5b, 0x16, 0xe8, 0x92, - 0xc7, 0x37, 0x48, 0xaf, 0xee, 0x24, 0xfc, 0x35, - 0x0b, 0xc2, 0xdd, 0x05, 0xc7, 0x6e, 0xa3, 0x29, - 0xbb, 0x29, 0x7d, 0xd3, 0x2b, 0x94, 0x80, 0xc3, - 0x40, 0x53, 0x0e, 0x03, 0x54, 0x3d, 0x7b, 0x8b, - 0xce, 0xf9, 0xa4, 0x03, 0x27, 0x63, 0xec, 0x51, - 0x00, 0x03, 0xe5, 0x30, 0x82, 0x03, 0xe1, 0x30, - 0x82, 0x02, 0xc9, 0xa0, 0x03, 0x02, 0x01, 0x02, - 0x02, 0x09, 0x00, 0xcc, 0x22, 0x4c, 0x4b, 0x98, - 0xa2, 0x88, 0xfc, 0x30, 0x0d, 0x06, 0x09, 0x2a, - 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, - 0x05, 0x00, 0x30, 0x81, 0x86, 0x31, 0x0b, 0x30, - 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, - 0x55, 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, - 0x55, 0x04, 0x08, 0x0c, 0x02, 0x4e, 0x59, 0x31, - 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x07, - 0x0c, 0x08, 0x42, 0x72, 0x6f, 0x6f, 0x6b, 0x6c, - 0x79, 0x6e, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, - 0x55, 0x04, 0x0a, 0x0c, 0x18, 0x4d, 0x79, 0x20, - 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, - 0x61, 0x74, 0x65, 0x20, 0x41, 0x75, 0x74, 0x68, - 0x6f, 0x72, 0x69, 0x74, 0x79, 0x31, 0x11, 0x30, - 0x0f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x08, - 0x6d, 0x79, 0x63, 0x61, 0x2e, 0x6f, 0x72, 0x67, - 0x31, 0x21, 0x30, 0x1f, 0x06, 0x09, 0x2a, 0x86, - 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, - 0x12, 0x6a, 0x76, 0x73, 0x68, 0x61, 0x68, 0x69, - 0x64, 0x40, 0x67, 0x6d, 0x61, 0x69, 0x6c, 0x2e, - 0x63, 0x6f, 0x6d, 0x30, 0x1e, 0x17, 0x0d, 0x31, - 0x33, 0x30, 0x35, 0x32, 0x36, 0x32, 0x31, 0x30, - 0x35, 0x30, 0x31, 0x5a, 0x17, 0x0d, 0x32, 0x33, - 0x30, 0x35, 0x32, 0x34, 0x32, 0x31, 0x30, 0x35, - 0x30, 0x31, 0x5a, 0x30, 0x81, 0x86, 0x31, 0x0b, - 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, - 0x02, 0x55, 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, - 0x03, 0x55, 0x04, 0x08, 0x0c, 0x02, 0x4e, 0x59, - 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, - 0x07, 0x0c, 0x08, 0x42, 0x72, 0x6f, 0x6f, 0x6b, - 0x6c, 0x79, 0x6e, 0x31, 0x21, 0x30, 0x1f, 0x06, - 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x18, 0x4d, 0x79, - 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, - 0x63, 0x61, 0x74, 0x65, 0x20, 0x41, 0x75, 0x74, - 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x31, 0x11, - 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, - 0x08, 0x6d, 0x79, 0x63, 0x61, 0x2e, 0x6f, 0x72, - 0x67, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x09, 0x2a, - 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, - 0x16, 0x12, 0x6a, 0x76, 0x73, 0x68, 0x61, 0x68, - 0x69, 0x64, 0x40, 0x67, 0x6d, 0x61, 0x69, 0x6c, - 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x82, 0x01, 0x22, - 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, - 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, - 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, - 0x02, 0x82, 0x01, 0x01, 0x00, 0xf0, 0xfb, 0xad, - 0x80, 0x5e, 0x37, 0xd3, 0x6d, 0xee, 0x2e, 0xcc, - 0xbc, 0x0c, 0xd7, 0x56, 0x4b, 0x56, 0x45, 0xcd, - 0x28, 0xb6, 0x22, 0xe9, 0xe2, 0x0f, 0xd1, 0x87, - 0x2a, 0x27, 0xce, 0x77, 0x8d, 0x6e, 0x0e, 0x0f, - 0xfb, 0x66, 0xe1, 0xb5, 0x0e, 0x9a, 0xb6, 0x05, - 0x8e, 0xb3, 0xe1, 0xc5, 0x77, 0x86, 0x5b, 0x46, - 0xd2, 0x0b, 0x92, 0x03, 0x1b, 0x89, 0x0c, 0x1b, - 0x10, 0x0e, 0x99, 0x8f, 0xe2, 0x17, 0xe8, 0xc2, - 0x30, 0x00, 0x47, 0xd6, 0xfc, 0xf9, 0x0f, 0x3b, - 0x75, 0x34, 0x8d, 0x4d, 0xb0, 0x99, 0xb7, 0xa0, - 0x6d, 0xa0, 0xb6, 0xad, 0xda, 0x07, 0x5e, 0x38, - 0x2e, 0x02, 0xe4, 0x30, 0x6d, 0xae, 0x13, 0x72, - 0xd4, 0xc8, 0xce, 0x14, 0x07, 0xae, 0x23, 0x8c, - 0x8f, 0x9e, 0x8c, 0x60, 0xd6, 0x06, 0xb9, 0xef, - 0x00, 0x18, 0xc0, 0x1d, 0x25, 0x1e, 0xda, 0x3e, - 0x2f, 0xcf, 0x2b, 0x56, 0x84, 0x9e, 0x30, 0x21, - 0xc7, 0x29, 0xf6, 0x03, 0x8a, 0x24, 0xf9, 0x34, - 0xac, 0x65, 0x9d, 0x80, 0x36, 0xc8, 0x3b, 0x15, - 0x10, 0xbd, 0x51, 0xe9, 0xbc, 0x02, 0xe1, 0xe9, - 0xb3, 0x5a, 0x9a, 0x99, 0x41, 0x1b, 0x27, 0xa0, - 0x4d, 0x50, 0x9e, 0x27, 0x7f, 0xa1, 0x7d, 0x09, - 0x87, 0xbd, 0x8a, 0xca, 0x5f, 0xb1, 0xa5, 0x08, - 0xb8, 0x04, 0xd4, 0x52, 0x89, 0xaa, 0xe0, 0x7d, - 0x42, 0x2e, 0x2f, 0x15, 0xee, 0x66, 0x57, 0x0f, - 0x13, 0x19, 0x45, 0xa8, 0x4b, 0x5d, 0x81, 0x66, - 0xcc, 0x12, 0x37, 0x94, 0x5e, 0xfd, 0x3c, 0x10, - 0x81, 0x51, 0x3f, 0xfa, 0x0f, 0xdd, 0xa1, 0x89, - 0x03, 0xa9, 0x78, 0x91, 0xf5, 0x3b, 0xf3, 0xbc, - 0xac, 0xbe, 0x93, 0x30, 0x2e, 0xbe, 0xca, 0x7f, - 0x46, 0xd3, 0x28, 0xb4, 0x4e, 0x91, 0x7b, 0x5b, - 0x43, 0x6c, 0xaf, 0x9b, 0x5c, 0x6a, 0x6d, 0x5a, - 0xdb, 0x79, 0x5e, 0x6a, 0x6b, 0x02, 0x03, 0x01, - 0x00, 0x01, 0xa3, 0x50, 0x30, 0x4e, 0x30, 0x1d, - 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, - 0x14, 0x6b, 0x1e, 0x00, 0xa8, 0x9f, 0xfa, 0x7d, - 0x00, 0xf9, 0xe0, 0x9d, 0x0f, 0x90, 0x8c, 0x90, - 0xa8, 0xa1, 0x37, 0x6b, 0xda, 0x30, 0x1f, 0x06, - 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, - 0x80, 0x14, 0x6b, 0x1e, 0x00, 0xa8, 0x9f, 0xfa, - 0x7d, 0x00, 0xf9, 0xe0, 0x9d, 0x0f, 0x90, 0x8c, - 0x90, 0xa8, 0xa1, 0x37, 0x6b, 0xda, 0x30, 0x0c, - 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, 0x30, - 0x03, 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x05, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, - 0xcd, 0x6f, 0x73, 0x4d, 0x56, 0x0b, 0xf3, 0x2e, - 0x1c, 0xe2, 0x02, 0x0c, 0x14, 0xbb, 0x2f, 0xdd, - 0x3c, 0x43, 0xfe, 0xdf, 0x94, 0x2d, 0xa9, 0x89, - 0x81, 0x51, 0xf8, 0x5f, 0xa7, 0xa0, 0x13, 0xaa, - 0xcc, 0xb0, 0x18, 0xe2, 0x57, 0x3e, 0x0d, 0x29, - 0x93, 0xe8, 0x95, 0xd5, 0x1b, 0x53, 0xd2, 0x51, - 0xf2, 0xbd, 0xf5, 0x9e, 0x7b, 0x22, 0x65, 0x62, - 0x5c, 0xc4, 0x4c, 0x1d, 0xe8, 0xe9, 0xc3, 0xd4, - 0x2b, 0xe7, 0x78, 0xcb, 0x10, 0xf3, 0xfe, 0x06, - 0x83, 0xdc, 0x3a, 0x1e, 0x62, 0x10, 0xc0, 0x46, - 0x77, 0xc6, 0x9d, 0x9f, 0xab, 0x96, 0x25, 0x5c, - 0xfb, 0x26, 0xc1, 0x15, 0x1f, 0xa5, 0x33, 0xee, - 0x4f, 0x9a, 0x14, 0x6a, 0x14, 0x97, 0x93, 0x2b, - 0x95, 0x0b, 0xdc, 0xa8, 0xd7, 0x69, 0x2e, 0xf0, - 0x01, 0x0e, 0xfd, 0x4e, 0xd0, 0xd9, 0xa8, 0xe5, - 0x65, 0xde, 0xfb, 0xca, 0xca, 0x1c, 0x5f, 0xf9, - 0x53, 0xa0, 0x87, 0xe7, 0x33, 0x9b, 0x2f, 0xcf, - 0xe4, 0x13, 0xfc, 0xec, 0x7a, 0x6c, 0xb0, 0x90, - 0x13, 0x9b, 0xb6, 0xc5, 0x03, 0xf6, 0x0e, 0x5e, - 0xe2, 0xe4, 0x26, 0xc1, 0x7e, 0x53, 0xfe, 0x69, - 0xa3, 0xc7, 0xd8, 0x8e, 0x6e, 0x94, 0x32, 0xa0, - 0xde, 0xca, 0xb6, 0xcc, 0xd6, 0x01, 0xd5, 0x78, - 0x40, 0x28, 0x63, 0x9b, 0xee, 0xcf, 0x09, 0x3b, - 0x35, 0x04, 0xf0, 0x14, 0x02, 0xf6, 0x80, 0x0e, - 0x90, 0xb2, 0x94, 0xd2, 0x25, 0x16, 0xb8, 0x7a, - 0x76, 0x87, 0x84, 0x9f, 0x84, 0xc5, 0xaf, 0xc2, - 0x6d, 0x68, 0x7a, 0x84, 0x9c, 0xc6, 0x8a, 0x63, - 0x60, 0x87, 0x6a, 0x25, 0xc1, 0xa1, 0x78, 0x0f, - 0xba, 0xe8, 0x5f, 0xe1, 0xba, 0xac, 0xa4, 0x6f, - 0xdd, 0x09, 0x3f, 0x12, 0xcb, 0x1d, 0xf3, 0xcf, - 0x48, 0xd7, 0xd3, 0x26, 0xe8, 0x9c, 0xc3, 0x53, - 0xb3, 0xba, 0xdc, 0x32, 0x99, 0x98, 0x96, 0xd6, - 0x16, 0x03, 0x03, 0x00, 0x46, 0x10, 0x00, 0x00, - 0x42, 0x41, 0x04, 0x1e, 0x18, 0x37, 0xef, 0x0d, - 0x19, 0x51, 0x88, 0x35, 0x75, 0x71, 0xb5, 0xe5, - 0x54, 0x5b, 0x12, 0x2e, 0x8f, 0x09, 0x67, 0xfd, - 0xa7, 0x24, 0x20, 0x3e, 0xb2, 0x56, 0x1c, 0xce, - 0x97, 0x28, 0x5e, 0xf8, 0x2b, 0x2d, 0x4f, 0x9e, - 0xf1, 0x07, 0x9f, 0x6c, 0x4b, 0x5b, 0x83, 0x56, - 0xe2, 0x32, 0x42, 0xe9, 0x58, 0xb6, 0xd7, 0x49, - 0xa6, 0xb5, 0x68, 0x1a, 0x41, 0x03, 0x56, 0x6b, - 0xdc, 0x5a, 0x89, 0x16, 0x03, 0x03, 0x01, 0x08, - 0x0f, 0x00, 0x01, 0x04, 0x04, 0x01, 0x01, 0x00, - 0x7e, 0xe4, 0x65, 0x02, 0x8e, 0xb3, 0x34, 0x6a, - 0x47, 0x71, 0xd1, 0xb0, 0x8d, 0x3c, 0x0c, 0xe1, - 0xde, 0x7e, 0x5f, 0xb4, 0x15, 0x2d, 0x32, 0x0a, - 0x2a, 0xdb, 0x9b, 0x40, 0xba, 0xce, 0x8b, 0xf5, - 0x74, 0xc1, 0x68, 0x20, 0x7c, 0x87, 0x23, 0x13, - 0xc3, 0x13, 0xa7, 0xdb, 0xec, 0x59, 0xa0, 0x40, - 0x9e, 0x64, 0x03, 0x60, 0xac, 0x76, 0xff, 0x01, - 0x34, 0x7b, 0x32, 0x26, 0xd9, 0x41, 0x31, 0x93, - 0xaa, 0x30, 0x51, 0x83, 0x85, 0x40, 0xeb, 0x4e, - 0x66, 0x39, 0x83, 0xb1, 0x30, 0x0d, 0x96, 0x01, - 0xee, 0x81, 0x53, 0x5e, 0xec, 0xa9, 0xc9, 0xdf, - 0x7e, 0xc1, 0x09, 0x47, 0x8b, 0x35, 0xdb, 0x10, - 0x15, 0xd4, 0xc7, 0x5a, 0x39, 0xe3, 0xc0, 0xf3, - 0x93, 0x38, 0x11, 0xdc, 0x71, 0xbb, 0xc7, 0x62, - 0x2b, 0x85, 0xad, 0x6b, 0x4f, 0x09, 0xb3, 0x31, - 0xa8, 0xe5, 0xd1, 0xb3, 0xa9, 0x21, 0x37, 0x50, - 0xc8, 0x7d, 0xc3, 0xd2, 0xf7, 0x00, 0xd3, 0xdb, - 0x0f, 0x82, 0xf2, 0x43, 0xcf, 0x36, 0x6c, 0x98, - 0x63, 0xd8, 0x1d, 0xb3, 0xf3, 0xde, 0x63, 0x79, - 0x64, 0xf0, 0xdb, 0x46, 0x04, 0xe1, 0x1c, 0x57, - 0x0f, 0x9e, 0x96, 0xb9, 0x93, 0x45, 0x71, 0x1c, - 0x8b, 0x65, 0x7d, 0x1e, 0xad, 0xbd, 0x03, 0x51, - 0xae, 0x44, 0xef, 0x97, 0x45, 0x0d, 0x8d, 0x41, - 0x5c, 0x80, 0x7b, 0xe6, 0xe0, 0xbc, 0xa6, 0x72, - 0x95, 0xa0, 0x97, 0xe1, 0xbb, 0xc0, 0xcc, 0xe5, - 0x1e, 0xc3, 0xbe, 0xd7, 0x42, 0x2a, 0xf3, 0x75, - 0x8a, 0x44, 0x67, 0x3c, 0xe5, 0x68, 0x78, 0xe5, - 0x40, 0x1f, 0xf0, 0x89, 0x57, 0xda, 0xee, 0x45, - 0xf4, 0x44, 0x81, 0x01, 0x77, 0xf0, 0x4a, 0x14, - 0xb1, 0x3f, 0x60, 0x2b, 0xeb, 0x42, 0x38, 0xa6, - 0xfb, 0xe5, 0x4d, 0x71, 0xdc, 0x7d, 0x0a, 0x72, - 0x56, 0x28, 0x9d, 0xa6, 0x8e, 0x74, 0x2d, 0xbd, - 0x14, 0x03, 0x03, 0x00, 0x01, 0x01, 0x16, 0x03, - 0x03, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x31, 0x4d, 0x58, 0x94, 0x0b, - 0x0b, 0x06, 0x5f, 0xae, 0x57, 0x17, 0x98, 0x86, - 0xaa, 0x49, 0x17, 0x7f, 0xbd, 0x41, 0x05, 0xa5, - 0x74, 0x1c, 0x58, 0xc8, 0x38, 0x2d, 0x99, 0x5d, - 0xe5, 0x12, 0x43, - }, - { - 0x14, 0x03, 0x03, 0x00, 0x01, 0x01, 0x16, 0x03, - 0x03, 0x00, 0x28, 0xf2, 0x60, 0xc2, 0x75, 0x27, - 0x64, 0xf4, 0x05, 0x98, 0xc9, 0xd3, 0xa8, 0x00, - 0x4c, 0xa0, 0x49, 0x82, 0x68, 0xf1, 0x21, 0x05, - 0x7b, 0x4b, 0x25, 0x3e, 0xe1, 0x5f, 0x0f, 0x84, - 0x26, 0x2d, 0x16, 0x2e, 0xc0, 0xfd, 0xdf, 0x0a, - 0xf4, 0xba, 0x19, - }, - { - 0x17, 0x03, 0x03, 0x00, 0x1e, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x35, 0xef, 0x9d, - 0x6a, 0x86, 0x98, 0xc5, 0xca, 0x55, 0xca, 0x89, - 0x29, 0xb4, 0x55, 0xd4, 0x41, 0x08, 0x96, 0xe0, - 0xf3, 0x39, 0xfc, 0x15, 0x03, 0x03, 0x00, 0x1a, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x02, 0x63, 0x1b, 0xaa, 0xc6, 0xc9, 0x6d, 0x72, - 0x24, 0x10, 0x55, 0xa9, 0x8c, 0x3b, 0x23, 0xce, - 0xd8, 0x4a, - }, -} - -var testClientChainCertificate = fromHex( - "2d2d2d2d2d424547494e2050524956415445204b" + - "45592d2d2d2d2d0a4d494945766749424144414e" + - "42676b71686b6947397730424151454641415343" + - "424b67776767536b41674541416f494241514367" + - "6f2b2f4252483269343347590a4a324f7a485846" + - "51706a515679386b71772b726b6e70784a706747" + - "6266716d31657638566b6e48496c35776c74336b" + - "722f367647736163416b4c4b4c313348560a776a" + - "726d676b493369554545734c7248573470446e35" + - "633544412f56625a364e3638416d78526a6f656a" + - "30794c6a6951514673354c41664c4a4244467954" + - "766a0a5a6b64587557717452506a51634749376a" + - "75316758794c3475417a4a5153764a6747354f47" + - "2b45672f45656b724d4d2f35734b4265514d334a" + - "596e4b317156470a6b574e427854375637583950" + - "6a5162416951432b4e33742b6338707741425130" + - "766b6538736d6f6f70536d45714a3349486e646d" + - "48352b714b306662335775630a715079434e7052" + - "694456772f7367473070626a4744705262374636" + - "37656d4d6b38666e5755416a426f387951423173" + - "4542454a307a7a6636384b585a3034614a0a6952" + - "6a7a544f495241674d424141454367674542414a" + - "4b613676326b5a3144596146786e586d7369624c" + - "386734426f67514c6a42307362524a6d746b6b4d" + - "54370a685343325873537551522f446c654d7148" + - "664555786731784a717579597643544d44585972" + - "473667354a5051744d4432465a424a7239626c65" + - "467138386c706a0a543766514e793571354c2b4f" + - "682f6b62433835436e623641753641656978776d" + - "2b6e77665a4f3766726b6278306d35516b715975" + - "5739392f452b69502b454e570a76396a68773436" + - "76515065563236494b79717656462b4f7362722f" + - "6152316138707948336361566e3579594a433346" + - "5855756c6f5a77516331714a6b4c434c4c0a375a" + - "49744f525a78514c486d4d4a654d44722f5a4942" + - "34675467645650636145375a4d5141714d6d3066" + - "4c6b6d7671723149526b77642f6831455a645650" + - "79320a742f6b6b43413039566336663749556575" + - "6f67706d705a50303130564e376b6277394a6348" + - "75544561564543675945417a47395679426e6d62" + - "6858496c57764f0a71583747524f2f5231636a2b" + - "6b564e35377876674b54756b35592b7a4d774a48" + - "32626c57435945513251753974446c476854756b" + - "664273385746772b6e6263460a7a6f706d535245" + - "6c6d464d2f6141536d464733574e5a7072696a68" + - "504b77726338376470636b31703131635a415478" + - "5a413168566d43743457616343673634690a4d74" + - "64507a334e2f34416147664956794d2b69624949" + - "35332f515543675945417953693556735a356f6a" + - "644a795077426e6c6142554231686f2b336b7068" + - "70770a7264572b2b4d796b51494a345564534437" + - "3052486e5a315839754359713978616671746c51" + - "664c44395963442f436d665264706461586c5673" + - "5249467a5a556c0a454630557149644e77337046" + - "68634f4a6d6e5a3241434470434342476f763542" + - "6e3068302b3137686a4b376f69315833716e4542" + - "7857326c7462593476556a500a44394c5330666e" + - "4a76703043675942504a527330714c4a4a464333" + - "6669796b712f57574d38727474354b364a584b50" + - "734b674b53644144577a7463316645434d0a7a65" + - "2b394a6a5a376b4d77557063666a644c2b745047" + - "3455563048326c524375635735414131396d7058" + - "50367454494733713737655a6b416e65516f6163" + - "41340a716c3073583051476c6a5763414e30464b" + - "6f4759733975582b6378445a6e7265362f52392f" + - "3930567766443237454c57546373677734633463" + - "514b42675143420a6f5432326e745a5a59396d6e" + - "72455a36752f492f4a332f35664e396737783733" + - "3177746e463745745a5361575453587364597256" + - "466b564f6362505135494a6f0a714a6a7249372b" + - "474a4d69376f6a4c69642f4c45656f31764f3163" + - "454158334f43723236554e38612f6c7434394f5a" + - "69354c337348556b756c475951755671650a6737" + - "6e6e4632437749544c34503645486443575a4461" + - "7a4136626d7375524f2b6462536e335a6c567651" + - "4b42674859524c5a665458536c44755264776977" + - "746b0a513148546b6d6b57694156726c4f577864" + - "5858456d546130303045574c46446145797a7358" + - "7834424863357166776b5a4e746b634a56396e58" + - "63536e647441530a35767a427a676e797a4f7962" + - "68315878484a3966427472414f3847555878446c" + - "6634394457616753393449763072596e616b7656" + - "2f673039786875415763366e0a5365757230576b" + - "5376453847666653734d485149584c456b0a2d2d" + - "2d2d2d454e442050524956415445204b45592d2d" + - "2d2d2d0a2d2d2d2d2d424547494e204345525449" + - "4649434154452d2d2d2d2d0a4d494944656a4343" + - "416d494343514330523168584b326649776a414e" + - "42676b71686b6947397730424151554641444342" + - "6744454c4d416b474131554542684d430a56564d" + - "78437a414a42674e564241674d416b355a4d5245" + - "77447759445651514844416843636d3976613278" + - "35626a45564d424d47413155454367774d54586b" + - "670a51304567513278705a5735304d5263774651" + - "5944565151444441357465574e68593278705a57" + - "35304c6d4e76625445684d423847435371475349" + - "62334451454a0a41525953616e5a7a6147466f61" + - "5752415a32316861577775593239744d42345844" + - "54457a4d4455794e6a49784e4451774d466f5844" + - "54457a4d4459794e5449780a4e4451774d466f77" + - "6654454c4d416b474131554542684d4356564d78" + - "4554415042674e564241674d4345356c6479425a" + - "62334a724d52457744775944565151480a444168" + - "43636d397661327835626a45514d413447413155" + - "454367774854586b67544756685a6a45544d4245" + - "47413155454177774b62586c735a57466d4c6d4e" + - "760a625445684d42384743537147534962334451" + - "454a41525953616e5a7a6147466f615752415a32" + - "316861577775593239744d494942496a414e4267" + - "6b71686b69470a397730424151454641414f4341" + - "5138414d49494243674b43415145416f4b507677" + - "5552396f754e786d43646a73783178554b593046" + - "63764a4b735071354a36630a536159426d333670" + - "7458722f465a4a78794a65634a6264354b2f2b72" + - "7872476e414a43796939647831634936356f4a43" + - "4e346c42424c43367831754b51352b580a4f5177" + - "50315732656a6576414a73555936486f394d6934" + - "346b4542624f5377487979515178636b3734325a" + - "4856376c7172555434304842694f343774594638" + - "690a2b4c674d7955457279594275546876684950" + - "7848704b7a44502b624367586b444e79574a7974" + - "616c5270466a5163552b3165312f543430477749" + - "6b41766a64370a666e504b634141554e4c354876" + - "4c4a714b4b5570684b6964794235335a682b6671" + - "697448323931726e4b6a38676a61555967316350" + - "374942744b5734786736550a572b78657533706a" + - "4a504835316c41497761504d6b41646242415243" + - "644d38332b76436c32644f4769596b5938307a69" + - "45514944415141424d413047435371470a534962" + - "3344514542425155414134494241514351752f6c" + - "65756863667243476661307047304730386a7a33" + - "34586a357972364161382f2b4a72467436347045" + - "710a493458475455646e4151696f425230425946" + - "42665761332b6538594d564a426f634763753759" + - "6634615971734d7635766b426b715a4932435a67" + - "5644694f37790a4d4f326b6a372f575679445551" + - "7831536c6d2b75435a5942556a6a6a72356e5833" + - "42535a7849734f42412b7a46425455705a506879" + - "597142373250384e6e63460a427641714241712b" + - "4c73364250534f6832746a72787570657a796732" + - "55544756586b414537617a4279465a70682b7737" + - "417a36644430784d363965364a742f6a0a336844" + - "756b324b4e63314a752f7a63326d487374566b79" + - "364362696e384473576763726251367673544735" + - "3877517369496b4d6474677a4275632f6b552b34" + - "640a506f696e4537352f766135797a38316a3073" + - "4d59574a4b697262554a6e5a454433547a69484e" + - "35340a2d2d2d2d2d454e44204345525449464943" + - "4154452d2d2d2d2d0a2d2d2d2d2d424547494e20" + - "43455254494649434154452d2d2d2d2d0a4d4949" + - "4468444343416d7743435143723761626b536973" + - "722b44414e42676b71686b694739773042415155" + - "4641444342686a454c4d416b474131554542684d" + - "430a56564d78437a414a42674e564241674d416b" + - "355a4d524577447759445651514844416843636d" + - "397661327835626a45684d423847413155454367" + - "775954586b670a5132567964476c6d61574e6864" + - "4755675158563061473979615852354d52457744" + - "775944565151444441687465574e684c6d39795a" + - "7a45684d423847435371470a534962334451454a" + - "41525953616e5a7a6147466f615752415a323168" + - "61577775593239744d4234584454457a4d445579" + - "4e6a49784d5467304d466f584454457a0a4d4459" + - "794e5449784d5467304d466f7767594178437a41" + - "4a42674e5642415954416c56544d517377435159" + - "445651514944414a4f575445524d413847413155" + - "450a42777749516e4a7662327473655734784654" + - "415442674e5642416f4d4445313549454e424945" + - "4e7361575675644445584d425547413155454177" + - "774f62586c6a0a59574e73615756756443356a62" + - "3230784954416642676b71686b69473977304243" + - "514557456d70326332686861476c6b5147647459" + - "576c734c6d4e76625443430a415349774451594a" + - "4b6f5a496876634e415145424251414467674550" + - "4144434341516f4367674542414d345438484b77" + - "596367594e34704250534368484d752f0a396a74" + - "304a697157456578546f63783964315a46447a61" + - "33386b6953476d4c4d747343684c30517277596e" + - "4c6268376256354c566c32434d51537a5a495037" + - "700a4834373866774a454479694231677a4e7650" + - "4258624d796e75676167707048613730614b5941" + - "3953624a42736a455376734a3251756946596f44" + - "7a75564c55700a4a68384b724f3949614450514d" + - "39434c477578754c37564b553849613076465142" + - "566c6332646f44436b6533336663366166564f36" + - "6b7243796c5377693362680a416931535a376e64" + - "554d6b37427951696167416457494f6f374a5878" + - "32754a7a6f4b4679594a364755387446714d4b67" + - "554b425431767759684c564b4a7443690a717444" + - "2f747634366e4c555a4f7a2f685341326b43552b" + - "447963444a7067745948787837724b4a43764748" + - "3049596f41326853675941502b6b784a73567330" + - "430a417745414154414e42676b71686b69473977" + - "30424151554641414f43415145414a536b374873" + - "4e594d75596a794f3459384231696254745a6d54" + - "722b535849480a5031695432384376734c4e6330" + - "567959794f704b3546687a445666464533786365" + - "5762614242336c6d4e6f3152305377306e706d6e" + - "63314270592b68456249610a6838444e56653230" + - "657a4e79362f666a6534734368756b724a6a4b66" + - "6d66484c6b36753546724f617369495449523962" + - "7a4b4a5a75326e79754165417a677a330a6d4579" + - "4677705a7149675870766b6977416c74704b4269" + - "496c755058786e7254365a6e2f6e634e68545a71" + - "573873597a54655664576d686b576f49315a5358" + - "6a0a6a46757739705a57764c2b58646b746d5249" + - "476b784b637878614650364b544b495055425735" + - "6c5057765477654c397853645878776149592f58" + - "4a62467569530a787a6449722b346b2f44554c77" + - "7430467832366a4b62737066644d726c49444451" + - "464d4f413151396534764f2b6151444a32507355" + - "513d3d0a2d2d2d2d2d454e442043455254494649" + - "434154452d2d2d2d2d0a2d2d2d2d2d424547494e" + - "2043455254494649434154452d2d2d2d2d0a4d49" + - "49443454434341736d67417749424167494a414d" + - "7769544575596f6f6a384d413047435371475349" + - "623344514542425155414d4947474d5173774351" + - "59440a5651514745774a56557a454c4d416b4741" + - "31554543417743546c6b784554415042674e5642" + - "41634d43454a796232397262486c754d53457748" + - "7759445651514b0a4442684e655342445a584a30" + - "61575a70593246305a5342426458526f62334a70" + - "64486b784554415042674e5642414d4d43473135" + - "5932457562334a6e4d5345770a4877594a4b6f5a" + - "496876634e41516b4246684a71646e4e6f595768" + - "705a45426e625746706243356a62323077486863" + - "4e4d544d774e5449324d6a45774e5441780a5768" + - "634e4d6a4d774e5449304d6a45774e544178576a" + - "4342686a454c4d416b474131554542684d435656" + - "4d78437a414a42674e564241674d416b355a4d52" + - "45770a447759445651514844416843636d397661" + - "327835626a45684d423847413155454367775954" + - "586b675132567964476c6d61574e686447556751" + - "585630614739790a615852354d52457744775944" + - "565151444441687465574e684c6d39795a7a4568" + - "4d42384743537147534962334451454a41525953" + - "616e5a7a6147466f615752410a5a323168615777" + - "75593239744d494942496a414e42676b71686b69" + - "47397730424151454641414f43415138414d4949" + - "4243674b434151454138507574674634330a3032" + - "33754c737938444e645753315a467a5369324975" + - "6e69443947484b69664f6434317544672f375a75" + - "4731447071324259367a34635633686c74473067" + - "75530a4178754a4442735144706d503468666f77" + - "6a4141523962382b5138376454534e5462435a74" + - "3642746f4c6174326764654f4334433544427472" + - "684e79314d6a4f0a46416575493479506e6f7867" + - "31676135377741597742306c48746f2b4c383872" + - "566f53654d4348484b665944696954354e4b786c" + - "6e59413279447356454c31520a3662774334656d" + - "7a5770715a5152736e6f4531516e69642f6f5830" + - "4a6837324b796c2b7870516934424e5253696172" + - "67665549754c7858755a6c635045786c460a7145" + - "74646757624d456a65555876303845494652502f" + - "6f503361474a41366c346b665537383779737670" + - "4d774c72374b663062544b4c524f6b5874625132" + - "79760a6d31787162567262655635716177494441" + - "5141426f314177546a416442674e564851344546" + - "67515561783441714a2f3666514435344a30506b" + - "497951714b45330a61396f77487759445652306a" + - "42426777466f415561783441714a2f3666514435" + - "344a30506b497951714b453361396f7744415944" + - "5652305442415577417745420a2f7a414e42676b" + - "71686b6947397730424151554641414f43415145" + - "417a57397a5456594c387934633467494d464c73" + - "76335478442f742b554c616d4a675648340a5836" + - "65674536724d73426a69567a344e4b5a506f6c64" + - "556255394a52387233316e6e73695a574a637845" + - "7764364f6e443143766e654d7351382f34476739" + - "77360a486d495177455a33787032667135596c58" + - "50736d775255667054507554356f55616853586b" + - "7975564339796f31326b753841454f2f55375132" + - "616a6c5a6437370a79736f63582f6c546f49666e" + - "4d3573767a2b51542f4f7836624c435145357532" + - "78515032446c376935436242666c502b61615048" + - "324935756c444b67337371320a7a4e5942315868" + - "414b474f623773384a4f7a554538425143396f41" + - "4f6b4c4b55306955577548703268345366684d57" + - "76776d316f656f5363786f706a594964710a4a63" + - "476865412b3636462f687571796b6239304a5078" + - "4c4c48665050534e66544a75696377314f7a7574" + - "77796d5a695731673d3d0a2d2d2d2d2d454e4420" + - "43455254494649434154452d2d2d2d2d0a", -) - -// Script of interaction with openssl implementation: -// -// openssl s_server -cipher ECDHE-ECDSA-AES128-SHA \ -// -key server.key -cert server.crt -port 10443 -// -// The values for this test are obtained by building and running in client mode: -// % go test -test.run "TestRunClient" -connect -ciphersuites=0xc009 -// The recorded bytes are written to stdout. -// -// The server private key is: -// -// -----BEGIN EC PARAMETERS----- -// BgUrgQQAIw== -// -----END EC PARAMETERS----- -// -----BEGIN EC PRIVATE KEY----- -// MIHcAgEBBEIBmIPpCa0Kyeo9M/nq5mHxeFIGlw+MqakWcvHu3Keo7xK9ZWG7JG3a -// XfS01efjqSZJvF2DoL+Sly4A5iBn0Me9mdegBwYFK4EEACOhgYkDgYYABADEoe2+ -// mPkLSHM2fsMWVhEi8j1TwztNIT3Na3Xm9rDcmt8mwbyyh/ByMnyzZC8ckLzqaCMQ -// fv7jJcBIOmngKG3TNwDvBGLdDaCccGKD2IHTZDGqnpcxvZawaMCbI952ZD8aXH/p -// Eg5YWLZfcN2b2OrV1/XVzLm2nzBmW2aaIOIn5b/+Ow== -// -----END EC PRIVATE KEY----- -// -// and certificate is: -// -// -----BEGIN CERTIFICATE----- -// MIICADCCAWICCQC4vy1HoNLr9DAJBgcqhkjOPQQBMEUxCzAJBgNVBAYTAkFVMRMw -// EQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0 -// eSBMdGQwHhcNMTIxMTIyMTUwNjMyWhcNMjIxMTIwMTUwNjMyWjBFMQswCQYDVQQG -// EwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lk -// Z2l0cyBQdHkgTHRkMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQAxKHtvpj5C0hz -// Nn7DFlYRIvI9U8M7TSE9zWt15vaw3JrfJsG8sofwcjJ8s2QvHJC86mgjEH7+4yXA -// SDpp4Cht0zcA7wRi3Q2gnHBig9iB02Qxqp6XMb2WsGjAmyPedmQ/Glx/6RIOWFi2 -// X3Ddm9jq1df11cy5tp8wZltmmiDiJ+W//jswCQYHKoZIzj0EAQOBjAAwgYgCQgGI -// ok/r4kXFSH0brPXtmJ2uR3DAXhu2L73xtk23YUDTEaLO7gt+kn7/dp3DO36lP876 -// EOJZ7EctfKzaTpcOFaBv0AJCAU38vmcTnC0FDr0/o4wlwTMTgw2UBrvUN3r27HrJ -// hi7d1xFpf4V8Vt77MXgr5Md4Da7Lvp5ONiQxe2oPOZUSB48q -// -----END CERTIFICATE----- -var ecdheECDSAAESClientScript = [][]byte{ - { - 0x16, 0x03, 0x01, 0x00, 0x4a, 0x01, 0x00, 0x00, - 0x46, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xc0, 0x09, - 0x01, 0x00, 0x00, 0x1b, 0x00, 0x05, 0x00, 0x05, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, - 0x08, 0x00, 0x06, 0x00, 0x17, 0x00, 0x18, 0x00, - 0x19, 0x00, 0x0b, 0x00, 0x02, 0x01, 0x00, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x54, 0x02, 0x00, 0x00, - 0x50, 0x03, 0x01, 0x50, 0xd7, 0x19, 0xc9, 0x03, - 0xc2, 0x3a, 0xc6, 0x1f, 0x0a, 0x84, 0x9e, 0xd7, - 0xf4, 0x7e, 0x07, 0x6d, 0xa8, 0xe4, 0xa9, 0x4f, - 0x22, 0x50, 0xa2, 0x19, 0x24, 0x44, 0x42, 0x65, - 0xaa, 0xba, 0x3a, 0x20, 0x90, 0x70, 0xb7, 0xe5, - 0x57, 0xed, 0xb1, 0xb1, 0x43, 0x4b, 0xa1, 0x4e, - 0xee, 0x7a, 0x5b, 0x88, 0xf6, 0xa6, 0x73, 0x3b, - 0xcb, 0xa7, 0xbd, 0x57, 0x50, 0xf2, 0x72, 0x8c, - 0xbc, 0x45, 0x73, 0xaa, 0xc0, 0x09, 0x00, 0x00, - 0x08, 0x00, 0x0b, 0x00, 0x04, 0x03, 0x00, 0x01, - 0x02, 0x16, 0x03, 0x01, 0x02, 0x0e, 0x0b, 0x00, - 0x02, 0x0a, 0x00, 0x02, 0x07, 0x00, 0x02, 0x04, - 0x30, 0x82, 0x02, 0x00, 0x30, 0x82, 0x01, 0x62, - 0x02, 0x09, 0x00, 0xb8, 0xbf, 0x2d, 0x47, 0xa0, - 0xd2, 0xeb, 0xf4, 0x30, 0x09, 0x06, 0x07, 0x2a, - 0x86, 0x48, 0xce, 0x3d, 0x04, 0x01, 0x30, 0x45, - 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, - 0x06, 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, - 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, - 0x53, 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, - 0x74, 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, - 0x55, 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, - 0x64, 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, - 0x79, 0x20, 0x4c, 0x74, 0x64, 0x30, 0x1e, 0x17, - 0x0d, 0x31, 0x32, 0x31, 0x31, 0x32, 0x32, 0x31, - 0x35, 0x30, 0x36, 0x33, 0x32, 0x5a, 0x17, 0x0d, - 0x32, 0x32, 0x31, 0x31, 0x32, 0x30, 0x31, 0x35, - 0x30, 0x36, 0x33, 0x32, 0x5a, 0x30, 0x45, 0x31, - 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, - 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, - 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, - 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, - 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, - 0x20, 0x4c, 0x74, 0x64, 0x30, 0x81, 0x9b, 0x30, - 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, - 0x02, 0x01, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, - 0x23, 0x03, 0x81, 0x86, 0x00, 0x04, 0x00, 0xc4, - 0xa1, 0xed, 0xbe, 0x98, 0xf9, 0x0b, 0x48, 0x73, - 0x36, 0x7e, 0xc3, 0x16, 0x56, 0x11, 0x22, 0xf2, - 0x3d, 0x53, 0xc3, 0x3b, 0x4d, 0x21, 0x3d, 0xcd, - 0x6b, 0x75, 0xe6, 0xf6, 0xb0, 0xdc, 0x9a, 0xdf, - 0x26, 0xc1, 0xbc, 0xb2, 0x87, 0xf0, 0x72, 0x32, - 0x7c, 0xb3, 0x64, 0x2f, 0x1c, 0x90, 0xbc, 0xea, - 0x68, 0x23, 0x10, 0x7e, 0xfe, 0xe3, 0x25, 0xc0, - 0x48, 0x3a, 0x69, 0xe0, 0x28, 0x6d, 0xd3, 0x37, - 0x00, 0xef, 0x04, 0x62, 0xdd, 0x0d, 0xa0, 0x9c, - 0x70, 0x62, 0x83, 0xd8, 0x81, 0xd3, 0x64, 0x31, - 0xaa, 0x9e, 0x97, 0x31, 0xbd, 0x96, 0xb0, 0x68, - 0xc0, 0x9b, 0x23, 0xde, 0x76, 0x64, 0x3f, 0x1a, - 0x5c, 0x7f, 0xe9, 0x12, 0x0e, 0x58, 0x58, 0xb6, - 0x5f, 0x70, 0xdd, 0x9b, 0xd8, 0xea, 0xd5, 0xd7, - 0xf5, 0xd5, 0xcc, 0xb9, 0xb6, 0x9f, 0x30, 0x66, - 0x5b, 0x66, 0x9a, 0x20, 0xe2, 0x27, 0xe5, 0xbf, - 0xfe, 0x3b, 0x30, 0x09, 0x06, 0x07, 0x2a, 0x86, - 0x48, 0xce, 0x3d, 0x04, 0x01, 0x03, 0x81, 0x8c, - 0x00, 0x30, 0x81, 0x88, 0x02, 0x42, 0x01, 0x88, - 0xa2, 0x4f, 0xeb, 0xe2, 0x45, 0xc5, 0x48, 0x7d, - 0x1b, 0xac, 0xf5, 0xed, 0x98, 0x9d, 0xae, 0x47, - 0x70, 0xc0, 0x5e, 0x1b, 0xb6, 0x2f, 0xbd, 0xf1, - 0xb6, 0x4d, 0xb7, 0x61, 0x40, 0xd3, 0x11, 0xa2, - 0xce, 0xee, 0x0b, 0x7e, 0x92, 0x7e, 0xff, 0x76, - 0x9d, 0xc3, 0x3b, 0x7e, 0xa5, 0x3f, 0xce, 0xfa, - 0x10, 0xe2, 0x59, 0xec, 0x47, 0x2d, 0x7c, 0xac, - 0xda, 0x4e, 0x97, 0x0e, 0x15, 0xa0, 0x6f, 0xd0, - 0x02, 0x42, 0x01, 0x4d, 0xfc, 0xbe, 0x67, 0x13, - 0x9c, 0x2d, 0x05, 0x0e, 0xbd, 0x3f, 0xa3, 0x8c, - 0x25, 0xc1, 0x33, 0x13, 0x83, 0x0d, 0x94, 0x06, - 0xbb, 0xd4, 0x37, 0x7a, 0xf6, 0xec, 0x7a, 0xc9, - 0x86, 0x2e, 0xdd, 0xd7, 0x11, 0x69, 0x7f, 0x85, - 0x7c, 0x56, 0xde, 0xfb, 0x31, 0x78, 0x2b, 0xe4, - 0xc7, 0x78, 0x0d, 0xae, 0xcb, 0xbe, 0x9e, 0x4e, - 0x36, 0x24, 0x31, 0x7b, 0x6a, 0x0f, 0x39, 0x95, - 0x12, 0x07, 0x8f, 0x2a, 0x16, 0x03, 0x01, 0x00, - 0xd6, 0x0c, 0x00, 0x00, 0xd2, 0x03, 0x00, 0x17, - 0x41, 0x04, 0x33, 0xed, 0xe1, 0x10, 0x3d, 0xe2, - 0xb0, 0x81, 0x5e, 0x01, 0x1b, 0x00, 0x4a, 0x7d, - 0xdc, 0xc5, 0x78, 0x02, 0xb1, 0x9a, 0x78, 0x92, - 0x34, 0xd9, 0x23, 0xcc, 0x01, 0xfb, 0x0c, 0x49, - 0x1c, 0x4a, 0x59, 0x8a, 0x80, 0x1b, 0x34, 0xf0, - 0xe8, 0x87, 0x1b, 0x7c, 0xfb, 0x72, 0xf5, 0xea, - 0xf9, 0xf3, 0xff, 0xa6, 0x3e, 0x4e, 0xac, 0xbc, - 0xee, 0x14, 0x2b, 0x87, 0xd4, 0x0b, 0xda, 0x19, - 0x60, 0x2b, 0x00, 0x8b, 0x30, 0x81, 0x88, 0x02, - 0x42, 0x01, 0x75, 0x46, 0x4f, 0x97, 0x9f, 0xc5, - 0xf9, 0x4c, 0x38, 0xcf, 0x3b, 0x37, 0x1a, 0x6b, - 0x53, 0xfc, 0x05, 0x73, 0x7d, 0x98, 0x2c, 0x5b, - 0x76, 0xd4, 0x37, 0x1f, 0x50, 0x6d, 0xad, 0xc6, - 0x0f, 0x8f, 0x7b, 0xcc, 0x60, 0x8e, 0x04, 0x00, - 0x21, 0x80, 0xa8, 0xa5, 0x98, 0xf2, 0x42, 0xf2, - 0xc3, 0xf6, 0x44, 0x50, 0xc4, 0x7a, 0xae, 0x6f, - 0x74, 0xa0, 0x7f, 0x07, 0x7a, 0x0b, 0xbb, 0x41, - 0x9e, 0x3c, 0x0b, 0x02, 0x42, 0x01, 0xbe, 0x64, - 0xaa, 0x12, 0x03, 0xfb, 0xd8, 0x4f, 0x93, 0xf9, - 0x92, 0x54, 0x0d, 0x9c, 0x9d, 0x53, 0x88, 0x19, - 0x69, 0x94, 0xfc, 0xd6, 0xf7, 0x60, 0xcf, 0x70, - 0x64, 0x15, 0x1b, 0x02, 0x22, 0x56, 0xb0, 0x2c, - 0xb1, 0x72, 0x4c, 0x9e, 0x7b, 0xf0, 0x53, 0x97, - 0x43, 0xac, 0x11, 0x62, 0xe5, 0x5a, 0xf1, 0x7e, - 0x87, 0x8f, 0x5c, 0x43, 0x1d, 0xae, 0x56, 0x28, - 0xdb, 0x76, 0x15, 0xd8, 0x1c, 0x73, 0xce, 0x16, - 0x03, 0x01, 0x00, 0x04, 0x0e, 0x00, 0x00, 0x00, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x46, 0x10, 0x00, 0x00, - 0x42, 0x41, 0x04, 0x1e, 0x18, 0x37, 0xef, 0x0d, - 0x19, 0x51, 0x88, 0x35, 0x75, 0x71, 0xb5, 0xe5, - 0x54, 0x5b, 0x12, 0x2e, 0x8f, 0x09, 0x67, 0xfd, - 0xa7, 0x24, 0x20, 0x3e, 0xb2, 0x56, 0x1c, 0xce, - 0x97, 0x28, 0x5e, 0xf8, 0x2b, 0x2d, 0x4f, 0x9e, - 0xf1, 0x07, 0x9f, 0x6c, 0x4b, 0x5b, 0x83, 0x56, - 0xe2, 0x32, 0x42, 0xe9, 0x58, 0xb6, 0xd7, 0x49, - 0xa6, 0xb5, 0x68, 0x1a, 0x41, 0x03, 0x56, 0x6b, - 0xdc, 0x5a, 0x89, 0x14, 0x03, 0x01, 0x00, 0x01, - 0x01, 0x16, 0x03, 0x01, 0x00, 0x30, 0x1a, 0x45, - 0x92, 0x3b, 0xac, 0x8d, 0x91, 0x89, 0xd3, 0x2c, - 0xf4, 0x3c, 0x5f, 0x70, 0xf1, 0x79, 0xa5, 0x6a, - 0xcf, 0x97, 0x8f, 0x3f, 0x73, 0x08, 0xca, 0x3f, - 0x55, 0xb0, 0x28, 0xd1, 0x6f, 0xcd, 0x9b, 0xca, - 0xb6, 0xb7, 0xd0, 0xa5, 0x21, 0x5b, 0x08, 0xf8, - 0x42, 0xe2, 0xdf, 0x25, 0x6a, 0x16, - }, - { - 0x14, 0x03, 0x01, 0x00, 0x01, 0x01, 0x16, 0x03, - 0x01, 0x00, 0x30, 0x30, 0x83, 0xb6, 0x51, 0x8a, - 0x85, 0x4a, 0xee, 0xe4, 0xb6, 0xae, 0xf3, 0xc1, - 0xdc, 0xd2, 0x04, 0xb3, 0xd0, 0x25, 0x47, 0x5f, - 0xac, 0x83, 0xa3, 0x7d, 0xcf, 0x47, 0x92, 0xed, - 0x92, 0x6c, 0xd1, 0x6e, 0xfd, 0x63, 0xf5, 0x2d, - 0x89, 0xd8, 0x04, 0x8c, 0x62, 0x71, 0xae, 0x5e, - 0x32, 0x48, 0xf8, - }, - { - 0x17, 0x03, 0x01, 0x00, 0x20, 0xcf, 0x5e, 0xba, - 0xf4, 0x47, 0x32, 0x35, 0x9b, 0x85, 0xdc, 0xb3, - 0xff, 0x77, 0x90, 0xd9, 0x2b, 0xbd, 0x59, 0x2a, - 0x33, 0xe4, 0x6e, 0x9b, 0xfc, 0x1c, 0x73, 0x3f, - 0x5e, 0x1e, 0xe3, 0xa4, 0xc2, 0x17, 0x03, 0x01, - 0x00, 0x20, 0x05, 0xdf, 0x2d, 0x9b, 0x29, 0x7f, - 0x97, 0xcd, 0x49, 0x04, 0x53, 0x22, 0x1a, 0xa1, - 0xa1, 0xe6, 0x38, 0x3a, 0x56, 0x37, 0x1f, 0xd8, - 0x3a, 0x12, 0x2c, 0xf0, 0xeb, 0x61, 0x35, 0x76, - 0xe5, 0xf0, 0x15, 0x03, 0x01, 0x00, 0x20, 0xa5, - 0x56, 0xb5, 0x49, 0x4b, 0xc2, 0xd4, 0x4c, 0xf6, - 0x95, 0x15, 0x7d, 0x41, 0x1d, 0x5c, 0x00, 0x0e, - 0x20, 0xb1, 0x0a, 0xbc, 0xc9, 0x2a, 0x09, 0x17, - 0xb4, 0xaa, 0x1c, 0x79, 0xda, 0x79, 0x27, - }, -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/handshake_messages_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/handshake_messages_test.go deleted file mode 100644 index 4f569eeb13..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/handshake_messages_test.go +++ /dev/null @@ -1,246 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package tls - -import ( - "math/rand" - "reflect" - "testing" - "testing/quick" -) - -var tests = []interface{}{ - &clientHelloMsg{}, - &serverHelloMsg{}, - &finishedMsg{}, - - &certificateMsg{}, - &certificateRequestMsg{}, - &certificateVerifyMsg{}, - &certificateStatusMsg{}, - &clientKeyExchangeMsg{}, - &nextProtoMsg{}, - &newSessionTicketMsg{}, - &sessionState{}, -} - -type testMessage interface { - marshal() []byte - unmarshal([]byte) bool - equal(interface{}) bool -} - -func TestMarshalUnmarshal(t *testing.T) { - rand := rand.New(rand.NewSource(0)) - - for i, iface := range tests { - ty := reflect.ValueOf(iface).Type() - - n := 100 - if testing.Short() { - n = 5 - } - for j := 0; j < n; j++ { - v, ok := quick.Value(ty, rand) - if !ok { - t.Errorf("#%d: failed to create value", i) - break - } - - m1 := v.Interface().(testMessage) - marshaled := m1.marshal() - m2 := iface.(testMessage) - if !m2.unmarshal(marshaled) { - t.Errorf("#%d failed to unmarshal %#v %x", i, m1, marshaled) - break - } - m2.marshal() // to fill any marshal cache in the message - - if !m1.equal(m2) { - t.Errorf("#%d got:%#v want:%#v %x", i, m2, m1, marshaled) - break - } - - if i >= 3 { - // The first three message types (ClientHello, - // ServerHello and Finished) are allowed to - // have parsable prefixes because the extension - // data is optional and the length of the - // Finished varies across versions. - for j := 0; j < len(marshaled); j++ { - if m2.unmarshal(marshaled[0:j]) { - t.Errorf("#%d unmarshaled a prefix of length %d of %#v", i, j, m1) - break - } - } - } - } - } -} - -func TestFuzz(t *testing.T) { - rand := rand.New(rand.NewSource(0)) - for _, iface := range tests { - m := iface.(testMessage) - - for j := 0; j < 1000; j++ { - len := rand.Intn(100) - bytes := randomBytes(len, rand) - // This just looks for crashes due to bounds errors etc. - m.unmarshal(bytes) - } - } -} - -func randomBytes(n int, rand *rand.Rand) []byte { - r := make([]byte, n) - for i := 0; i < n; i++ { - r[i] = byte(rand.Int31()) - } - return r -} - -func randomString(n int, rand *rand.Rand) string { - b := randomBytes(n, rand) - return string(b) -} - -func (*clientHelloMsg) Generate(rand *rand.Rand, size int) reflect.Value { - m := &clientHelloMsg{} - m.vers = uint16(rand.Intn(65536)) - m.random = randomBytes(32, rand) - m.sessionId = randomBytes(rand.Intn(32), rand) - m.cipherSuites = make([]uint16, rand.Intn(63)+1) - for i := 0; i < len(m.cipherSuites); i++ { - m.cipherSuites[i] = uint16(rand.Int31()) - } - m.compressionMethods = randomBytes(rand.Intn(63)+1, rand) - if rand.Intn(10) > 5 { - m.nextProtoNeg = true - } - if rand.Intn(10) > 5 { - m.serverName = randomString(rand.Intn(255), rand) - } - m.ocspStapling = rand.Intn(10) > 5 - m.supportedPoints = randomBytes(rand.Intn(5)+1, rand) - m.supportedCurves = make([]uint16, rand.Intn(5)+1) - for i := range m.supportedCurves { - m.supportedCurves[i] = uint16(rand.Intn(30000)) - } - if rand.Intn(10) > 5 { - m.ticketSupported = true - if rand.Intn(10) > 5 { - m.sessionTicket = randomBytes(rand.Intn(300), rand) - } - } - if rand.Intn(10) > 5 { - m.signatureAndHashes = supportedSKXSignatureAlgorithms - } - - return reflect.ValueOf(m) -} - -func (*serverHelloMsg) Generate(rand *rand.Rand, size int) reflect.Value { - m := &serverHelloMsg{} - m.vers = uint16(rand.Intn(65536)) - m.random = randomBytes(32, rand) - m.sessionId = randomBytes(rand.Intn(32), rand) - m.cipherSuite = uint16(rand.Int31()) - m.compressionMethod = uint8(rand.Intn(256)) - - if rand.Intn(10) > 5 { - m.nextProtoNeg = true - - n := rand.Intn(10) - m.nextProtos = make([]string, n) - for i := 0; i < n; i++ { - m.nextProtos[i] = randomString(20, rand) - } - } - - if rand.Intn(10) > 5 { - m.ocspStapling = true - } - if rand.Intn(10) > 5 { - m.ticketSupported = true - } - - return reflect.ValueOf(m) -} - -func (*certificateMsg) Generate(rand *rand.Rand, size int) reflect.Value { - m := &certificateMsg{} - numCerts := rand.Intn(20) - m.certificates = make([][]byte, numCerts) - for i := 0; i < numCerts; i++ { - m.certificates[i] = randomBytes(rand.Intn(10)+1, rand) - } - return reflect.ValueOf(m) -} - -func (*certificateRequestMsg) Generate(rand *rand.Rand, size int) reflect.Value { - m := &certificateRequestMsg{} - m.certificateTypes = randomBytes(rand.Intn(5)+1, rand) - numCAs := rand.Intn(100) - m.certificateAuthorities = make([][]byte, numCAs) - for i := 0; i < numCAs; i++ { - m.certificateAuthorities[i] = randomBytes(rand.Intn(15)+1, rand) - } - return reflect.ValueOf(m) -} - -func (*certificateVerifyMsg) Generate(rand *rand.Rand, size int) reflect.Value { - m := &certificateVerifyMsg{} - m.signature = randomBytes(rand.Intn(15)+1, rand) - return reflect.ValueOf(m) -} - -func (*certificateStatusMsg) Generate(rand *rand.Rand, size int) reflect.Value { - m := &certificateStatusMsg{} - if rand.Intn(10) > 5 { - m.statusType = statusTypeOCSP - m.response = randomBytes(rand.Intn(10)+1, rand) - } else { - m.statusType = 42 - } - return reflect.ValueOf(m) -} - -func (*clientKeyExchangeMsg) Generate(rand *rand.Rand, size int) reflect.Value { - m := &clientKeyExchangeMsg{} - m.ciphertext = randomBytes(rand.Intn(1000)+1, rand) - return reflect.ValueOf(m) -} - -func (*finishedMsg) Generate(rand *rand.Rand, size int) reflect.Value { - m := &finishedMsg{} - m.verifyData = randomBytes(12, rand) - return reflect.ValueOf(m) -} - -func (*nextProtoMsg) Generate(rand *rand.Rand, size int) reflect.Value { - m := &nextProtoMsg{} - m.proto = randomString(rand.Intn(255), rand) - return reflect.ValueOf(m) -} - -func (*newSessionTicketMsg) Generate(rand *rand.Rand, size int) reflect.Value { - m := &newSessionTicketMsg{} - m.ticket = randomBytes(rand.Intn(4), rand) - return reflect.ValueOf(m) -} - -func (*sessionState) Generate(rand *rand.Rand, size int) reflect.Value { - s := &sessionState{} - s.vers = uint16(rand.Intn(10000)) - s.cipherSuite = uint16(rand.Intn(10000)) - s.masterSecret = randomBytes(rand.Intn(100), rand) - numCerts := rand.Intn(20) - s.certificates = make([][]byte, numCerts) - for i := 0; i < numCerts; i++ { - s.certificates[i] = randomBytes(rand.Intn(10)+1, rand) - } - return reflect.ValueOf(s) -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/handshake_server_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/handshake_server_test.go deleted file mode 100644 index c08eba7f17..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/handshake_server_test.go +++ /dev/null @@ -1,3796 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package tls - -import ( - "bytes" - "crypto/ecdsa" - "crypto/elliptic" - "crypto/rsa" - "crypto/x509" - "encoding/hex" - "encoding/pem" - "flag" - "fmt" - "io" - "log" - "math/big" - "net" - "os" - "strconv" - "strings" - "sync" - "testing" - "time" -) - -type zeroSource struct{} - -func (zeroSource) Read(b []byte) (n int, err error) { - for i := range b { - b[i] = 0 - } - - return len(b), nil -} - -var testConfig *Config - -func init() { - testConfig = new(Config) - testConfig.Time = func() time.Time { return time.Unix(0, 0) } - testConfig.Rand = zeroSource{} - testConfig.Certificates = make([]Certificate, 2) - testConfig.Certificates[0].Certificate = [][]byte{testRSACertificate} - testConfig.Certificates[0].PrivateKey = testRSAPrivateKey - testConfig.Certificates[1].Certificate = [][]byte{testSNICertificate} - testConfig.Certificates[1].PrivateKey = testRSAPrivateKey - testConfig.BuildNameToCertificate() - testConfig.CipherSuites = []uint16{TLS_RSA_WITH_RC4_128_SHA} - testConfig.InsecureSkipVerify = true - testConfig.MinVersion = VersionSSL30 - testConfig.MaxVersion = VersionTLS10 -} - -func testClientHelloFailure(t *testing.T, m handshakeMessage, expected error) { - // Create in-memory network connection, - // send message to server. Should return - // expected error. - c, s := net.Pipe() - go func() { - cli := Client(c, testConfig) - if ch, ok := m.(*clientHelloMsg); ok { - cli.vers = ch.vers - } - cli.writeRecord(recordTypeHandshake, m.marshal()) - c.Close() - }() - err := Server(s, testConfig).Handshake() - s.Close() - if e, ok := err.(*net.OpError); !ok || e.Err != expected { - t.Errorf("Got error: %s; expected: %s", err, expected) - } -} - -func TestSimpleError(t *testing.T) { - testClientHelloFailure(t, &serverHelloDoneMsg{}, alertUnexpectedMessage) -} - -var badProtocolVersions = []uint16{0x0000, 0x0005, 0x0100, 0x0105, 0x0200, 0x0205} - -func TestRejectBadProtocolVersion(t *testing.T) { - for _, v := range badProtocolVersions { - testClientHelloFailure(t, &clientHelloMsg{vers: v}, alertProtocolVersion) - } -} - -func TestNoSuiteOverlap(t *testing.T) { - clientHello := &clientHelloMsg{ - vers: 0x0301, - cipherSuites: []uint16{0xff00}, - compressionMethods: []uint8{0}, - } - testClientHelloFailure(t, clientHello, alertHandshakeFailure) -} - -func TestNoCompressionOverlap(t *testing.T) { - clientHello := &clientHelloMsg{ - vers: 0x0301, - cipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA}, - compressionMethods: []uint8{0xff}, - } - testClientHelloFailure(t, clientHello, alertHandshakeFailure) -} - -func TestTLS12OnlyCipherSuites(t *testing.T) { - // Test that a Server doesn't select a TLS 1.2-only cipher suite when - // the client negotiates TLS 1.1. - var zeros [32]byte - - clientHello := &clientHelloMsg{ - vers: VersionTLS11, - random: zeros[:], - cipherSuites: []uint16{ - // The Server, by default, will use the client's - // preference order. So the GCM cipher suite - // will be selected unless it's excluded because - // of the version in this ClientHello. - TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, - TLS_RSA_WITH_RC4_128_SHA, - }, - compressionMethods: []uint8{compressionNone}, - supportedCurves: []uint16{curveP256, curveP384, curveP521}, - supportedPoints: []uint8{pointFormatUncompressed}, - } - - c, s := net.Pipe() - var reply interface{} - var clientErr error - go func() { - cli := Client(c, testConfig) - cli.vers = clientHello.vers - cli.writeRecord(recordTypeHandshake, clientHello.marshal()) - reply, clientErr = cli.readHandshake() - c.Close() - }() - config := *testConfig - config.CipherSuites = clientHello.cipherSuites - Server(s, &config).Handshake() - s.Close() - if clientErr != nil { - t.Fatal(clientErr) - } - serverHello, ok := reply.(*serverHelloMsg) - if !ok { - t.Fatalf("didn't get ServerHello message in reply. Got %v\n", reply) - } - if s := serverHello.cipherSuite; s != TLS_RSA_WITH_RC4_128_SHA { - t.Fatalf("bad cipher suite from server: %x", s) - } -} - -func TestAlertForwarding(t *testing.T) { - c, s := net.Pipe() - go func() { - Client(c, testConfig).sendAlert(alertUnknownCA) - c.Close() - }() - - err := Server(s, testConfig).Handshake() - s.Close() - if e, ok := err.(*net.OpError); !ok || e.Err != error(alertUnknownCA) { - t.Errorf("Got error: %s; expected: %s", err, error(alertUnknownCA)) - } -} - -func TestClose(t *testing.T) { - c, s := net.Pipe() - go c.Close() - - err := Server(s, testConfig).Handshake() - s.Close() - if err != io.EOF { - t.Errorf("Got error: %s; expected: %s", err, io.EOF) - } -} - -func testHandshake(clientConfig, serverConfig *Config) (state ConnectionState, err error) { - c, s := net.Pipe() - go func() { - cli := Client(c, clientConfig) - cli.Handshake() - c.Close() - }() - server := Server(s, serverConfig) - err = server.Handshake() - if err == nil { - state = server.ConnectionState() - } - s.Close() - return -} - -func TestCipherSuitePreference(t *testing.T) { - serverConfig := &Config{ - CipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_RC4_128_SHA}, - Certificates: testConfig.Certificates, - MaxVersion: VersionTLS11, - } - clientConfig := &Config{ - CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_RC4_128_SHA}, - InsecureSkipVerify: true, - } - state, err := testHandshake(clientConfig, serverConfig) - if err != nil { - t.Fatalf("handshake failed: %s", err) - } - if state.CipherSuite != TLS_RSA_WITH_AES_128_CBC_SHA { - // By default the server should use the client's preference. - t.Fatalf("Client's preference was not used, got %x", state.CipherSuite) - } - - serverConfig.PreferServerCipherSuites = true - state, err = testHandshake(clientConfig, serverConfig) - if err != nil { - t.Fatalf("handshake failed: %s", err) - } - if state.CipherSuite != TLS_RSA_WITH_RC4_128_SHA { - t.Fatalf("Server's preference was not used, got %x", state.CipherSuite) - } -} - -func testServerScript(t *testing.T, name string, serverScript [][]byte, config *Config, peers []*x509.Certificate) { - c, s := net.Pipe() - srv := Server(s, config) - pchan := make(chan []*x509.Certificate, 1) - go func() { - srv.Write([]byte("hello, world\n")) - srv.Close() - s.Close() - st := srv.ConnectionState() - pchan <- st.PeerCertificates - }() - - for i, b := range serverScript { - if i%2 == 0 { - c.Write(b) - continue - } - bb := make([]byte, len(b)) - n, err := io.ReadFull(c, bb) - if err != nil { - t.Fatalf("%s #%d: %s\nRead %d, wanted %d, got %x, wanted %x\n", name, i, err, n, len(bb), bb[:n], b) - } - if !bytes.Equal(b, bb) { - t.Fatalf("%s #%d: mismatch on read: got:%x want:%x", name, i, bb, b) - } - } - c.Close() - - if peers != nil { - gotpeers := <-pchan - if len(peers) == len(gotpeers) { - for i := range peers { - if !peers[i].Equal(gotpeers[i]) { - t.Fatalf("%s: mismatch on peer cert %d", name, i) - } - } - } else { - t.Fatalf("%s: mismatch on peer list length: %d (wanted) != %d (got)", name, len(peers), len(gotpeers)) - } - } -} - -func TestHandshakeServerRSARC4(t *testing.T) { - testServerScript(t, "RSA-RC4", rsaRC4ServerScript, testConfig, nil) -} - -func TestHandshakeServerRSA3DES(t *testing.T) { - des3Config := new(Config) - *des3Config = *testConfig - des3Config.CipherSuites = []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA} - testServerScript(t, "RSA-3DES", rsaDES3ServerScript, des3Config, nil) -} - -func TestHandshakeServerRSAAES(t *testing.T) { - aesConfig := new(Config) - *aesConfig = *testConfig - aesConfig.CipherSuites = []uint16{TLS_RSA_WITH_AES_128_CBC_SHA} - testServerScript(t, "RSA-AES", rsaAESServerScript, aesConfig, nil) -} - -func TestHandshakeServerECDHEECDSAAES(t *testing.T) { - ecdsaConfig := new(Config) - *ecdsaConfig = *testConfig - ecdsaConfig.Certificates = make([]Certificate, 1) - ecdsaConfig.Certificates[0].Certificate = [][]byte{testECDSACertificate} - ecdsaConfig.Certificates[0].PrivateKey = testECDSAPrivateKey - ecdsaConfig.BuildNameToCertificate() - ecdsaConfig.CipherSuites = []uint16{TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA} - testServerScript(t, "ECDHE-ECDSA-AES", ecdheECDSAAESServerScript, ecdsaConfig, nil) -} - -func TestHandshakeServerSSLv3(t *testing.T) { - testServerScript(t, "SSLv3", sslv3ServerScript, testConfig, nil) -} - -// TestHandshakeServerSNI involves a client sending an SNI extension of -// "snitest.com", which happens to match the CN of testSNICertificate. The test -// verifies that the server correctly selects that certificate. -func TestHandshakeServerSNI(t *testing.T) { - testServerScript(t, "SNI", selectCertificateBySNIScript, testConfig, nil) -} - -func TestResumption(t *testing.T) { - testServerScript(t, "IssueTicket", issueSessionTicketTest, testConfig, nil) - testServerScript(t, "Resume", serverResumeTest, testConfig, nil) -} - -func TestTLS12ClientCertServer(t *testing.T) { - config := *testConfig - config.MaxVersion = VersionTLS12 - config.ClientAuth = RequireAnyClientCert - config.CipherSuites = []uint16{TLS_ECDHE_RSA_WITH_RC4_128_SHA} - - testServerScript(t, "TLS12", tls12ServerScript, &config, nil) -} - -type clientauthTest struct { - name string - clientauth ClientAuthType - peers []*x509.Certificate - script [][]byte -} - -func TestClientAuthRSA(t *testing.T) { - for _, cat := range clientauthRSATests { - t.Log("running", cat.name) - cfg := new(Config) - *cfg = *testConfig - cfg.ClientAuth = cat.clientauth - testServerScript(t, cat.name, cat.script, cfg, cat.peers) - } -} - -func TestClientAuthECDSA(t *testing.T) { - for _, cat := range clientauthECDSATests { - t.Log("running", cat.name) - cfg := new(Config) - *cfg = *testConfig - cfg.Certificates = make([]Certificate, 1) - cfg.Certificates[0].Certificate = [][]byte{testECDSACertificate} - cfg.Certificates[0].PrivateKey = testECDSAPrivateKey - cfg.BuildNameToCertificate() - cfg.CipherSuites = []uint16{TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA} - cfg.ClientAuth = cat.clientauth - testServerScript(t, cat.name, cat.script, cfg, cat.peers) - } -} - -// TestCipherSuiteCertPreferance ensures that we select an RSA ciphersuite with -// an RSA certificate and an ECDSA ciphersuite with an ECDSA certificate. -func TestCipherSuiteCertPreferance(t *testing.T) { - var config = *testConfig - config.CipherSuites = []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA} - config.MaxVersion = VersionTLS11 - config.PreferServerCipherSuites = true - testServerScript(t, "CipherSuiteCertPreference", tls11ECDHEAESServerScript, &config, nil) - - config = *testConfig - config.CipherSuites = []uint16{TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA} - config.Certificates = []Certificate{ - Certificate{ - Certificate: [][]byte{testECDSACertificate}, - PrivateKey: testECDSAPrivateKey, - }, - } - config.BuildNameToCertificate() - config.PreferServerCipherSuites = true - testServerScript(t, "CipherSuiteCertPreference2", ecdheECDSAAESServerScript, &config, nil) -} - -func TestTLS11Server(t *testing.T) { - var config = *testConfig - config.CipherSuites = []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA} - config.MaxVersion = VersionTLS11 - testServerScript(t, "TLS11", tls11ECDHEAESServerScript, &config, nil) -} - -func TestAESGCM(t *testing.T) { - var config = *testConfig - config.CipherSuites = []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256} - config.MaxVersion = VersionTLS12 - testServerScript(t, "AES-GCM", aesGCMServerScript, &config, nil) -} - -// recordingConn is a net.Conn that records the traffic that passes through it. -// WriteTo can be used to produce Go code that contains the recorded traffic. -type recordingConn struct { - net.Conn - lock sync.Mutex - flows [][]byte - currentlyReading bool -} - -func (r *recordingConn) Read(b []byte) (n int, err error) { - if n, err = r.Conn.Read(b); n == 0 { - return - } - b = b[:n] - - r.lock.Lock() - defer r.lock.Unlock() - - if l := len(r.flows); l == 0 || !r.currentlyReading { - buf := make([]byte, len(b)) - copy(buf, b) - r.flows = append(r.flows, buf) - } else { - r.flows[l-1] = append(r.flows[l-1], b[:n]...) - } - r.currentlyReading = true - return -} - -func (r *recordingConn) Write(b []byte) (n int, err error) { - if n, err = r.Conn.Write(b); n == 0 { - return - } - b = b[:n] - - r.lock.Lock() - defer r.lock.Unlock() - - if l := len(r.flows); l == 0 || r.currentlyReading { - buf := make([]byte, len(b)) - copy(buf, b) - r.flows = append(r.flows, buf) - } else { - r.flows[l-1] = append(r.flows[l-1], b[:n]...) - } - r.currentlyReading = false - return -} - -// WriteTo writes Go source code to w that contains the recorded traffic. -func (r *recordingConn) WriteTo(w io.Writer) { - fmt.Fprintf(w, "var changeMe = [][]byte {\n") - for _, buf := range r.flows { - fmt.Fprintf(w, "\t{") - for i, b := range buf { - if i%8 == 0 { - fmt.Fprintf(w, "\n\t\t") - } - fmt.Fprintf(w, "0x%02x, ", b) - } - fmt.Fprintf(w, "\n\t},\n") - } - fmt.Fprintf(w, "}\n") -} - -var serve = flag.Bool("serve", false, "run a TLS server on :10443") -var testCipherSuites = flag.String("ciphersuites", - "0x"+strconv.FormatInt(int64(TLS_RSA_WITH_RC4_128_SHA), 16), - "cipher suites to accept in serving mode") -var testMinVersion = flag.String("minversion", - "0x"+strconv.FormatInt(int64(VersionSSL30), 16), - "minimum version to negotiate") -var testMaxVersion = flag.String("maxversion", - "0x"+strconv.FormatInt(int64(VersionTLS10), 16), - "maximum version to negotiate") -var testClientAuth = flag.Int("clientauth", 0, "value for tls.Config.ClientAuth") - -func GetTestConfig() *Config { - var config = *testConfig - - minVersion, err := strconv.ParseUint(*testMinVersion, 0, 64) - if err != nil { - panic(err) - } - config.MinVersion = uint16(minVersion) - maxVersion, err := strconv.ParseUint(*testMaxVersion, 0, 64) - if err != nil { - panic(err) - } - config.MaxVersion = uint16(maxVersion) - - suites := strings.Split(*testCipherSuites, ",") - config.CipherSuites = make([]uint16, len(suites)) - for i := range suites { - suite, err := strconv.ParseUint(suites[i], 0, 64) - if err != nil { - panic(err) - } - config.CipherSuites[i] = uint16(suite) - } - - ecdsa := false - for _, suite := range config.CipherSuites { - switch suite { - case TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, - TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA: - ecdsa = true - } - } - if ecdsa { - config.Certificates = nil - if !*connect { - config.Certificates = make([]Certificate, 1) - config.Certificates[0].Certificate = [][]byte{testECDSACertificate} - config.Certificates[0].PrivateKey = testECDSAPrivateKey - } - config.BuildNameToCertificate() - } - - config.ClientAuth = ClientAuthType(*testClientAuth) - return &config -} - -func TestRunServer(t *testing.T) { - if !*serve { - return - } - - config := GetTestConfig() - - const addr = ":10443" - l, err := net.Listen("tcp", addr) - if err != nil { - t.Fatal(err) - } - log.Printf("Now listening for connections on %s", addr) - - for { - tcpConn, err := l.Accept() - if err != nil { - log.Printf("error accepting connection: %s", err) - break - } - - record := &recordingConn{ - Conn: tcpConn, - } - - conn := Server(record, config) - if err := conn.Handshake(); err != nil { - log.Printf("error from TLS handshake: %s", err) - break - } - - _, err = conn.Write([]byte("hello, world\n")) - if err != nil { - log.Printf("error from Write: %s", err) - continue - } - - conn.Close() - - record.WriteTo(os.Stdout) - } -} - -func bigFromString(s string) *big.Int { - ret := new(big.Int) - ret.SetString(s, 10) - return ret -} - -func fromHex(s string) []byte { - b, _ := hex.DecodeString(s) - return b -} - -var testRSACertificate = fromHex("308202b030820219a00302010202090085b0bba48a7fb8ca300d06092a864886f70d01010505003045310b3009060355040613024155311330110603550408130a536f6d652d53746174653121301f060355040a1318496e7465726e6574205769646769747320507479204c7464301e170d3130303432343039303933385a170d3131303432343039303933385a3045310b3009060355040613024155311330110603550408130a536f6d652d53746174653121301f060355040a1318496e7465726e6574205769646769747320507479204c746430819f300d06092a864886f70d010101050003818d0030818902818100bb79d6f517b5e5bf4610d0dc69bee62b07435ad0032d8a7a4385b71452e7a5654c2c78b8238cb5b482e5de1f953b7e62a52ca533d6fe125c7a56fcf506bffa587b263fb5cd04d3d0c921964ac7f4549f5abfef427100fe1899077f7e887d7df10439c4a22edb51c97ce3c04c3b326601cfafb11db8719a1ddbdb896baeda2d790203010001a381a73081a4301d0603551d0e04160414b1ade2855acfcb28db69ce2369ded3268e18883930750603551d23046e306c8014b1ade2855acfcb28db69ce2369ded3268e188839a149a4473045310b3009060355040613024155311330110603550408130a536f6d652d53746174653121301f060355040a1318496e7465726e6574205769646769747320507479204c746482090085b0bba48a7fb8ca300c0603551d13040530030101ff300d06092a864886f70d010105050003818100086c4524c76bb159ab0c52ccf2b014d7879d7a6475b55a9566e4c52b8eae12661feb4f38b36e60d392fdf74108b52513b1187a24fb301dbaed98b917ece7d73159db95d31d78ea50565cd5825a2d5a5f33c4b6d8c97590968c0f5298b5cd981f89205ff2a01ca31b9694dda9fd57e970e8266d71999b266e3850296c90a7bdd9") - -var testECDSACertificate = fromHex("3082020030820162020900b8bf2d47a0d2ebf4300906072a8648ce3d04013045310b3009060355040613024155311330110603550408130a536f6d652d53746174653121301f060355040a1318496e7465726e6574205769646769747320507479204c7464301e170d3132313132323135303633325a170d3232313132303135303633325a3045310b3009060355040613024155311330110603550408130a536f6d652d53746174653121301f060355040a1318496e7465726e6574205769646769747320507479204c746430819b301006072a8648ce3d020106052b81040023038186000400c4a1edbe98f90b4873367ec316561122f23d53c33b4d213dcd6b75e6f6b0dc9adf26c1bcb287f072327cb3642f1c90bcea6823107efee325c0483a69e0286dd33700ef0462dd0da09c706283d881d36431aa9e9731bd96b068c09b23de76643f1a5c7fe9120e5858b65f70dd9bd8ead5d7f5d5ccb9b69f30665b669a20e227e5bffe3b300906072a8648ce3d040103818c0030818802420188a24febe245c5487d1bacf5ed989dae4770c05e1bb62fbdf1b64db76140d311a2ceee0b7e927eff769dc33b7ea53fcefa10e259ec472d7cacda4e970e15a06fd00242014dfcbe67139c2d050ebd3fa38c25c13313830d9406bbd4377af6ec7ac9862eddd711697f857c56defb31782be4c7780daecbbe9e4e3624317b6a0f399512078f2a") - -var testSNICertificate = fromHex("308201f23082015da003020102020100300b06092a864886f70d01010530283110300e060355040a130741636d6520436f311430120603550403130b736e69746573742e636f6d301e170d3132303431313137343033355a170d3133303431313137343533355a30283110300e060355040a130741636d6520436f311430120603550403130b736e69746573742e636f6d30819d300b06092a864886f70d01010103818d0030818902818100bb79d6f517b5e5bf4610d0dc69bee62b07435ad0032d8a7a4385b71452e7a5654c2c78b8238cb5b482e5de1f953b7e62a52ca533d6fe125c7a56fcf506bffa587b263fb5cd04d3d0c921964ac7f4549f5abfef427100fe1899077f7e887d7df10439c4a22edb51c97ce3c04c3b326601cfafb11db8719a1ddbdb896baeda2d790203010001a3323030300e0603551d0f0101ff0404030200a0300d0603551d0e0406040401020304300f0603551d2304083006800401020304300b06092a864886f70d0101050381810089c6455f1c1f5ef8eb1ab174ee2439059f5c4259bb1a8d86cdb1d056f56a717da40e95ab90f59e8deaf627c157995094db0802266eb34fc6842dea8a4b68d9c1389103ab84fb9e1f85d9b5d23ff2312c8670fbb540148245a4ebafe264d90c8a4cf4f85b0fac12ac2fc4a3154bad52462868af96c62c6525d652b6e31845bdcc") - -var testRSAPrivateKey = &rsa.PrivateKey{ - PublicKey: rsa.PublicKey{ - N: bigFromString("131650079503776001033793877885499001334664249354723305978524647182322416328664556247316495448366990052837680518067798333412266673813370895702118944398081598789828837447552603077848001020611640547221687072142537202428102790818451901395596882588063427854225330436740647715202971973145151161964464812406232198521"), - E: 65537, - }, - D: bigFromString("29354450337804273969007277378287027274721892607543397931919078829901848876371746653677097639302788129485893852488285045793268732234230875671682624082413996177431586734171663258657462237320300610850244186316880055243099640544518318093544057213190320837094958164973959123058337475052510833916491060913053867729"), - Primes: []*big.Int{ - bigFromString("11969277782311800166562047708379380720136961987713178380670422671426759650127150688426177829077494755200794297055316163155755835813760102405344560929062149"), - bigFromString("10998999429884441391899182616418192492905073053684657075974935218461686523870125521822756579792315215543092255516093840728890783887287417039645833477273829"), - }, -} - -var testECDSAPrivateKey = &ecdsa.PrivateKey{ - PublicKey: ecdsa.PublicKey{ - Curve: &elliptic.CurveParams{ - P: bigFromString("6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151"), - N: bigFromString("6864797660130609714981900799081393217269435300143305409394463459185543183397655394245057746333217197532963996371363321113864768612440380340372808892707005449"), - B: bigFromString("1093849038073734274511112390766805569936207598951683748994586394495953116150735016013708737573759623248592132296706313309438452531591012912142327488478985984"), - Gx: bigFromString("2661740802050217063228768716723360960729859168756973147706671368418802944996427808491545080627771902352094241225065558662157113545570916814161637315895999846"), - Gy: bigFromString("3757180025770020463545507224491183603594455134769762486694567779615544477440556316691234405012945539562144444537289428522585666729196580810124344277578376784"), - BitSize: 521, - }, - X: bigFromString("2636411247892461147287360222306590634450676461695221912739908880441342231985950069527906976759812296359387337367668045707086543273113073382714101597903639351"), - Y: bigFromString("3204695818431246682253994090650952614555094516658732116404513121125038617915183037601737180082382202488628239201196033284060130040574800684774115478859677243"), - }, - D: bigFromString("5477294338614160138026852784385529180817726002953041720191098180813046231640184669647735805135001309477695746518160084669446643325196003346204701381388769751"), -} - -func loadPEMCert(in string) *x509.Certificate { - block, _ := pem.Decode([]byte(in)) - if block.Type == "CERTIFICATE" && len(block.Headers) == 0 { - cert, err := x509.ParseCertificate(block.Bytes) - if err == nil { - return cert - } - panic("error parsing cert") - } - panic("error parsing PEM") -} - -// Script of interaction with gnutls implementation. -// The values for this test are obtained by building and running in server mode: -// % go test -test.run "TestRunServer" -serve -// The recorded bytes are written to stdout. -var rsaRC4ServerScript = [][]byte{ - { - 0x16, 0x03, 0x01, 0x00, 0x54, 0x01, 0x00, 0x00, - 0x50, 0x03, 0x01, 0x50, 0x77, 0x3d, 0xbd, 0x32, - 0x13, 0xd7, 0xea, 0x33, 0x65, 0x02, 0xb8, 0x70, - 0xb7, 0x84, 0xc4, 0x05, 0x1f, 0xa4, 0x24, 0xc4, - 0x91, 0x69, 0x04, 0x32, 0x96, 0xfe, 0x5b, 0x49, - 0x71, 0x60, 0x9a, 0x00, 0x00, 0x28, 0x00, 0x39, - 0x00, 0x38, 0x00, 0x35, 0x00, 0x16, 0x00, 0x13, - 0x00, 0x0a, 0x00, 0x33, 0x00, 0x32, 0x00, 0x2f, - 0x00, 0x05, 0x00, 0x04, 0x00, 0x15, 0x00, 0x12, - 0x00, 0x09, 0x00, 0x14, 0x00, 0x11, 0x00, 0x08, - 0x00, 0x06, 0x00, 0x03, 0x00, 0xff, 0x02, 0x01, - 0x00, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x2a, 0x02, 0x00, 0x00, - 0x26, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x16, - 0x03, 0x01, 0x02, 0xbe, 0x0b, 0x00, 0x02, 0xba, - 0x00, 0x02, 0xb7, 0x00, 0x02, 0xb4, 0x30, 0x82, - 0x02, 0xb0, 0x30, 0x82, 0x02, 0x19, 0xa0, 0x03, - 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0x85, 0xb0, - 0xbb, 0xa4, 0x8a, 0x7f, 0xb8, 0xca, 0x30, 0x0d, - 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, - 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x45, 0x31, - 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, - 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, - 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, - 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, - 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, - 0x20, 0x4c, 0x74, 0x64, 0x30, 0x1e, 0x17, 0x0d, - 0x31, 0x30, 0x30, 0x34, 0x32, 0x34, 0x30, 0x39, - 0x30, 0x39, 0x33, 0x38, 0x5a, 0x17, 0x0d, 0x31, - 0x31, 0x30, 0x34, 0x32, 0x34, 0x30, 0x39, 0x30, - 0x39, 0x33, 0x38, 0x5a, 0x30, 0x45, 0x31, 0x0b, - 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, - 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, - 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, - 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, - 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, - 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, - 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, - 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, - 0x4c, 0x74, 0x64, 0x30, 0x81, 0x9f, 0x30, 0x0d, - 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, - 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, - 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, - 0xbb, 0x79, 0xd6, 0xf5, 0x17, 0xb5, 0xe5, 0xbf, - 0x46, 0x10, 0xd0, 0xdc, 0x69, 0xbe, 0xe6, 0x2b, - 0x07, 0x43, 0x5a, 0xd0, 0x03, 0x2d, 0x8a, 0x7a, - 0x43, 0x85, 0xb7, 0x14, 0x52, 0xe7, 0xa5, 0x65, - 0x4c, 0x2c, 0x78, 0xb8, 0x23, 0x8c, 0xb5, 0xb4, - 0x82, 0xe5, 0xde, 0x1f, 0x95, 0x3b, 0x7e, 0x62, - 0xa5, 0x2c, 0xa5, 0x33, 0xd6, 0xfe, 0x12, 0x5c, - 0x7a, 0x56, 0xfc, 0xf5, 0x06, 0xbf, 0xfa, 0x58, - 0x7b, 0x26, 0x3f, 0xb5, 0xcd, 0x04, 0xd3, 0xd0, - 0xc9, 0x21, 0x96, 0x4a, 0xc7, 0xf4, 0x54, 0x9f, - 0x5a, 0xbf, 0xef, 0x42, 0x71, 0x00, 0xfe, 0x18, - 0x99, 0x07, 0x7f, 0x7e, 0x88, 0x7d, 0x7d, 0xf1, - 0x04, 0x39, 0xc4, 0xa2, 0x2e, 0xdb, 0x51, 0xc9, - 0x7c, 0xe3, 0xc0, 0x4c, 0x3b, 0x32, 0x66, 0x01, - 0xcf, 0xaf, 0xb1, 0x1d, 0xb8, 0x71, 0x9a, 0x1d, - 0xdb, 0xdb, 0x89, 0x6b, 0xae, 0xda, 0x2d, 0x79, - 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x81, 0xa7, - 0x30, 0x81, 0xa4, 0x30, 0x1d, 0x06, 0x03, 0x55, - 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xb1, 0xad, - 0xe2, 0x85, 0x5a, 0xcf, 0xcb, 0x28, 0xdb, 0x69, - 0xce, 0x23, 0x69, 0xde, 0xd3, 0x26, 0x8e, 0x18, - 0x88, 0x39, 0x30, 0x75, 0x06, 0x03, 0x55, 0x1d, - 0x23, 0x04, 0x6e, 0x30, 0x6c, 0x80, 0x14, 0xb1, - 0xad, 0xe2, 0x85, 0x5a, 0xcf, 0xcb, 0x28, 0xdb, - 0x69, 0xce, 0x23, 0x69, 0xde, 0xd3, 0x26, 0x8e, - 0x18, 0x88, 0x39, 0xa1, 0x49, 0xa4, 0x47, 0x30, - 0x45, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, - 0x04, 0x06, 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, - 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, - 0x0a, 0x53, 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, - 0x61, 0x74, 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, - 0x03, 0x55, 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, - 0x69, 0x64, 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, - 0x74, 0x79, 0x20, 0x4c, 0x74, 0x64, 0x82, 0x09, - 0x00, 0x85, 0xb0, 0xbb, 0xa4, 0x8a, 0x7f, 0xb8, - 0xca, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, - 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, - 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, - 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x81, - 0x81, 0x00, 0x08, 0x6c, 0x45, 0x24, 0xc7, 0x6b, - 0xb1, 0x59, 0xab, 0x0c, 0x52, 0xcc, 0xf2, 0xb0, - 0x14, 0xd7, 0x87, 0x9d, 0x7a, 0x64, 0x75, 0xb5, - 0x5a, 0x95, 0x66, 0xe4, 0xc5, 0x2b, 0x8e, 0xae, - 0x12, 0x66, 0x1f, 0xeb, 0x4f, 0x38, 0xb3, 0x6e, - 0x60, 0xd3, 0x92, 0xfd, 0xf7, 0x41, 0x08, 0xb5, - 0x25, 0x13, 0xb1, 0x18, 0x7a, 0x24, 0xfb, 0x30, - 0x1d, 0xba, 0xed, 0x98, 0xb9, 0x17, 0xec, 0xe7, - 0xd7, 0x31, 0x59, 0xdb, 0x95, 0xd3, 0x1d, 0x78, - 0xea, 0x50, 0x56, 0x5c, 0xd5, 0x82, 0x5a, 0x2d, - 0x5a, 0x5f, 0x33, 0xc4, 0xb6, 0xd8, 0xc9, 0x75, - 0x90, 0x96, 0x8c, 0x0f, 0x52, 0x98, 0xb5, 0xcd, - 0x98, 0x1f, 0x89, 0x20, 0x5f, 0xf2, 0xa0, 0x1c, - 0xa3, 0x1b, 0x96, 0x94, 0xdd, 0xa9, 0xfd, 0x57, - 0xe9, 0x70, 0xe8, 0x26, 0x6d, 0x71, 0x99, 0x9b, - 0x26, 0x6e, 0x38, 0x50, 0x29, 0x6c, 0x90, 0xa7, - 0xbd, 0xd9, 0x16, 0x03, 0x01, 0x00, 0x04, 0x0e, - 0x00, 0x00, 0x00, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x86, 0x10, 0x00, 0x00, - 0x82, 0x00, 0x80, 0x2d, 0x09, 0x7c, 0x7f, 0xfc, - 0x84, 0xce, 0xb3, 0x30, 0x9b, 0xf9, 0xb7, 0xc8, - 0xc3, 0xff, 0xee, 0x6f, 0x20, 0x8a, 0xf4, 0xfb, - 0x86, 0x55, 0x1f, 0x6a, 0xb4, 0x81, 0x50, 0x3a, - 0x46, 0x1b, 0xd3, 0xca, 0x4b, 0x11, 0xff, 0xef, - 0x02, 0xbc, 0x18, 0xb8, 0x4a, 0x7d, 0x43, 0x23, - 0x96, 0x92, 0x27, 0x7c, 0xca, 0xcf, 0xe6, 0x91, - 0xe8, 0x14, 0x97, 0x68, 0xb4, 0xe5, 0xc0, 0xc9, - 0x23, 0xdd, 0x54, 0x07, 0xa6, 0x2e, 0x8c, 0x98, - 0xfc, 0xc6, 0x8c, 0x04, 0x6b, 0x1b, 0x5f, 0xd5, - 0x3d, 0x8b, 0x6c, 0x55, 0x4f, 0x7a, 0xe6, 0x6c, - 0x74, 0x2c, 0x1e, 0x34, 0xdb, 0xfb, 0x00, 0xb1, - 0x4e, 0x10, 0x21, 0x16, 0xe0, 0x3e, 0xc5, 0x64, - 0x84, 0x28, 0x2b, 0x2b, 0x29, 0x47, 0x51, 0x34, - 0x76, 0x15, 0x20, 0x71, 0x0b, 0x30, 0xa1, 0x85, - 0xd5, 0x15, 0x18, 0x14, 0x64, 0x4b, 0x40, 0x7c, - 0x4f, 0xb3, 0x7b, 0x14, 0x03, 0x01, 0x00, 0x01, - 0x01, 0x16, 0x03, 0x01, 0x00, 0x24, 0xab, 0xee, - 0xf5, 0x97, 0x5f, 0xc6, 0x78, 0xf3, 0xc6, 0x83, - 0x5b, 0x55, 0x4f, 0xcb, 0x45, 0x3f, 0xfa, 0xf7, - 0x05, 0x02, 0xc2, 0x63, 0x87, 0x18, 0xb5, 0x9a, - 0x62, 0xe2, 0x3f, 0x88, 0x5a, 0x60, 0x61, 0x72, - 0xfa, 0x9c, - }, - { - 0x14, 0x03, 0x01, 0x00, 0x01, 0x01, 0x16, 0x03, - 0x01, 0x00, 0x24, 0x72, 0xa4, 0xe4, 0xaa, 0xd2, - 0xc4, 0x39, 0x7e, 0x2a, 0xc1, 0x6f, 0x34, 0x42, - 0x28, 0xcb, 0x9d, 0x7a, 0x09, 0xca, 0x96, 0xad, - 0x0e, 0x11, 0x51, 0x8a, 0x06, 0xb0, 0xe9, 0xca, - 0xeb, 0xce, 0xe2, 0xd5, 0x2e, 0xc1, 0x8d, 0x17, - 0x03, 0x01, 0x00, 0x21, 0x2e, 0x61, 0x86, 0x17, - 0xdb, 0xa6, 0x30, 0xe2, 0x62, 0x06, 0x2a, 0x8b, - 0x75, 0x2c, 0x2d, 0xcf, 0xf5, 0x01, 0x11, 0x52, - 0x81, 0x38, 0xcf, 0xd5, 0xf7, 0xdc, 0x52, 0x31, - 0x1f, 0x97, 0x43, 0xc2, 0x71, 0x15, 0x03, 0x01, - 0x00, 0x16, 0xe0, 0x21, 0xfe, 0x36, 0x2e, 0x68, - 0x2c, 0xf1, 0xbe, 0x04, 0xec, 0xd4, 0xc6, 0xdd, - 0xac, 0x6f, 0x4c, 0x85, 0x32, 0x3f, 0x87, 0x1b, - }, -} - -var rsaDES3ServerScript = [][]byte{ - { - 0x16, 0x03, 0x00, 0x00, 0xc5, 0x01, 0x00, 0x00, - 0xc1, 0x03, 0x03, 0x50, 0xae, 0x5d, 0x38, 0xec, - 0xaa, 0x2f, 0x41, 0xf9, 0xd2, 0x7b, 0xa1, 0xfd, - 0x0f, 0xff, 0x4e, 0x54, 0x0e, 0x15, 0x57, 0xaf, - 0x2c, 0x91, 0xb5, 0x35, 0x5b, 0x2e, 0xb0, 0xec, - 0x20, 0xe5, 0xd2, 0x00, 0x00, 0x50, 0xc0, 0x09, - 0xc0, 0x23, 0xc0, 0x2b, 0xc0, 0x0a, 0xc0, 0x24, - 0xc0, 0x2c, 0xc0, 0x08, 0xc0, 0x13, 0xc0, 0x27, - 0xc0, 0x2f, 0xc0, 0x14, 0xc0, 0x30, 0xc0, 0x12, - 0x00, 0x33, 0x00, 0x67, 0x00, 0x45, 0x00, 0x9e, - 0x00, 0x39, 0x00, 0x6b, 0x00, 0x88, 0x00, 0x16, - 0x00, 0x32, 0x00, 0x40, 0x00, 0x44, 0x00, 0xa2, - 0x00, 0x38, 0x00, 0x6a, 0x00, 0x87, 0x00, 0x13, - 0x00, 0x66, 0x00, 0x2f, 0x00, 0x3c, 0x00, 0x41, - 0x00, 0x9c, 0x00, 0x35, 0x00, 0x3d, 0x00, 0x84, - 0x00, 0x0a, 0x00, 0x05, 0x00, 0x04, 0x01, 0x00, - 0x00, 0x48, 0x00, 0x05, 0x00, 0x05, 0x01, 0x00, - 0x00, 0x00, 0x00, 0xff, 0x01, 0x00, 0x01, 0x00, - 0x00, 0x23, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x0c, - 0x00, 0x0a, 0x00, 0x13, 0x00, 0x15, 0x00, 0x17, - 0x00, 0x18, 0x00, 0x19, 0x00, 0x0b, 0x00, 0x02, - 0x01, 0x00, 0x00, 0x0d, 0x00, 0x1c, 0x00, 0x1a, - 0x04, 0x01, 0x04, 0x02, 0x04, 0x03, 0x05, 0x01, - 0x05, 0x03, 0x06, 0x01, 0x06, 0x03, 0x03, 0x01, - 0x03, 0x02, 0x03, 0x03, 0x02, 0x01, 0x02, 0x02, - 0x02, 0x03, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x30, 0x02, 0x00, 0x00, - 0x2c, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, - 0x04, 0x00, 0x23, 0x00, 0x00, 0x16, 0x03, 0x01, - 0x02, 0xbe, 0x0b, 0x00, 0x02, 0xba, 0x00, 0x02, - 0xb7, 0x00, 0x02, 0xb4, 0x30, 0x82, 0x02, 0xb0, - 0x30, 0x82, 0x02, 0x19, 0xa0, 0x03, 0x02, 0x01, - 0x02, 0x02, 0x09, 0x00, 0x85, 0xb0, 0xbb, 0xa4, - 0x8a, 0x7f, 0xb8, 0xca, 0x30, 0x0d, 0x06, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x05, 0x05, 0x00, 0x30, 0x45, 0x31, 0x0b, 0x30, - 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, - 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, - 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, 0x6d, - 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, - 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, - 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, - 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, - 0x74, 0x64, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x30, - 0x30, 0x34, 0x32, 0x34, 0x30, 0x39, 0x30, 0x39, - 0x33, 0x38, 0x5a, 0x17, 0x0d, 0x31, 0x31, 0x30, - 0x34, 0x32, 0x34, 0x30, 0x39, 0x30, 0x39, 0x33, - 0x38, 0x5a, 0x30, 0x45, 0x31, 0x0b, 0x30, 0x09, - 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x41, - 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, - 0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, 0x6d, 0x65, - 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, 0x21, - 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, - 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, - 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, 0x74, - 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, 0x74, - 0x64, 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, - 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xbb, 0x79, - 0xd6, 0xf5, 0x17, 0xb5, 0xe5, 0xbf, 0x46, 0x10, - 0xd0, 0xdc, 0x69, 0xbe, 0xe6, 0x2b, 0x07, 0x43, - 0x5a, 0xd0, 0x03, 0x2d, 0x8a, 0x7a, 0x43, 0x85, - 0xb7, 0x14, 0x52, 0xe7, 0xa5, 0x65, 0x4c, 0x2c, - 0x78, 0xb8, 0x23, 0x8c, 0xb5, 0xb4, 0x82, 0xe5, - 0xde, 0x1f, 0x95, 0x3b, 0x7e, 0x62, 0xa5, 0x2c, - 0xa5, 0x33, 0xd6, 0xfe, 0x12, 0x5c, 0x7a, 0x56, - 0xfc, 0xf5, 0x06, 0xbf, 0xfa, 0x58, 0x7b, 0x26, - 0x3f, 0xb5, 0xcd, 0x04, 0xd3, 0xd0, 0xc9, 0x21, - 0x96, 0x4a, 0xc7, 0xf4, 0x54, 0x9f, 0x5a, 0xbf, - 0xef, 0x42, 0x71, 0x00, 0xfe, 0x18, 0x99, 0x07, - 0x7f, 0x7e, 0x88, 0x7d, 0x7d, 0xf1, 0x04, 0x39, - 0xc4, 0xa2, 0x2e, 0xdb, 0x51, 0xc9, 0x7c, 0xe3, - 0xc0, 0x4c, 0x3b, 0x32, 0x66, 0x01, 0xcf, 0xaf, - 0xb1, 0x1d, 0xb8, 0x71, 0x9a, 0x1d, 0xdb, 0xdb, - 0x89, 0x6b, 0xae, 0xda, 0x2d, 0x79, 0x02, 0x03, - 0x01, 0x00, 0x01, 0xa3, 0x81, 0xa7, 0x30, 0x81, - 0xa4, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, - 0x04, 0x16, 0x04, 0x14, 0xb1, 0xad, 0xe2, 0x85, - 0x5a, 0xcf, 0xcb, 0x28, 0xdb, 0x69, 0xce, 0x23, - 0x69, 0xde, 0xd3, 0x26, 0x8e, 0x18, 0x88, 0x39, - 0x30, 0x75, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, - 0x6e, 0x30, 0x6c, 0x80, 0x14, 0xb1, 0xad, 0xe2, - 0x85, 0x5a, 0xcf, 0xcb, 0x28, 0xdb, 0x69, 0xce, - 0x23, 0x69, 0xde, 0xd3, 0x26, 0x8e, 0x18, 0x88, - 0x39, 0xa1, 0x49, 0xa4, 0x47, 0x30, 0x45, 0x31, - 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, - 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, - 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, - 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, - 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, - 0x20, 0x4c, 0x74, 0x64, 0x82, 0x09, 0x00, 0x85, - 0xb0, 0xbb, 0xa4, 0x8a, 0x7f, 0xb8, 0xca, 0x30, - 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, - 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, - 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, - 0x01, 0x05, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, - 0x08, 0x6c, 0x45, 0x24, 0xc7, 0x6b, 0xb1, 0x59, - 0xab, 0x0c, 0x52, 0xcc, 0xf2, 0xb0, 0x14, 0xd7, - 0x87, 0x9d, 0x7a, 0x64, 0x75, 0xb5, 0x5a, 0x95, - 0x66, 0xe4, 0xc5, 0x2b, 0x8e, 0xae, 0x12, 0x66, - 0x1f, 0xeb, 0x4f, 0x38, 0xb3, 0x6e, 0x60, 0xd3, - 0x92, 0xfd, 0xf7, 0x41, 0x08, 0xb5, 0x25, 0x13, - 0xb1, 0x18, 0x7a, 0x24, 0xfb, 0x30, 0x1d, 0xba, - 0xed, 0x98, 0xb9, 0x17, 0xec, 0xe7, 0xd7, 0x31, - 0x59, 0xdb, 0x95, 0xd3, 0x1d, 0x78, 0xea, 0x50, - 0x56, 0x5c, 0xd5, 0x82, 0x5a, 0x2d, 0x5a, 0x5f, - 0x33, 0xc4, 0xb6, 0xd8, 0xc9, 0x75, 0x90, 0x96, - 0x8c, 0x0f, 0x52, 0x98, 0xb5, 0xcd, 0x98, 0x1f, - 0x89, 0x20, 0x5f, 0xf2, 0xa0, 0x1c, 0xa3, 0x1b, - 0x96, 0x94, 0xdd, 0xa9, 0xfd, 0x57, 0xe9, 0x70, - 0xe8, 0x26, 0x6d, 0x71, 0x99, 0x9b, 0x26, 0x6e, - 0x38, 0x50, 0x29, 0x6c, 0x90, 0xa7, 0xbd, 0xd9, - 0x16, 0x03, 0x01, 0x00, 0x04, 0x0e, 0x00, 0x00, - 0x00, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x86, 0x10, 0x00, 0x00, - 0x82, 0x00, 0x80, 0x51, 0x04, 0xf1, 0x7a, 0xbf, - 0xe8, 0xa5, 0x86, 0x09, 0xa7, 0xf3, 0xcc, 0x93, - 0x00, 0x10, 0x5b, 0xb8, 0xc1, 0x51, 0x0d, 0x5b, - 0xcd, 0xed, 0x26, 0x01, 0x69, 0x73, 0xf4, 0x05, - 0x8a, 0x6a, 0xc3, 0xb1, 0x9e, 0x84, 0x4e, 0x39, - 0xcf, 0x5e, 0x55, 0xa9, 0x70, 0x19, 0x96, 0x91, - 0xcd, 0x2c, 0x78, 0x3c, 0xa2, 0x6d, 0xb0, 0x49, - 0x86, 0xf6, 0xd1, 0x3a, 0xde, 0x00, 0x4b, 0xa6, - 0x25, 0xbf, 0x85, 0x39, 0xce, 0xb1, 0xcf, 0xbc, - 0x16, 0xc7, 0x66, 0xac, 0xf8, 0xd2, 0x3b, 0xd1, - 0xcc, 0x16, 0xac, 0x63, 0x3c, 0xbe, 0xd9, 0xb6, - 0x6a, 0xe4, 0x13, 0x8a, 0xf4, 0x56, 0x2f, 0x92, - 0x54, 0xd8, 0xf0, 0x84, 0x01, 0x32, 0x1a, 0xa9, - 0x2d, 0xaf, 0x82, 0x0e, 0x00, 0xfa, 0x07, 0x88, - 0xd9, 0x87, 0xe7, 0xdc, 0x9e, 0xe9, 0x72, 0x49, - 0xb8, 0xfa, 0x8c, 0x7b, 0x07, 0x0b, 0x03, 0x7c, - 0x10, 0x8c, 0x8a, 0x14, 0x03, 0x01, 0x00, 0x01, - 0x01, 0x16, 0x03, 0x01, 0x00, 0xa8, 0x61, 0xa4, - 0xf4, 0x5f, 0x8a, 0x1f, 0x5c, 0x92, 0x3f, 0x8c, - 0xdb, 0xd6, 0x10, 0xcd, 0x9e, 0xe7, 0xf0, 0xc4, - 0x3c, 0xb6, 0x1c, 0x9a, 0x56, 0x73, 0x7f, 0xa6, - 0x14, 0x24, 0xcb, 0x96, 0x1f, 0xe0, 0xaf, 0xcd, - 0x3c, 0x66, 0x43, 0xb7, 0x37, 0x65, 0x34, 0x47, - 0xf8, 0x43, 0xf1, 0xcc, 0x15, 0xb8, 0xdc, 0x35, - 0xe0, 0xa4, 0x2d, 0x78, 0x94, 0xe0, 0x02, 0xf3, - 0x76, 0x46, 0xf7, 0x9b, 0x8d, 0x0d, 0x5d, 0x0b, - 0xd3, 0xdd, 0x9a, 0x9e, 0x62, 0x2e, 0xc5, 0x98, - 0x75, 0x63, 0x0c, 0xbf, 0x8e, 0x49, 0x33, 0x23, - 0x7c, 0x00, 0xcf, 0xfb, 0xcf, 0xba, 0x0f, 0x41, - 0x39, 0x89, 0xb9, 0xcc, 0x59, 0xd0, 0x2b, 0xb6, - 0xec, 0x04, 0xe2, 0xc0, 0x52, 0xc7, 0xcf, 0x71, - 0x47, 0xff, 0x70, 0x7e, 0xa9, 0xbd, 0x1c, 0xdd, - 0x17, 0xa5, 0x6c, 0xb7, 0x10, 0x4f, 0x42, 0x18, - 0x37, 0x69, 0xa9, 0xd2, 0xb3, 0x18, 0x84, 0x92, - 0xa7, 0x47, 0x21, 0xf6, 0x95, 0x63, 0x29, 0xd6, - 0xa5, 0xb6, 0xda, 0x65, 0x67, 0x69, 0xc4, 0x26, - 0xac, 0x8b, 0x08, 0x58, 0xdd, 0x3c, 0x31, 0x20, - 0xd5, 0x0c, 0x88, 0x72, 0x18, 0x16, 0x88, 0x1e, - 0x4a, 0x0f, 0xe1, 0xcf, 0x95, 0x24, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x72, 0x04, 0x00, 0x00, - 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, - 0xe8, 0x4b, 0xde, 0xef, 0xba, 0x3e, 0x18, 0x1c, - 0x1e, 0x5e, 0xbc, 0x87, 0xf1, 0x87, 0x8d, 0x72, - 0xe3, 0xbe, 0x0f, 0xdf, 0xfd, 0xd0, 0xb2, 0x89, - 0xf8, 0x05, 0x9a, 0x52, 0x47, 0x77, 0x9e, 0xe8, - 0xb1, 0x1d, 0x18, 0xed, 0x6a, 0x4b, 0x63, 0x1d, - 0xf1, 0x62, 0xd2, 0x65, 0x21, 0x26, 0x73, 0xd4, - 0x35, 0x5b, 0x95, 0x89, 0x12, 0x59, 0x23, 0x8c, - 0xc3, 0xfc, 0xf9, 0x4d, 0x21, 0x79, 0xa0, 0xbd, - 0xff, 0x33, 0xa2, 0x3d, 0x0b, 0x6f, 0x89, 0xc9, - 0x23, 0xe4, 0xe7, 0x9f, 0x1d, 0x98, 0xf6, 0xed, - 0x02, 0x8d, 0xac, 0x1a, 0xf9, 0xcb, 0xa5, 0x14, - 0x03, 0x01, 0x00, 0x01, 0x01, 0x16, 0x03, 0x01, - 0x00, 0x28, 0x91, 0x56, 0x80, 0xe2, 0x6d, 0x51, - 0x88, 0x03, 0xf8, 0x49, 0xe6, 0x6a, 0x5a, 0xfb, - 0x2f, 0x0b, 0xb5, 0xa1, 0x0d, 0x63, 0x83, 0xae, - 0xb9, 0xbc, 0x05, 0xf0, 0x81, 0x00, 0x61, 0x83, - 0x38, 0xda, 0x14, 0xf6, 0xea, 0xd8, 0x78, 0x65, - 0xc7, 0x26, 0x17, 0x03, 0x01, 0x00, 0x18, 0x81, - 0x30, 0x8b, 0x22, 0x5a, 0xd3, 0x7f, 0xc8, 0xf2, - 0x8a, 0x6b, 0xa3, 0xba, 0x4d, 0xe7, 0x6e, 0xd2, - 0xfd, 0xbf, 0xf2, 0xc5, 0x28, 0xa0, 0x62, 0x17, - 0x03, 0x01, 0x00, 0x28, 0x17, 0x83, 0x3c, 0x78, - 0x18, 0xfa, 0x8d, 0x58, 0x5c, 0xaa, 0x05, 0x7d, - 0x67, 0x96, 0x11, 0x60, 0x11, 0xc0, 0x1e, 0x0d, - 0x6a, 0x6e, 0x5f, 0x1d, 0x98, 0x4b, 0xff, 0x82, - 0xee, 0x21, 0x06, 0x29, 0xd3, 0x8b, 0x80, 0x78, - 0x39, 0x05, 0x34, 0x9b, 0x15, 0x03, 0x01, 0x00, - 0x18, 0xa9, 0x38, 0x18, 0x4f, 0x9d, 0x84, 0x75, - 0x88, 0x53, 0xd6, 0x85, 0xc2, 0x15, 0x4b, 0xe3, - 0xe3, 0x35, 0x9a, 0x74, 0xc9, 0x3e, 0x13, 0xc1, - 0x8c, - }, -} - -var rsaAESServerScript = [][]byte{ - { - 0x16, 0x03, 0x00, 0x00, 0xc5, 0x01, 0x00, 0x00, - 0xc1, 0x03, 0x03, 0x50, 0xae, 0x5c, 0xe9, 0x5e, - 0x31, 0x93, 0x82, 0xa5, 0x6f, 0x51, 0x82, 0xc8, - 0x55, 0x4f, 0x1f, 0x2e, 0x90, 0x98, 0x81, 0x13, - 0x27, 0x80, 0x68, 0xb4, 0x2d, 0xba, 0x3a, 0x76, - 0xd8, 0xd7, 0x2c, 0x00, 0x00, 0x50, 0xc0, 0x09, - 0xc0, 0x23, 0xc0, 0x2b, 0xc0, 0x0a, 0xc0, 0x24, - 0xc0, 0x2c, 0xc0, 0x08, 0xc0, 0x13, 0xc0, 0x27, - 0xc0, 0x2f, 0xc0, 0x14, 0xc0, 0x30, 0xc0, 0x12, - 0x00, 0x33, 0x00, 0x67, 0x00, 0x45, 0x00, 0x9e, - 0x00, 0x39, 0x00, 0x6b, 0x00, 0x88, 0x00, 0x16, - 0x00, 0x32, 0x00, 0x40, 0x00, 0x44, 0x00, 0xa2, - 0x00, 0x38, 0x00, 0x6a, 0x00, 0x87, 0x00, 0x13, - 0x00, 0x66, 0x00, 0x2f, 0x00, 0x3c, 0x00, 0x41, - 0x00, 0x9c, 0x00, 0x35, 0x00, 0x3d, 0x00, 0x84, - 0x00, 0x0a, 0x00, 0x05, 0x00, 0x04, 0x01, 0x00, - 0x00, 0x48, 0x00, 0x05, 0x00, 0x05, 0x01, 0x00, - 0x00, 0x00, 0x00, 0xff, 0x01, 0x00, 0x01, 0x00, - 0x00, 0x23, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x0c, - 0x00, 0x0a, 0x00, 0x13, 0x00, 0x15, 0x00, 0x17, - 0x00, 0x18, 0x00, 0x19, 0x00, 0x0b, 0x00, 0x02, - 0x01, 0x00, 0x00, 0x0d, 0x00, 0x1c, 0x00, 0x1a, - 0x04, 0x01, 0x04, 0x02, 0x04, 0x03, 0x05, 0x01, - 0x05, 0x03, 0x06, 0x01, 0x06, 0x03, 0x03, 0x01, - 0x03, 0x02, 0x03, 0x03, 0x02, 0x01, 0x02, 0x02, - 0x02, 0x03, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x30, 0x02, 0x00, 0x00, - 0x2c, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, - 0x04, 0x00, 0x23, 0x00, 0x00, 0x16, 0x03, 0x01, - 0x02, 0xbe, 0x0b, 0x00, 0x02, 0xba, 0x00, 0x02, - 0xb7, 0x00, 0x02, 0xb4, 0x30, 0x82, 0x02, 0xb0, - 0x30, 0x82, 0x02, 0x19, 0xa0, 0x03, 0x02, 0x01, - 0x02, 0x02, 0x09, 0x00, 0x85, 0xb0, 0xbb, 0xa4, - 0x8a, 0x7f, 0xb8, 0xca, 0x30, 0x0d, 0x06, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x05, 0x05, 0x00, 0x30, 0x45, 0x31, 0x0b, 0x30, - 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, - 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, - 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, 0x6d, - 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, - 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, - 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, - 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, - 0x74, 0x64, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x30, - 0x30, 0x34, 0x32, 0x34, 0x30, 0x39, 0x30, 0x39, - 0x33, 0x38, 0x5a, 0x17, 0x0d, 0x31, 0x31, 0x30, - 0x34, 0x32, 0x34, 0x30, 0x39, 0x30, 0x39, 0x33, - 0x38, 0x5a, 0x30, 0x45, 0x31, 0x0b, 0x30, 0x09, - 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x41, - 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, - 0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, 0x6d, 0x65, - 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, 0x21, - 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, - 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, - 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, 0x74, - 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, 0x74, - 0x64, 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, - 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xbb, 0x79, - 0xd6, 0xf5, 0x17, 0xb5, 0xe5, 0xbf, 0x46, 0x10, - 0xd0, 0xdc, 0x69, 0xbe, 0xe6, 0x2b, 0x07, 0x43, - 0x5a, 0xd0, 0x03, 0x2d, 0x8a, 0x7a, 0x43, 0x85, - 0xb7, 0x14, 0x52, 0xe7, 0xa5, 0x65, 0x4c, 0x2c, - 0x78, 0xb8, 0x23, 0x8c, 0xb5, 0xb4, 0x82, 0xe5, - 0xde, 0x1f, 0x95, 0x3b, 0x7e, 0x62, 0xa5, 0x2c, - 0xa5, 0x33, 0xd6, 0xfe, 0x12, 0x5c, 0x7a, 0x56, - 0xfc, 0xf5, 0x06, 0xbf, 0xfa, 0x58, 0x7b, 0x26, - 0x3f, 0xb5, 0xcd, 0x04, 0xd3, 0xd0, 0xc9, 0x21, - 0x96, 0x4a, 0xc7, 0xf4, 0x54, 0x9f, 0x5a, 0xbf, - 0xef, 0x42, 0x71, 0x00, 0xfe, 0x18, 0x99, 0x07, - 0x7f, 0x7e, 0x88, 0x7d, 0x7d, 0xf1, 0x04, 0x39, - 0xc4, 0xa2, 0x2e, 0xdb, 0x51, 0xc9, 0x7c, 0xe3, - 0xc0, 0x4c, 0x3b, 0x32, 0x66, 0x01, 0xcf, 0xaf, - 0xb1, 0x1d, 0xb8, 0x71, 0x9a, 0x1d, 0xdb, 0xdb, - 0x89, 0x6b, 0xae, 0xda, 0x2d, 0x79, 0x02, 0x03, - 0x01, 0x00, 0x01, 0xa3, 0x81, 0xa7, 0x30, 0x81, - 0xa4, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, - 0x04, 0x16, 0x04, 0x14, 0xb1, 0xad, 0xe2, 0x85, - 0x5a, 0xcf, 0xcb, 0x28, 0xdb, 0x69, 0xce, 0x23, - 0x69, 0xde, 0xd3, 0x26, 0x8e, 0x18, 0x88, 0x39, - 0x30, 0x75, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, - 0x6e, 0x30, 0x6c, 0x80, 0x14, 0xb1, 0xad, 0xe2, - 0x85, 0x5a, 0xcf, 0xcb, 0x28, 0xdb, 0x69, 0xce, - 0x23, 0x69, 0xde, 0xd3, 0x26, 0x8e, 0x18, 0x88, - 0x39, 0xa1, 0x49, 0xa4, 0x47, 0x30, 0x45, 0x31, - 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, - 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, - 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, - 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, - 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, - 0x20, 0x4c, 0x74, 0x64, 0x82, 0x09, 0x00, 0x85, - 0xb0, 0xbb, 0xa4, 0x8a, 0x7f, 0xb8, 0xca, 0x30, - 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, - 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, - 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, - 0x01, 0x05, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, - 0x08, 0x6c, 0x45, 0x24, 0xc7, 0x6b, 0xb1, 0x59, - 0xab, 0x0c, 0x52, 0xcc, 0xf2, 0xb0, 0x14, 0xd7, - 0x87, 0x9d, 0x7a, 0x64, 0x75, 0xb5, 0x5a, 0x95, - 0x66, 0xe4, 0xc5, 0x2b, 0x8e, 0xae, 0x12, 0x66, - 0x1f, 0xeb, 0x4f, 0x38, 0xb3, 0x6e, 0x60, 0xd3, - 0x92, 0xfd, 0xf7, 0x41, 0x08, 0xb5, 0x25, 0x13, - 0xb1, 0x18, 0x7a, 0x24, 0xfb, 0x30, 0x1d, 0xba, - 0xed, 0x98, 0xb9, 0x17, 0xec, 0xe7, 0xd7, 0x31, - 0x59, 0xdb, 0x95, 0xd3, 0x1d, 0x78, 0xea, 0x50, - 0x56, 0x5c, 0xd5, 0x82, 0x5a, 0x2d, 0x5a, 0x5f, - 0x33, 0xc4, 0xb6, 0xd8, 0xc9, 0x75, 0x90, 0x96, - 0x8c, 0x0f, 0x52, 0x98, 0xb5, 0xcd, 0x98, 0x1f, - 0x89, 0x20, 0x5f, 0xf2, 0xa0, 0x1c, 0xa3, 0x1b, - 0x96, 0x94, 0xdd, 0xa9, 0xfd, 0x57, 0xe9, 0x70, - 0xe8, 0x26, 0x6d, 0x71, 0x99, 0x9b, 0x26, 0x6e, - 0x38, 0x50, 0x29, 0x6c, 0x90, 0xa7, 0xbd, 0xd9, - 0x16, 0x03, 0x01, 0x00, 0x04, 0x0e, 0x00, 0x00, - 0x00, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x86, 0x10, 0x00, 0x00, - 0x82, 0x00, 0x80, 0x51, 0x2e, 0xec, 0x0d, 0x86, - 0xf3, 0x9f, 0xf2, 0x77, 0x04, 0x27, 0x2b, 0x0e, - 0x9c, 0xab, 0x35, 0x84, 0x65, 0xff, 0x36, 0xef, - 0xc0, 0x08, 0xc9, 0x1d, 0x9f, 0x29, 0xae, 0x8d, - 0xc5, 0x66, 0x81, 0x31, 0x92, 0x5e, 0x3d, 0xac, - 0xaa, 0x37, 0x28, 0x2c, 0x06, 0x91, 0xa6, 0xc2, - 0xd0, 0x83, 0x34, 0x24, 0x1c, 0x88, 0xfc, 0x0a, - 0xcf, 0xbf, 0xc2, 0x94, 0xe2, 0xed, 0xa7, 0x6a, - 0xa8, 0x8d, 0x3d, 0xf7, 0x06, 0x7d, 0x69, 0xf8, - 0x0d, 0xb2, 0xf7, 0xe4, 0x45, 0xcb, 0x0a, 0x25, - 0xcb, 0xb2, 0x2e, 0x38, 0x9a, 0x84, 0x75, 0xe8, - 0xe1, 0x42, 0x39, 0xa2, 0x18, 0x0e, 0x48, 0xca, - 0x33, 0x16, 0x4e, 0xf6, 0x2f, 0xec, 0x07, 0xe7, - 0x57, 0xe1, 0x20, 0x40, 0x40, 0x6d, 0x4e, 0x29, - 0x04, 0x1a, 0x8c, 0x99, 0xfb, 0x19, 0x3c, 0xaa, - 0x75, 0x64, 0xd3, 0xa6, 0xe6, 0xed, 0x3f, 0x5a, - 0xd2, 0xc9, 0x80, 0x14, 0x03, 0x01, 0x00, 0x01, - 0x01, 0x16, 0x03, 0x01, 0x01, 0x10, 0xe9, 0x9e, - 0x06, 0x92, 0x18, 0xbf, 0x5e, 0xaf, 0x33, 0xc1, - 0xbf, 0x0e, 0x12, 0x07, 0x48, 0x4f, 0x6b, 0x6c, - 0xf5, 0x23, 0x5e, 0x87, 0xa7, 0xd3, 0x50, 0x79, - 0x38, 0xdc, 0xe0, 0x49, 0xd3, 0x81, 0x21, 0x12, - 0xd0, 0x3d, 0x9a, 0xfb, 0x83, 0xc1, 0x8b, 0xfc, - 0x14, 0xd5, 0xd5, 0xa7, 0xa3, 0x34, 0x14, 0x71, - 0xbe, 0xea, 0x37, 0x18, 0x12, 0x7f, 0x41, 0xfb, - 0xc5, 0x51, 0x17, 0x9d, 0x96, 0x58, 0x14, 0xfb, - 0x4f, 0xd7, 0xd3, 0x15, 0x0f, 0xec, 0x5a, 0x0d, - 0x35, 0xbb, 0x3c, 0x81, 0x5b, 0x3f, 0xdf, 0x52, - 0xa4, 0x4c, 0xcd, 0x13, 0xe1, 0x10, 0x37, 0x34, - 0xbf, 0xb4, 0x80, 0x1e, 0x8d, 0xe2, 0xc3, 0x7a, - 0x0f, 0x7b, 0x7d, 0x23, 0xeb, 0xd0, 0x99, 0x69, - 0xad, 0x0a, 0x2d, 0xb3, 0x6c, 0xd6, 0x80, 0x11, - 0x7f, 0x6c, 0xed, 0x1b, 0xcd, 0x08, 0x22, 0x56, - 0x90, 0x0e, 0xa4, 0xc3, 0x29, 0x33, 0x96, 0x30, - 0x34, 0x94, 0xa1, 0xeb, 0x9c, 0x1b, 0x5a, 0xd1, - 0x03, 0x61, 0xf9, 0xdd, 0xf3, 0x64, 0x8a, 0xfd, - 0x5f, 0x44, 0xdb, 0x2e, 0xa7, 0xfd, 0xe1, 0x1a, - 0x66, 0xc5, 0x01, 0x9c, 0xc7, 0xd1, 0xc4, 0xd3, - 0xea, 0x14, 0x3c, 0xed, 0x74, 0xbb, 0x1b, 0x97, - 0x8f, 0xf1, 0x29, 0x39, 0x33, 0x92, 0x93, 0x4e, - 0xf5, 0x87, 0x91, 0x61, 0x65, 0x8d, 0x27, 0x8d, - 0x76, 0xc1, 0xfa, 0x6a, 0x99, 0x80, 0xb1, 0x9b, - 0x29, 0x53, 0xce, 0x3e, 0xb6, 0x9a, 0xce, 0x3c, - 0x19, 0x5e, 0x48, 0x83, 0xaa, 0xa7, 0x66, 0x98, - 0x59, 0xf4, 0xbb, 0xf2, 0xbc, 0xd9, 0xc5, 0x9a, - 0xc8, 0x2c, 0x63, 0x58, 0xd5, 0xd4, 0xbc, 0x03, - 0xa9, 0x06, 0xa9, 0x80, 0x0d, 0xb3, 0x46, 0x2d, - 0xe3, 0xc6, 0xaf, 0x1a, 0x39, 0x18, 0x7e, 0x1e, - 0x83, 0x80, 0x46, 0x11, 0xd2, 0x13, 0x9f, 0xda, - 0xfc, 0x2d, 0x42, 0xaa, 0x5a, 0x1d, 0x4c, 0x31, - 0xe5, 0x58, 0x78, 0x5e, 0xe2, 0x04, 0xd6, 0x23, - 0x7f, 0x3f, 0x06, 0xc0, 0x54, 0xf8, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x72, 0x04, 0x00, 0x00, - 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, - 0xe8, 0x4b, 0xfb, 0xef, 0xba, 0xed, 0xc5, 0x36, - 0xc8, 0x5a, 0x41, 0x3f, 0x05, 0xfa, 0xfe, 0x48, - 0xc3, 0x91, 0x12, 0x8b, 0xe8, 0x32, 0x6a, 0x9f, - 0xdc, 0x97, 0xe2, 0x77, 0xb9, 0x96, 0x2d, 0xd4, - 0xe5, 0xbd, 0xa1, 0xfd, 0x94, 0xbb, 0x74, 0x63, - 0xb1, 0x0c, 0x38, 0xbc, 0x6f, 0x69, 0xaf, 0xa3, - 0x46, 0x9c, 0x96, 0x41, 0xde, 0x59, 0x23, 0xff, - 0x15, 0x6b, 0x3a, 0xef, 0x91, 0x6d, 0x92, 0x44, - 0xdc, 0x72, 0x1f, 0x40, 0x3d, 0xb5, 0x34, 0x8f, - 0x2a, 0xac, 0x21, 0x69, 0x05, 0x6f, 0xb2, 0x60, - 0x32, 0x5d, 0x3d, 0x97, 0xb4, 0x24, 0x99, 0x14, - 0x03, 0x01, 0x00, 0x01, 0x01, 0x16, 0x03, 0x01, - 0x00, 0x30, 0x68, 0x27, 0x97, 0xca, 0x63, 0x09, - 0x22, 0xed, 0x0e, 0x61, 0x7c, 0x76, 0x31, 0x9c, - 0xbe, 0x27, 0xc9, 0xe6, 0x09, 0xc3, 0xc3, 0xc2, - 0xf4, 0xa2, 0x32, 0xba, 0x7c, 0xf2, 0x0f, 0xb8, - 0x3d, 0xcb, 0xe2, 0x4c, 0xc0, 0x7d, 0x8e, 0x5b, - 0x5a, 0xed, 0x05, 0x5c, 0x15, 0x96, 0x69, 0xc2, - 0x6f, 0x5f, 0x17, 0x03, 0x01, 0x00, 0x20, 0x5a, - 0xfe, 0x0b, 0xe1, 0x6f, 0xa8, 0x54, 0x19, 0x78, - 0xca, 0xba, 0x2e, 0x1e, 0x2e, 0xe1, 0x5d, 0x17, - 0xe5, 0x97, 0x05, 0x2c, 0x08, 0x0c, 0xff, 0xa8, - 0x59, 0xa9, 0xde, 0x5e, 0x21, 0x34, 0x04, 0x17, - 0x03, 0x01, 0x00, 0x30, 0x86, 0xb1, 0x3f, 0x88, - 0x43, 0xf0, 0x07, 0xee, 0xa8, 0xf4, 0xbc, 0xe7, - 0x5f, 0xc6, 0x8c, 0x86, 0x4c, 0xca, 0x70, 0x88, - 0xcc, 0x6a, 0xb4, 0x3d, 0x40, 0xe8, 0x54, 0x89, - 0x19, 0x43, 0x1f, 0x76, 0xe2, 0xac, 0xb2, 0x5b, - 0x92, 0xf8, 0x57, 0x39, 0x2a, 0xc3, 0x6d, 0x13, - 0x45, 0xfa, 0x36, 0x9e, 0x15, 0x03, 0x01, 0x00, - 0x20, 0x6d, 0xed, 0x7b, 0x59, 0x28, 0x2a, 0x27, - 0x04, 0x15, 0x07, 0x4e, 0xeb, 0x13, 0x00, 0xe3, - 0x3a, 0x3f, 0xf8, 0xaa, 0x2b, 0x3b, 0x1a, 0x8c, - 0x12, 0xd6, 0x4c, 0xec, 0x2a, 0xaf, 0x33, 0x60, - 0xaf, - }, -} - -// Generated using: -// $ go test -test.run TestRunServer -serve -ciphersuites=0xc00a -// $ openssl s_client -host 127.0.0.1 -port 10443 -cipher ECDHE-ECDSA-AES256-SHA -var ecdheECDSAAESServerScript = [][]byte{ - { - 0x16, 0x03, 0x01, 0x00, 0xa0, 0x01, 0x00, 0x00, - 0x9c, 0x03, 0x03, 0x50, 0xd7, 0x18, 0x31, 0x49, - 0xde, 0x19, 0x8d, 0x08, 0x5c, 0x4b, 0x60, 0x67, - 0x0f, 0xfe, 0xd0, 0x62, 0xf9, 0x31, 0x48, 0x17, - 0x9e, 0x50, 0xc1, 0xd8, 0x35, 0x24, 0x0e, 0xa6, - 0x09, 0x06, 0x51, 0x00, 0x00, 0x04, 0xc0, 0x0a, - 0x00, 0xff, 0x01, 0x00, 0x00, 0x6f, 0x00, 0x0b, - 0x00, 0x04, 0x03, 0x00, 0x01, 0x02, 0x00, 0x0a, - 0x00, 0x34, 0x00, 0x32, 0x00, 0x0e, 0x00, 0x0d, - 0x00, 0x19, 0x00, 0x0b, 0x00, 0x0c, 0x00, 0x18, - 0x00, 0x09, 0x00, 0x0a, 0x00, 0x16, 0x00, 0x17, - 0x00, 0x08, 0x00, 0x06, 0x00, 0x07, 0x00, 0x14, - 0x00, 0x15, 0x00, 0x04, 0x00, 0x05, 0x00, 0x12, - 0x00, 0x13, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, - 0x00, 0x0f, 0x00, 0x10, 0x00, 0x11, 0x00, 0x23, - 0x00, 0x00, 0x00, 0x0d, 0x00, 0x22, 0x00, 0x20, - 0x06, 0x01, 0x06, 0x02, 0x06, 0x03, 0x05, 0x01, - 0x05, 0x02, 0x05, 0x03, 0x04, 0x01, 0x04, 0x02, - 0x04, 0x03, 0x03, 0x01, 0x03, 0x02, 0x03, 0x03, - 0x02, 0x01, 0x02, 0x02, 0x02, 0x03, 0x01, 0x01, - 0x00, 0x0f, 0x00, 0x01, 0x01, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x30, 0x02, 0x00, 0x00, - 0x2c, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xc0, 0x0a, 0x00, 0x00, - 0x04, 0x00, 0x23, 0x00, 0x00, 0x16, 0x03, 0x01, - 0x02, 0x0e, 0x0b, 0x00, 0x02, 0x0a, 0x00, 0x02, - 0x07, 0x00, 0x02, 0x04, 0x30, 0x82, 0x02, 0x00, - 0x30, 0x82, 0x01, 0x62, 0x02, 0x09, 0x00, 0xb8, - 0xbf, 0x2d, 0x47, 0xa0, 0xd2, 0xeb, 0xf4, 0x30, - 0x09, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, - 0x04, 0x01, 0x30, 0x45, 0x31, 0x0b, 0x30, 0x09, - 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x41, - 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, - 0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, 0x6d, 0x65, - 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, 0x21, - 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, - 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, - 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, 0x74, - 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, 0x74, - 0x64, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x32, 0x31, - 0x31, 0x32, 0x32, 0x31, 0x35, 0x30, 0x36, 0x33, - 0x32, 0x5a, 0x17, 0x0d, 0x32, 0x32, 0x31, 0x31, - 0x32, 0x30, 0x31, 0x35, 0x30, 0x36, 0x33, 0x32, - 0x5a, 0x30, 0x45, 0x31, 0x0b, 0x30, 0x09, 0x06, - 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x41, 0x55, - 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, - 0x08, 0x13, 0x0a, 0x53, 0x6f, 0x6d, 0x65, 0x2d, - 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, 0x21, 0x30, - 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x18, - 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, - 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, 0x74, 0x73, - 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, 0x74, 0x64, - 0x30, 0x81, 0x9b, 0x30, 0x10, 0x06, 0x07, 0x2a, - 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, - 0x2b, 0x81, 0x04, 0x00, 0x23, 0x03, 0x81, 0x86, - 0x00, 0x04, 0x00, 0xc4, 0xa1, 0xed, 0xbe, 0x98, - 0xf9, 0x0b, 0x48, 0x73, 0x36, 0x7e, 0xc3, 0x16, - 0x56, 0x11, 0x22, 0xf2, 0x3d, 0x53, 0xc3, 0x3b, - 0x4d, 0x21, 0x3d, 0xcd, 0x6b, 0x75, 0xe6, 0xf6, - 0xb0, 0xdc, 0x9a, 0xdf, 0x26, 0xc1, 0xbc, 0xb2, - 0x87, 0xf0, 0x72, 0x32, 0x7c, 0xb3, 0x64, 0x2f, - 0x1c, 0x90, 0xbc, 0xea, 0x68, 0x23, 0x10, 0x7e, - 0xfe, 0xe3, 0x25, 0xc0, 0x48, 0x3a, 0x69, 0xe0, - 0x28, 0x6d, 0xd3, 0x37, 0x00, 0xef, 0x04, 0x62, - 0xdd, 0x0d, 0xa0, 0x9c, 0x70, 0x62, 0x83, 0xd8, - 0x81, 0xd3, 0x64, 0x31, 0xaa, 0x9e, 0x97, 0x31, - 0xbd, 0x96, 0xb0, 0x68, 0xc0, 0x9b, 0x23, 0xde, - 0x76, 0x64, 0x3f, 0x1a, 0x5c, 0x7f, 0xe9, 0x12, - 0x0e, 0x58, 0x58, 0xb6, 0x5f, 0x70, 0xdd, 0x9b, - 0xd8, 0xea, 0xd5, 0xd7, 0xf5, 0xd5, 0xcc, 0xb9, - 0xb6, 0x9f, 0x30, 0x66, 0x5b, 0x66, 0x9a, 0x20, - 0xe2, 0x27, 0xe5, 0xbf, 0xfe, 0x3b, 0x30, 0x09, - 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, - 0x01, 0x03, 0x81, 0x8c, 0x00, 0x30, 0x81, 0x88, - 0x02, 0x42, 0x01, 0x88, 0xa2, 0x4f, 0xeb, 0xe2, - 0x45, 0xc5, 0x48, 0x7d, 0x1b, 0xac, 0xf5, 0xed, - 0x98, 0x9d, 0xae, 0x47, 0x70, 0xc0, 0x5e, 0x1b, - 0xb6, 0x2f, 0xbd, 0xf1, 0xb6, 0x4d, 0xb7, 0x61, - 0x40, 0xd3, 0x11, 0xa2, 0xce, 0xee, 0x0b, 0x7e, - 0x92, 0x7e, 0xff, 0x76, 0x9d, 0xc3, 0x3b, 0x7e, - 0xa5, 0x3f, 0xce, 0xfa, 0x10, 0xe2, 0x59, 0xec, - 0x47, 0x2d, 0x7c, 0xac, 0xda, 0x4e, 0x97, 0x0e, - 0x15, 0xa0, 0x6f, 0xd0, 0x02, 0x42, 0x01, 0x4d, - 0xfc, 0xbe, 0x67, 0x13, 0x9c, 0x2d, 0x05, 0x0e, - 0xbd, 0x3f, 0xa3, 0x8c, 0x25, 0xc1, 0x33, 0x13, - 0x83, 0x0d, 0x94, 0x06, 0xbb, 0xd4, 0x37, 0x7a, - 0xf6, 0xec, 0x7a, 0xc9, 0x86, 0x2e, 0xdd, 0xd7, - 0x11, 0x69, 0x7f, 0x85, 0x7c, 0x56, 0xde, 0xfb, - 0x31, 0x78, 0x2b, 0xe4, 0xc7, 0x78, 0x0d, 0xae, - 0xcb, 0xbe, 0x9e, 0x4e, 0x36, 0x24, 0x31, 0x7b, - 0x6a, 0x0f, 0x39, 0x95, 0x12, 0x07, 0x8f, 0x2a, - 0x16, 0x03, 0x01, 0x01, 0x1a, 0x0c, 0x00, 0x01, - 0x16, 0x03, 0x00, 0x19, 0x85, 0x04, 0x01, 0x39, - 0xdc, 0xee, 0x44, 0x17, 0x5e, 0xdb, 0xd7, 0x27, - 0xaf, 0xb6, 0x56, 0xd9, 0xb4, 0x43, 0x5a, 0x99, - 0xcf, 0xaa, 0x31, 0x37, 0x0c, 0x6f, 0x3a, 0xa0, - 0xf8, 0x53, 0xc4, 0x74, 0xd1, 0x91, 0x0a, 0x46, - 0xf5, 0x38, 0x3b, 0x5c, 0x09, 0xd8, 0x97, 0xdc, - 0x4b, 0xaa, 0x70, 0x26, 0x48, 0xf2, 0xd6, 0x0b, - 0x31, 0xc9, 0xf8, 0xd4, 0x98, 0x43, 0xe1, 0x6c, - 0xd5, 0xc7, 0xb2, 0x8e, 0x0b, 0x01, 0xe6, 0xb6, - 0x00, 0x28, 0x80, 0x7b, 0xfc, 0x96, 0x8f, 0x0d, - 0xa2, 0x4f, 0xb0, 0x79, 0xaf, 0xdc, 0x61, 0x28, - 0x63, 0x33, 0x78, 0xf6, 0x31, 0x39, 0xfd, 0x8a, - 0xf4, 0x15, 0x18, 0x11, 0xfe, 0xdb, 0xd5, 0x07, - 0xda, 0x2c, 0xed, 0x49, 0xa0, 0x23, 0xbf, 0xd0, - 0x3a, 0x38, 0x1d, 0x54, 0xae, 0x1c, 0x7b, 0xea, - 0x29, 0xee, 0xd0, 0x38, 0xc1, 0x76, 0xa7, 0x7f, - 0x2a, 0xf4, 0xce, 0x1e, 0xac, 0xcc, 0x94, 0x79, - 0x90, 0x33, 0x00, 0x8b, 0x30, 0x81, 0x88, 0x02, - 0x42, 0x00, 0xc6, 0x85, 0x8e, 0x06, 0xb7, 0x04, - 0x04, 0xe9, 0xcd, 0x9e, 0x3e, 0xcb, 0x66, 0x23, - 0x95, 0xb4, 0x42, 0x9c, 0x64, 0x81, 0x39, 0x05, - 0x3f, 0xb5, 0x21, 0xf8, 0x28, 0xaf, 0x60, 0x6b, - 0x4d, 0x3d, 0xba, 0xa1, 0x4b, 0x5e, 0x77, 0xef, - 0xe7, 0x59, 0x28, 0xfe, 0x1d, 0xc1, 0x27, 0xa2, - 0xff, 0xa8, 0xde, 0x33, 0x48, 0xb3, 0xc1, 0x85, - 0x6a, 0x42, 0x9b, 0xf9, 0x7e, 0x7e, 0x31, 0xc2, - 0xe5, 0xbd, 0x66, 0x02, 0x42, 0x00, 0xad, 0x7d, - 0x06, 0x35, 0xab, 0xec, 0x8d, 0xac, 0xd4, 0xba, - 0x1b, 0x49, 0x5e, 0x05, 0x5f, 0xf0, 0x97, 0x93, - 0x82, 0xb8, 0x2b, 0x8d, 0x91, 0x98, 0x63, 0x8e, - 0xb4, 0x14, 0x62, 0xdb, 0x1e, 0xc9, 0x2b, 0x30, - 0xf8, 0x41, 0x9b, 0xa6, 0xe6, 0xbc, 0xde, 0x0e, - 0x68, 0x30, 0x22, 0x50, 0xe6, 0x98, 0x97, 0x7b, - 0x69, 0xf7, 0x93, 0xed, 0xcd, 0x19, 0x2f, 0x44, - 0x6c, 0x2e, 0xdf, 0x25, 0xee, 0xcc, 0x46, 0x16, - 0x03, 0x01, 0x00, 0x04, 0x0e, 0x00, 0x00, 0x00, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x8a, 0x10, 0x00, 0x00, - 0x86, 0x85, 0x04, 0x00, 0x1c, 0xc5, 0xe8, 0xb3, - 0x42, 0xb4, 0xad, 0xca, 0x45, 0xcd, 0x42, 0x7b, - 0xfb, 0x0c, 0xea, 0x32, 0x26, 0xd4, 0x8a, 0xef, - 0xdf, 0xc9, 0xff, 0xd2, 0xe0, 0x36, 0xea, 0x4e, - 0xbb, 0x3e, 0xf4, 0x9c, 0x76, 0x4f, 0x44, 0xbd, - 0x84, 0x72, 0xdd, 0xcb, 0xe5, 0x28, 0x8d, 0x31, - 0x72, 0x3b, 0xd3, 0xf2, 0x9a, 0x13, 0xfb, 0x8a, - 0xa7, 0x72, 0xca, 0x21, 0x6c, 0xea, 0xbf, 0xe9, - 0x8c, 0x0a, 0xcc, 0x8f, 0xd6, 0x00, 0x20, 0x87, - 0xf3, 0x7d, 0x18, 0xc5, 0xfd, 0x9e, 0xdd, 0x6b, - 0x06, 0xdc, 0x52, 0xeb, 0x14, 0xc0, 0x67, 0x5a, - 0x06, 0xd8, 0x98, 0x19, 0x14, 0xe7, 0xd4, 0x36, - 0x32, 0xee, 0xb7, 0xfa, 0xe2, 0x85, 0x4a, 0x16, - 0x42, 0x0c, 0xa6, 0x21, 0xcf, 0x1f, 0xae, 0x10, - 0x8b, 0x28, 0x32, 0x19, 0xa4, 0x0a, 0xd7, 0xce, - 0xe6, 0xe1, 0x93, 0xfb, 0x5f, 0x08, 0x8b, 0x42, - 0xa2, 0x20, 0xed, 0x0d, 0x62, 0xca, 0xed, 0x14, - 0x03, 0x01, 0x00, 0x01, 0x01, 0x16, 0x03, 0x01, - 0x00, 0x30, 0x2e, 0x33, 0xc0, 0x57, 0x6c, 0xb4, - 0x1b, 0xd2, 0x63, 0xe8, 0x67, 0x10, 0x2d, 0x87, - 0x71, 0x6e, 0x19, 0x60, 0xf4, 0xa4, 0x10, 0x52, - 0x73, 0x2d, 0x09, 0x5e, 0xdb, 0x6c, 0xdc, 0xcf, - 0x2d, 0xff, 0x03, 0x11, 0x95, 0x76, 0x90, 0xd7, - 0x87, 0x54, 0x43, 0xed, 0xc2, 0x36, 0x69, 0x14, - 0x72, 0x4a, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x72, 0x04, 0x00, 0x00, - 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, - 0xe8, 0x8b, 0xde, 0xef, 0xba, 0xc5, 0x7e, 0x04, - 0xab, 0xfd, 0x79, 0x56, 0xf3, 0xe1, 0xa5, 0x3e, - 0x02, 0xdf, 0x69, 0x6d, 0x1f, 0x41, 0x9f, 0xbc, - 0x93, 0xe2, 0x6c, 0xf1, 0xb1, 0x38, 0xf5, 0x2b, - 0x8c, 0x4c, 0xf4, 0x74, 0xe1, 0x79, 0x35, 0x34, - 0x97, 0x9b, 0xd5, 0xba, 0xfd, 0xf7, 0x2f, 0x2d, - 0x9e, 0x84, 0x54, 0xee, 0x77, 0x59, 0x23, 0x8f, - 0xc8, 0x84, 0xb4, 0xd6, 0xea, 0x4c, 0x44, 0x8a, - 0xc6, 0x9c, 0xf9, 0x9b, 0x27, 0xea, 0x4f, 0x28, - 0x72, 0x33, 0x12, 0x20, 0x7c, 0xd7, 0x3f, 0x56, - 0xa6, 0x76, 0xc7, 0x48, 0xe4, 0x2d, 0x6f, 0x14, - 0x03, 0x01, 0x00, 0x01, 0x01, 0x16, 0x03, 0x01, - 0x00, 0x30, 0x36, 0xe3, 0xd4, 0xf7, 0xb1, 0x69, - 0x18, 0x8d, 0x09, 0xba, 0x52, 0x1e, 0xd5, 0x7d, - 0x2c, 0x15, 0x3a, 0xd6, 0xe3, 0x99, 0x30, 0x2c, - 0x99, 0x97, 0xbc, 0x19, 0x3c, 0x63, 0xa1, 0x25, - 0x68, 0xbc, 0x8a, 0x16, 0x47, 0xec, 0xae, 0x13, - 0xa4, 0x03, 0x96, 0x29, 0x11, 0x92, 0x90, 0x1a, - 0xc8, 0xa4, 0x17, 0x03, 0x01, 0x00, 0x20, 0xc1, - 0x10, 0x1d, 0xa6, 0xf1, 0xe2, 0x8a, 0xcc, 0x37, - 0x7d, 0x8e, 0x05, 0x00, 0xfb, 0xd1, 0x9f, 0xc7, - 0x11, 0xd2, 0x00, 0xb4, 0x27, 0x0a, 0x25, 0x14, - 0xd9, 0x79, 0x1b, 0xcb, 0x4d, 0x81, 0x61, 0x17, - 0x03, 0x01, 0x00, 0x30, 0x5c, 0x7c, 0x2d, 0xc0, - 0x9e, 0xa6, 0xc4, 0x8e, 0xfd, 0xf4, 0xe2, 0xe5, - 0xe4, 0xe6, 0x56, 0x9f, 0x7d, 0x4c, 0x4c, 0x2d, - 0xb7, 0xa9, 0xac, 0xfa, 0x9f, 0x12, 0x7f, 0x2d, - 0x30, 0x57, 0xe4, 0x8e, 0x30, 0x86, 0x65, 0x59, - 0xcd, 0x24, 0xda, 0xe2, 0x8a, 0x7b, 0x0c, 0x5e, - 0x86, 0x05, 0x06, 0x2a, 0x15, 0x03, 0x01, 0x00, - 0x20, 0xd6, 0xb7, 0x70, 0xf8, 0x47, 0xbc, 0x0f, - 0xf4, 0x66, 0x98, 0x1b, 0x1e, 0x8a, 0x8c, 0x0b, - 0xa1, 0x4a, 0x04, 0x29, 0x60, 0x72, 0x8b, 0xc4, - 0x73, 0xc1, 0xd6, 0x41, 0x72, 0xb7, 0x17, 0x39, - 0xda, - }, -} - -var sslv3ServerScript = [][]byte{ - { - 0x16, 0x03, 0x00, 0x00, 0x54, 0x01, 0x00, 0x00, - 0x50, 0x03, 0x00, 0x50, 0x77, 0x3d, 0x42, 0xae, - 0x84, 0xbd, 0xc5, 0x07, 0xa5, 0xc4, 0xd6, 0x16, - 0x4e, 0xd5, 0xc5, 0xfa, 0x02, 0x7a, 0x0f, 0x1d, - 0xc1, 0xe1, 0xaa, 0xe3, 0x3b, 0x4b, 0x6f, 0x11, - 0xfa, 0x1a, 0xa4, 0x00, 0x00, 0x28, 0x00, 0x39, - 0x00, 0x38, 0x00, 0x35, 0x00, 0x16, 0x00, 0x13, - 0x00, 0x0a, 0x00, 0x33, 0x00, 0x32, 0x00, 0x2f, - 0x00, 0x05, 0x00, 0x04, 0x00, 0x15, 0x00, 0x12, - 0x00, 0x09, 0x00, 0x14, 0x00, 0x11, 0x00, 0x08, - 0x00, 0x06, 0x00, 0x03, 0x00, 0xff, 0x02, 0x01, - 0x00, - }, - { - 0x16, 0x03, 0x00, 0x00, 0x2a, 0x02, 0x00, 0x00, - 0x26, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x16, - 0x03, 0x00, 0x02, 0xbe, 0x0b, 0x00, 0x02, 0xba, - 0x00, 0x02, 0xb7, 0x00, 0x02, 0xb4, 0x30, 0x82, - 0x02, 0xb0, 0x30, 0x82, 0x02, 0x19, 0xa0, 0x03, - 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0x85, 0xb0, - 0xbb, 0xa4, 0x8a, 0x7f, 0xb8, 0xca, 0x30, 0x0d, - 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, - 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x45, 0x31, - 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, - 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, - 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, - 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, - 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, - 0x20, 0x4c, 0x74, 0x64, 0x30, 0x1e, 0x17, 0x0d, - 0x31, 0x30, 0x30, 0x34, 0x32, 0x34, 0x30, 0x39, - 0x30, 0x39, 0x33, 0x38, 0x5a, 0x17, 0x0d, 0x31, - 0x31, 0x30, 0x34, 0x32, 0x34, 0x30, 0x39, 0x30, - 0x39, 0x33, 0x38, 0x5a, 0x30, 0x45, 0x31, 0x0b, - 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, - 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, - 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, - 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, - 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, - 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, - 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, - 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, - 0x4c, 0x74, 0x64, 0x30, 0x81, 0x9f, 0x30, 0x0d, - 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, - 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, - 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, - 0xbb, 0x79, 0xd6, 0xf5, 0x17, 0xb5, 0xe5, 0xbf, - 0x46, 0x10, 0xd0, 0xdc, 0x69, 0xbe, 0xe6, 0x2b, - 0x07, 0x43, 0x5a, 0xd0, 0x03, 0x2d, 0x8a, 0x7a, - 0x43, 0x85, 0xb7, 0x14, 0x52, 0xe7, 0xa5, 0x65, - 0x4c, 0x2c, 0x78, 0xb8, 0x23, 0x8c, 0xb5, 0xb4, - 0x82, 0xe5, 0xde, 0x1f, 0x95, 0x3b, 0x7e, 0x62, - 0xa5, 0x2c, 0xa5, 0x33, 0xd6, 0xfe, 0x12, 0x5c, - 0x7a, 0x56, 0xfc, 0xf5, 0x06, 0xbf, 0xfa, 0x58, - 0x7b, 0x26, 0x3f, 0xb5, 0xcd, 0x04, 0xd3, 0xd0, - 0xc9, 0x21, 0x96, 0x4a, 0xc7, 0xf4, 0x54, 0x9f, - 0x5a, 0xbf, 0xef, 0x42, 0x71, 0x00, 0xfe, 0x18, - 0x99, 0x07, 0x7f, 0x7e, 0x88, 0x7d, 0x7d, 0xf1, - 0x04, 0x39, 0xc4, 0xa2, 0x2e, 0xdb, 0x51, 0xc9, - 0x7c, 0xe3, 0xc0, 0x4c, 0x3b, 0x32, 0x66, 0x01, - 0xcf, 0xaf, 0xb1, 0x1d, 0xb8, 0x71, 0x9a, 0x1d, - 0xdb, 0xdb, 0x89, 0x6b, 0xae, 0xda, 0x2d, 0x79, - 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x81, 0xa7, - 0x30, 0x81, 0xa4, 0x30, 0x1d, 0x06, 0x03, 0x55, - 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xb1, 0xad, - 0xe2, 0x85, 0x5a, 0xcf, 0xcb, 0x28, 0xdb, 0x69, - 0xce, 0x23, 0x69, 0xde, 0xd3, 0x26, 0x8e, 0x18, - 0x88, 0x39, 0x30, 0x75, 0x06, 0x03, 0x55, 0x1d, - 0x23, 0x04, 0x6e, 0x30, 0x6c, 0x80, 0x14, 0xb1, - 0xad, 0xe2, 0x85, 0x5a, 0xcf, 0xcb, 0x28, 0xdb, - 0x69, 0xce, 0x23, 0x69, 0xde, 0xd3, 0x26, 0x8e, - 0x18, 0x88, 0x39, 0xa1, 0x49, 0xa4, 0x47, 0x30, - 0x45, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, - 0x04, 0x06, 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, - 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, - 0x0a, 0x53, 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, - 0x61, 0x74, 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, - 0x03, 0x55, 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, - 0x69, 0x64, 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, - 0x74, 0x79, 0x20, 0x4c, 0x74, 0x64, 0x82, 0x09, - 0x00, 0x85, 0xb0, 0xbb, 0xa4, 0x8a, 0x7f, 0xb8, - 0xca, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, - 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, - 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, - 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x81, - 0x81, 0x00, 0x08, 0x6c, 0x45, 0x24, 0xc7, 0x6b, - 0xb1, 0x59, 0xab, 0x0c, 0x52, 0xcc, 0xf2, 0xb0, - 0x14, 0xd7, 0x87, 0x9d, 0x7a, 0x64, 0x75, 0xb5, - 0x5a, 0x95, 0x66, 0xe4, 0xc5, 0x2b, 0x8e, 0xae, - 0x12, 0x66, 0x1f, 0xeb, 0x4f, 0x38, 0xb3, 0x6e, - 0x60, 0xd3, 0x92, 0xfd, 0xf7, 0x41, 0x08, 0xb5, - 0x25, 0x13, 0xb1, 0x18, 0x7a, 0x24, 0xfb, 0x30, - 0x1d, 0xba, 0xed, 0x98, 0xb9, 0x17, 0xec, 0xe7, - 0xd7, 0x31, 0x59, 0xdb, 0x95, 0xd3, 0x1d, 0x78, - 0xea, 0x50, 0x56, 0x5c, 0xd5, 0x82, 0x5a, 0x2d, - 0x5a, 0x5f, 0x33, 0xc4, 0xb6, 0xd8, 0xc9, 0x75, - 0x90, 0x96, 0x8c, 0x0f, 0x52, 0x98, 0xb5, 0xcd, - 0x98, 0x1f, 0x89, 0x20, 0x5f, 0xf2, 0xa0, 0x1c, - 0xa3, 0x1b, 0x96, 0x94, 0xdd, 0xa9, 0xfd, 0x57, - 0xe9, 0x70, 0xe8, 0x26, 0x6d, 0x71, 0x99, 0x9b, - 0x26, 0x6e, 0x38, 0x50, 0x29, 0x6c, 0x90, 0xa7, - 0xbd, 0xd9, 0x16, 0x03, 0x00, 0x00, 0x04, 0x0e, - 0x00, 0x00, 0x00, - }, - { - 0x16, 0x03, 0x00, 0x00, 0x84, 0x10, 0x00, 0x00, - 0x80, 0x4a, 0x8d, 0xc4, 0x38, 0x7a, 0x9c, 0xd6, - 0xe8, 0x72, 0x9e, 0xa3, 0xdf, 0x37, 0xb4, 0x6c, - 0x58, 0x33, 0x59, 0xd9, 0xc9, 0x4b, 0x50, 0x33, - 0x6c, 0xed, 0x73, 0x38, 0x2a, 0x46, 0x55, 0x31, - 0xa9, 0x8e, 0x8e, 0xfc, 0x0b, 0x5d, 0x5f, 0x3c, - 0x88, 0x28, 0x3f, 0x60, 0x51, 0x13, 0xf1, 0x59, - 0x0c, 0xa3, 0x5e, 0xe0, 0xa3, 0x35, 0x06, 0xb1, - 0x71, 0x59, 0x24, 0x4e, 0xed, 0x07, 0x15, 0x88, - 0x50, 0xef, 0xc2, 0xb2, 0x2a, 0x52, 0x30, 0x6a, - 0x7c, 0xbe, 0x2f, 0xc6, 0x8f, 0xa8, 0x83, 0xc5, - 0x80, 0x14, 0x62, 0x74, 0x7f, 0x96, 0x9f, 0x41, - 0x32, 0x74, 0xdd, 0x76, 0x2d, 0x7b, 0xeb, 0x7b, - 0xea, 0xd0, 0x4f, 0x0c, 0xcf, 0x9a, 0x9c, 0xc5, - 0x7a, 0xe4, 0xbc, 0xf8, 0xa6, 0xe1, 0x09, 0x8e, - 0x7c, 0x53, 0x3a, 0xe3, 0x30, 0x8f, 0x76, 0xee, - 0x58, 0xbb, 0xfd, 0x0b, 0x06, 0xb8, 0xdf, 0xb7, - 0x31, 0x14, 0x03, 0x00, 0x00, 0x01, 0x01, 0x16, - 0x03, 0x00, 0x00, 0x3c, 0x13, 0x91, 0xc6, 0x4a, - 0x0c, 0x59, 0x25, 0xce, 0x54, 0xc0, 0x1d, 0xb9, - 0x2a, 0xff, 0x4d, 0xca, 0x26, 0x0c, 0x8c, 0x04, - 0x98, 0x7c, 0x7c, 0x38, 0xa3, 0xf5, 0xf9, 0x36, - 0x1c, 0x04, 0x32, 0x47, 0x2d, 0x48, 0x0e, 0x96, - 0xe8, 0x2b, 0x5e, 0x5a, 0xc6, 0x0a, 0x48, 0x41, - 0x34, 0x5e, 0x62, 0xd5, 0x68, 0x4e, 0x44, 0x1d, - 0xb2, 0xa1, 0x11, 0xad, 0x6e, 0x14, 0x85, 0x61, - }, - { - 0x14, 0x03, 0x00, 0x00, 0x01, 0x01, 0x16, 0x03, - 0x00, 0x00, 0x3c, 0x88, 0xae, 0xa9, 0xd4, 0xa8, - 0x10, 0x8d, 0x65, 0xa6, 0x3e, 0x1e, 0xed, 0xd2, - 0xfc, 0xc4, 0x7c, 0xa8, 0x94, 0x4f, 0x11, 0xaf, - 0xa6, 0x87, 0x09, 0x37, 0x54, 0xf7, 0x69, 0xd1, - 0xb5, 0x25, 0x6b, 0xb5, 0xed, 0xcb, 0x25, 0x39, - 0x73, 0xeb, 0x53, 0x6c, 0xc7, 0xb4, 0x29, 0x8f, - 0xd6, 0x49, 0xd1, 0x95, 0x59, 0x80, 0x9a, 0x67, - 0x5c, 0xb2, 0xe0, 0xbd, 0x1e, 0xff, 0xaa, 0x17, - 0x03, 0x00, 0x00, 0x21, 0x65, 0x7b, 0x99, 0x09, - 0x02, 0xc3, 0x9d, 0x54, 0xd6, 0xe7, 0x32, 0x62, - 0xab, 0xc1, 0x09, 0x91, 0x30, 0x0a, 0xc9, 0xfa, - 0x70, 0xec, 0x06, 0x7b, 0xa3, 0xe1, 0x5f, 0xb4, - 0x63, 0xe6, 0x5c, 0xba, 0x1f, 0x15, 0x03, 0x00, - 0x00, 0x16, 0x40, 0x70, 0xbe, 0xe6, 0xa6, 0xee, - 0x8f, 0xd0, 0x87, 0xa0, 0x43, 0xa1, 0x92, 0xd7, - 0xd0, 0x1a, 0x0c, 0x20, 0x7c, 0xbf, 0xa2, 0xb5, - }, -} - -var selectCertificateBySNIScript = [][]byte{ - { - 0x16, 0x03, 0x01, 0x00, 0x6a, 0x01, 0x00, 0x00, - 0x66, 0x03, 0x01, 0x50, 0x77, 0x3d, 0xfe, 0xfb, - 0x8d, 0xc2, 0x68, 0xeb, 0xf9, 0xfa, 0x54, 0x97, - 0x86, 0x45, 0xa2, 0xa3, 0xed, 0xb1, 0x91, 0xb8, - 0x28, 0xc0, 0x47, 0xaf, 0xfb, 0xcd, 0xdc, 0x0e, - 0xb3, 0xea, 0xa5, 0x00, 0x00, 0x28, 0x00, 0x39, - 0x00, 0x38, 0x00, 0x35, 0x00, 0x16, 0x00, 0x13, - 0x00, 0x0a, 0x00, 0x33, 0x00, 0x32, 0x00, 0x2f, - 0x00, 0x05, 0x00, 0x04, 0x00, 0x15, 0x00, 0x12, - 0x00, 0x09, 0x00, 0x14, 0x00, 0x11, 0x00, 0x08, - 0x00, 0x06, 0x00, 0x03, 0x00, 0xff, 0x02, 0x01, - 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x10, 0x00, - 0x0e, 0x00, 0x00, 0x0b, 0x73, 0x6e, 0x69, 0x74, - 0x65, 0x73, 0x74, 0x2e, 0x63, 0x6f, 0x6d, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x2a, 0x02, 0x00, 0x00, - 0x26, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x16, - 0x03, 0x01, 0x02, 0x00, 0x0b, 0x00, 0x01, 0xfc, - 0x00, 0x01, 0xf9, 0x00, 0x01, 0xf6, 0x30, 0x82, - 0x01, 0xf2, 0x30, 0x82, 0x01, 0x5d, 0xa0, 0x03, - 0x02, 0x01, 0x02, 0x02, 0x01, 0x00, 0x30, 0x0b, - 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, - 0x01, 0x01, 0x05, 0x30, 0x28, 0x31, 0x10, 0x30, - 0x0e, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x07, - 0x41, 0x63, 0x6d, 0x65, 0x20, 0x43, 0x6f, 0x31, - 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x03, - 0x13, 0x0b, 0x73, 0x6e, 0x69, 0x74, 0x65, 0x73, - 0x74, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x1e, 0x17, - 0x0d, 0x31, 0x32, 0x30, 0x34, 0x31, 0x31, 0x31, - 0x37, 0x34, 0x30, 0x33, 0x35, 0x5a, 0x17, 0x0d, - 0x31, 0x33, 0x30, 0x34, 0x31, 0x31, 0x31, 0x37, - 0x34, 0x35, 0x33, 0x35, 0x5a, 0x30, 0x28, 0x31, - 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x0a, - 0x13, 0x07, 0x41, 0x63, 0x6d, 0x65, 0x20, 0x43, - 0x6f, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, - 0x04, 0x03, 0x13, 0x0b, 0x73, 0x6e, 0x69, 0x74, - 0x65, 0x73, 0x74, 0x2e, 0x63, 0x6f, 0x6d, 0x30, - 0x81, 0x9d, 0x30, 0x0b, 0x06, 0x09, 0x2a, 0x86, - 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x03, - 0x81, 0x8d, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, - 0x81, 0x00, 0xbb, 0x79, 0xd6, 0xf5, 0x17, 0xb5, - 0xe5, 0xbf, 0x46, 0x10, 0xd0, 0xdc, 0x69, 0xbe, - 0xe6, 0x2b, 0x07, 0x43, 0x5a, 0xd0, 0x03, 0x2d, - 0x8a, 0x7a, 0x43, 0x85, 0xb7, 0x14, 0x52, 0xe7, - 0xa5, 0x65, 0x4c, 0x2c, 0x78, 0xb8, 0x23, 0x8c, - 0xb5, 0xb4, 0x82, 0xe5, 0xde, 0x1f, 0x95, 0x3b, - 0x7e, 0x62, 0xa5, 0x2c, 0xa5, 0x33, 0xd6, 0xfe, - 0x12, 0x5c, 0x7a, 0x56, 0xfc, 0xf5, 0x06, 0xbf, - 0xfa, 0x58, 0x7b, 0x26, 0x3f, 0xb5, 0xcd, 0x04, - 0xd3, 0xd0, 0xc9, 0x21, 0x96, 0x4a, 0xc7, 0xf4, - 0x54, 0x9f, 0x5a, 0xbf, 0xef, 0x42, 0x71, 0x00, - 0xfe, 0x18, 0x99, 0x07, 0x7f, 0x7e, 0x88, 0x7d, - 0x7d, 0xf1, 0x04, 0x39, 0xc4, 0xa2, 0x2e, 0xdb, - 0x51, 0xc9, 0x7c, 0xe3, 0xc0, 0x4c, 0x3b, 0x32, - 0x66, 0x01, 0xcf, 0xaf, 0xb1, 0x1d, 0xb8, 0x71, - 0x9a, 0x1d, 0xdb, 0xdb, 0x89, 0x6b, 0xae, 0xda, - 0x2d, 0x79, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, - 0x32, 0x30, 0x30, 0x30, 0x0e, 0x06, 0x03, 0x55, - 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, - 0x02, 0x00, 0xa0, 0x30, 0x0d, 0x06, 0x03, 0x55, - 0x1d, 0x0e, 0x04, 0x06, 0x04, 0x04, 0x01, 0x02, - 0x03, 0x04, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d, - 0x23, 0x04, 0x08, 0x30, 0x06, 0x80, 0x04, 0x01, - 0x02, 0x03, 0x04, 0x30, 0x0b, 0x06, 0x09, 0x2a, - 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, - 0x03, 0x81, 0x81, 0x00, 0x89, 0xc6, 0x45, 0x5f, - 0x1c, 0x1f, 0x5e, 0xf8, 0xeb, 0x1a, 0xb1, 0x74, - 0xee, 0x24, 0x39, 0x05, 0x9f, 0x5c, 0x42, 0x59, - 0xbb, 0x1a, 0x8d, 0x86, 0xcd, 0xb1, 0xd0, 0x56, - 0xf5, 0x6a, 0x71, 0x7d, 0xa4, 0x0e, 0x95, 0xab, - 0x90, 0xf5, 0x9e, 0x8d, 0xea, 0xf6, 0x27, 0xc1, - 0x57, 0x99, 0x50, 0x94, 0xdb, 0x08, 0x02, 0x26, - 0x6e, 0xb3, 0x4f, 0xc6, 0x84, 0x2d, 0xea, 0x8a, - 0x4b, 0x68, 0xd9, 0xc1, 0x38, 0x91, 0x03, 0xab, - 0x84, 0xfb, 0x9e, 0x1f, 0x85, 0xd9, 0xb5, 0xd2, - 0x3f, 0xf2, 0x31, 0x2c, 0x86, 0x70, 0xfb, 0xb5, - 0x40, 0x14, 0x82, 0x45, 0xa4, 0xeb, 0xaf, 0xe2, - 0x64, 0xd9, 0x0c, 0x8a, 0x4c, 0xf4, 0xf8, 0x5b, - 0x0f, 0xac, 0x12, 0xac, 0x2f, 0xc4, 0xa3, 0x15, - 0x4b, 0xad, 0x52, 0x46, 0x28, 0x68, 0xaf, 0x96, - 0xc6, 0x2c, 0x65, 0x25, 0xd6, 0x52, 0xb6, 0xe3, - 0x18, 0x45, 0xbd, 0xcc, 0x16, 0x03, 0x01, 0x00, - 0x04, 0x0e, 0x00, 0x00, 0x00, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x86, 0x10, 0x00, 0x00, - 0x82, 0x00, 0x80, 0x69, 0xc3, 0xd4, 0x0e, 0xcc, - 0xdc, 0xbc, 0x5e, 0xc2, 0x64, 0xa6, 0xde, 0x3c, - 0x0c, 0x7e, 0x0c, 0x6b, 0x80, 0x0f, 0xd4, 0x8f, - 0x02, 0x4b, 0xb2, 0xba, 0x8d, 0x01, 0xeb, 0x6b, - 0xa1, 0x2e, 0x79, 0x37, 0xba, 0xae, 0x24, 0xc2, - 0x26, 0x72, 0x51, 0xe1, 0x82, 0x8e, 0x51, 0x41, - 0x1c, 0x54, 0xa4, 0x26, 0xbe, 0x13, 0xcd, 0x1b, - 0xc6, 0xed, 0x3d, 0x1f, 0xfd, 0x72, 0x80, 0x90, - 0xdb, 0xbf, 0xd6, 0x39, 0x94, 0x5f, 0x48, 0xfb, - 0x25, 0x5a, 0xc9, 0x60, 0x9b, 0xd7, 0xc6, 0x20, - 0xa8, 0x66, 0x64, 0x13, 0xf3, 0x65, 0xc8, 0xb1, - 0xd5, 0x33, 0x21, 0x0e, 0x73, 0x41, 0xc0, 0x18, - 0x1a, 0x37, 0xfe, 0xcf, 0x28, 0x2a, 0xcd, 0xe4, - 0x0b, 0xac, 0xdd, 0x25, 0x5e, 0xcb, 0x17, 0x51, - 0x69, 0xd5, 0x8c, 0xf4, 0xb6, 0x21, 0x98, 0xef, - 0x20, 0xdb, 0x14, 0x67, 0xf3, 0x7c, 0x95, 0x6a, - 0x48, 0x2a, 0x6a, 0x14, 0x03, 0x01, 0x00, 0x01, - 0x01, 0x16, 0x03, 0x01, 0x00, 0x24, 0x36, 0x1b, - 0x09, 0xe5, 0xb9, 0xb9, 0x4d, 0x7d, 0xae, 0x87, - 0xb6, 0x0f, 0xaf, 0xec, 0x22, 0xba, 0x0d, 0xa5, - 0x96, 0x5e, 0x64, 0x65, 0xe7, 0xfb, 0xe3, 0xf3, - 0x6b, 0x72, 0xa8, 0xdb, 0xed, 0xd8, 0x69, 0x9c, - 0x08, 0xd8, - }, - { - 0x14, 0x03, 0x01, 0x00, 0x01, 0x01, 0x16, 0x03, - 0x01, 0x00, 0x24, 0x60, 0xf7, 0x09, 0x5f, 0xd1, - 0xcb, 0xc9, 0xe1, 0x22, 0xb5, 0x2a, 0xcc, 0xde, - 0x7c, 0xa7, 0xb8, 0x85, 0x00, 0xbc, 0xfd, 0x85, - 0xe1, 0x91, 0x36, 0xbb, 0x07, 0x42, 0xad, 0x3d, - 0x29, 0x62, 0x69, 0xc1, 0x45, 0x92, 0x6f, 0x17, - 0x03, 0x01, 0x00, 0x21, 0x0d, 0xf9, 0xd5, 0x87, - 0xb9, 0x57, 0x3c, 0x50, 0x19, 0xe4, 0x3a, 0x50, - 0x45, 0xcc, 0x86, 0x89, 0xd4, 0x32, 0x79, 0x45, - 0x7c, 0x9f, 0x96, 0xd4, 0x54, 0x56, 0x0c, 0x63, - 0x72, 0x81, 0xc3, 0xd3, 0xe3, 0x15, 0x03, 0x01, - 0x00, 0x16, 0x84, 0xec, 0x2e, 0xf6, 0xaf, 0x4f, - 0xee, 0x48, 0x0f, 0xbe, 0xcd, 0x82, 0x5c, 0x56, - 0x16, 0xe4, 0xfb, 0x89, 0xc5, 0x57, 0x3e, 0x91, - }, -} - -var issueSessionTicketTest = [][]byte{ - { - 0x16, 0x03, 0x01, 0x00, 0x5a, 0x01, 0x00, 0x00, - 0x56, 0x03, 0x01, 0x50, 0x77, 0x3e, 0x49, 0x7a, - 0xb7, 0x86, 0x5c, 0x27, 0xd2, 0x97, 0x61, 0xe3, - 0x49, 0x41, 0x48, 0xe7, 0x0e, 0xaa, 0x7e, 0x4d, - 0xb8, 0xdc, 0x01, 0x97, 0xfb, 0xab, 0x53, 0xb2, - 0x5e, 0x36, 0xf6, 0x00, 0x00, 0x28, 0x00, 0x39, - 0x00, 0x38, 0x00, 0x35, 0x00, 0x16, 0x00, 0x13, - 0x00, 0x0a, 0x00, 0x33, 0x00, 0x32, 0x00, 0x2f, - 0x00, 0x05, 0x00, 0x04, 0x00, 0x15, 0x00, 0x12, - 0x00, 0x09, 0x00, 0x14, 0x00, 0x11, 0x00, 0x08, - 0x00, 0x06, 0x00, 0x03, 0x00, 0xff, 0x02, 0x01, - 0x00, 0x00, 0x04, 0x00, 0x23, 0x00, 0x00, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x30, 0x02, 0x00, 0x00, - 0x2c, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, - 0x04, 0x00, 0x23, 0x00, 0x00, 0x16, 0x03, 0x01, - 0x02, 0xbe, 0x0b, 0x00, 0x02, 0xba, 0x00, 0x02, - 0xb7, 0x00, 0x02, 0xb4, 0x30, 0x82, 0x02, 0xb0, - 0x30, 0x82, 0x02, 0x19, 0xa0, 0x03, 0x02, 0x01, - 0x02, 0x02, 0x09, 0x00, 0x85, 0xb0, 0xbb, 0xa4, - 0x8a, 0x7f, 0xb8, 0xca, 0x30, 0x0d, 0x06, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x05, 0x05, 0x00, 0x30, 0x45, 0x31, 0x0b, 0x30, - 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, - 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, - 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, 0x6d, - 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, - 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, - 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, - 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, - 0x74, 0x64, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x30, - 0x30, 0x34, 0x32, 0x34, 0x30, 0x39, 0x30, 0x39, - 0x33, 0x38, 0x5a, 0x17, 0x0d, 0x31, 0x31, 0x30, - 0x34, 0x32, 0x34, 0x30, 0x39, 0x30, 0x39, 0x33, - 0x38, 0x5a, 0x30, 0x45, 0x31, 0x0b, 0x30, 0x09, - 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x41, - 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, - 0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, 0x6d, 0x65, - 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, 0x21, - 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, - 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, - 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, 0x74, - 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, 0x74, - 0x64, 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, - 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xbb, 0x79, - 0xd6, 0xf5, 0x17, 0xb5, 0xe5, 0xbf, 0x46, 0x10, - 0xd0, 0xdc, 0x69, 0xbe, 0xe6, 0x2b, 0x07, 0x43, - 0x5a, 0xd0, 0x03, 0x2d, 0x8a, 0x7a, 0x43, 0x85, - 0xb7, 0x14, 0x52, 0xe7, 0xa5, 0x65, 0x4c, 0x2c, - 0x78, 0xb8, 0x23, 0x8c, 0xb5, 0xb4, 0x82, 0xe5, - 0xde, 0x1f, 0x95, 0x3b, 0x7e, 0x62, 0xa5, 0x2c, - 0xa5, 0x33, 0xd6, 0xfe, 0x12, 0x5c, 0x7a, 0x56, - 0xfc, 0xf5, 0x06, 0xbf, 0xfa, 0x58, 0x7b, 0x26, - 0x3f, 0xb5, 0xcd, 0x04, 0xd3, 0xd0, 0xc9, 0x21, - 0x96, 0x4a, 0xc7, 0xf4, 0x54, 0x9f, 0x5a, 0xbf, - 0xef, 0x42, 0x71, 0x00, 0xfe, 0x18, 0x99, 0x07, - 0x7f, 0x7e, 0x88, 0x7d, 0x7d, 0xf1, 0x04, 0x39, - 0xc4, 0xa2, 0x2e, 0xdb, 0x51, 0xc9, 0x7c, 0xe3, - 0xc0, 0x4c, 0x3b, 0x32, 0x66, 0x01, 0xcf, 0xaf, - 0xb1, 0x1d, 0xb8, 0x71, 0x9a, 0x1d, 0xdb, 0xdb, - 0x89, 0x6b, 0xae, 0xda, 0x2d, 0x79, 0x02, 0x03, - 0x01, 0x00, 0x01, 0xa3, 0x81, 0xa7, 0x30, 0x81, - 0xa4, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, - 0x04, 0x16, 0x04, 0x14, 0xb1, 0xad, 0xe2, 0x85, - 0x5a, 0xcf, 0xcb, 0x28, 0xdb, 0x69, 0xce, 0x23, - 0x69, 0xde, 0xd3, 0x26, 0x8e, 0x18, 0x88, 0x39, - 0x30, 0x75, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, - 0x6e, 0x30, 0x6c, 0x80, 0x14, 0xb1, 0xad, 0xe2, - 0x85, 0x5a, 0xcf, 0xcb, 0x28, 0xdb, 0x69, 0xce, - 0x23, 0x69, 0xde, 0xd3, 0x26, 0x8e, 0x18, 0x88, - 0x39, 0xa1, 0x49, 0xa4, 0x47, 0x30, 0x45, 0x31, - 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, - 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, - 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, - 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, - 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, - 0x20, 0x4c, 0x74, 0x64, 0x82, 0x09, 0x00, 0x85, - 0xb0, 0xbb, 0xa4, 0x8a, 0x7f, 0xb8, 0xca, 0x30, - 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, - 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, - 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, - 0x01, 0x05, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, - 0x08, 0x6c, 0x45, 0x24, 0xc7, 0x6b, 0xb1, 0x59, - 0xab, 0x0c, 0x52, 0xcc, 0xf2, 0xb0, 0x14, 0xd7, - 0x87, 0x9d, 0x7a, 0x64, 0x75, 0xb5, 0x5a, 0x95, - 0x66, 0xe4, 0xc5, 0x2b, 0x8e, 0xae, 0x12, 0x66, - 0x1f, 0xeb, 0x4f, 0x38, 0xb3, 0x6e, 0x60, 0xd3, - 0x92, 0xfd, 0xf7, 0x41, 0x08, 0xb5, 0x25, 0x13, - 0xb1, 0x18, 0x7a, 0x24, 0xfb, 0x30, 0x1d, 0xba, - 0xed, 0x98, 0xb9, 0x17, 0xec, 0xe7, 0xd7, 0x31, - 0x59, 0xdb, 0x95, 0xd3, 0x1d, 0x78, 0xea, 0x50, - 0x56, 0x5c, 0xd5, 0x82, 0x5a, 0x2d, 0x5a, 0x5f, - 0x33, 0xc4, 0xb6, 0xd8, 0xc9, 0x75, 0x90, 0x96, - 0x8c, 0x0f, 0x52, 0x98, 0xb5, 0xcd, 0x98, 0x1f, - 0x89, 0x20, 0x5f, 0xf2, 0xa0, 0x1c, 0xa3, 0x1b, - 0x96, 0x94, 0xdd, 0xa9, 0xfd, 0x57, 0xe9, 0x70, - 0xe8, 0x26, 0x6d, 0x71, 0x99, 0x9b, 0x26, 0x6e, - 0x38, 0x50, 0x29, 0x6c, 0x90, 0xa7, 0xbd, 0xd9, - 0x16, 0x03, 0x01, 0x00, 0x04, 0x0e, 0x00, 0x00, - 0x00, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x86, 0x10, 0x00, 0x00, - 0x82, 0x00, 0x80, 0x68, 0x10, 0xdc, 0x80, 0xbc, - 0xb3, 0x5a, 0x10, 0x75, 0x89, 0xcc, 0xe5, 0x9f, - 0xbf, 0xe2, 0xce, 0xa4, 0x9f, 0x7f, 0x60, 0xc4, - 0xfe, 0x5c, 0xb5, 0x02, 0x2d, 0xa5, 0xa9, 0x1e, - 0x2c, 0x10, 0x79, 0x15, 0x0f, 0xed, 0x96, 0xb3, - 0xa8, 0x5e, 0x21, 0xbc, 0x5b, 0xdc, 0x58, 0x04, - 0x7d, 0x37, 0xdb, 0xa0, 0x31, 0xe8, 0x4f, 0x04, - 0xbc, 0x46, 0x7c, 0xdb, 0x2e, 0x93, 0x07, 0xaf, - 0xa6, 0x36, 0xd3, 0x39, 0x8d, 0x1d, 0x95, 0xa8, - 0x50, 0x4b, 0xc4, 0x2b, 0xde, 0xd7, 0x04, 0x6d, - 0x77, 0x6c, 0x4d, 0x70, 0x51, 0x88, 0x16, 0x31, - 0x40, 0xb5, 0xba, 0x90, 0x47, 0x64, 0x0c, 0x87, - 0xa5, 0x19, 0xf9, 0x89, 0x24, 0x3c, 0x5e, 0x4b, - 0xaa, 0xe0, 0x60, 0x47, 0x0f, 0x2e, 0xcc, 0xc2, - 0xd5, 0x21, 0xed, 0x72, 0xd0, 0xa9, 0xdd, 0x2a, - 0x2b, 0xef, 0x08, 0x3a, 0x65, 0xea, 0x8b, 0x52, - 0x77, 0x2d, 0xcc, 0x14, 0x03, 0x01, 0x00, 0x01, - 0x01, 0x16, 0x03, 0x01, 0x00, 0x24, 0xe2, 0x95, - 0x62, 0x3c, 0x18, 0xe5, 0xc7, 0x2c, 0xda, 0x16, - 0x9b, 0x28, 0x0d, 0xf7, 0x88, 0x7b, 0x5d, 0x33, - 0x55, 0x3b, 0x01, 0x73, 0xf2, 0xc6, 0x4e, 0x96, - 0x01, 0x01, 0x83, 0x65, 0xd4, 0xef, 0x12, 0x13, - 0x1d, 0x42, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x72, 0x04, 0x00, 0x00, - 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, - 0xe8, 0x4b, 0xd1, 0xef, 0xba, 0xfb, 0x41, 0x92, - 0x6d, 0x37, 0x5f, 0xf8, 0x7d, 0x90, 0x0f, 0x01, - 0xf8, 0x8c, 0xee, 0xbc, 0xd9, 0x0c, 0x97, 0x7e, - 0x23, 0x46, 0xe2, 0x6b, 0x52, 0xc6, 0xc6, 0x97, - 0x1d, 0xab, 0xde, 0xa0, 0x86, 0x94, 0xc8, 0x2e, - 0x8b, 0x2e, 0x42, 0x5f, 0xc2, 0x70, 0x35, 0xc9, - 0xee, 0x37, 0xeb, 0x70, 0xaa, 0x59, 0x23, 0x6c, - 0xc8, 0xc1, 0x84, 0x89, 0x39, 0x87, 0x73, 0x0a, - 0x7e, 0xba, 0xca, 0xed, 0x63, 0xba, 0x4e, 0x4f, - 0xf3, 0x31, 0x4b, 0xf0, 0xee, 0x91, 0xa5, 0xb4, - 0x62, 0x01, 0x9e, 0xbd, 0xbc, 0xb3, 0x35, 0x14, - 0x03, 0x01, 0x00, 0x01, 0x01, 0x16, 0x03, 0x01, - 0x00, 0x24, 0x3f, 0x66, 0xe4, 0x98, 0xc1, 0x3f, - 0xc6, 0x2c, 0x81, 0xfb, 0xa9, 0x9f, 0x27, 0xe9, - 0x63, 0x20, 0x1e, 0x0e, 0x4f, 0xfc, 0x5d, 0x12, - 0xee, 0x77, 0x73, 0xc6, 0x96, 0x51, 0xf2, 0x26, - 0x35, 0x3f, 0xce, 0x6a, 0xa9, 0xfd, 0x17, 0x03, - 0x01, 0x00, 0x21, 0x8d, 0xd5, 0x67, 0x60, 0x5d, - 0xa7, 0x93, 0xcc, 0x39, 0x78, 0x59, 0xab, 0xdb, - 0x10, 0x96, 0xf2, 0xad, 0xa2, 0x85, 0xe2, 0x93, - 0x43, 0x43, 0xcf, 0x82, 0xbd, 0x1f, 0xdc, 0x7a, - 0x72, 0xd6, 0x83, 0x3b, 0x15, 0x03, 0x01, 0x00, - 0x16, 0x89, 0x55, 0xf6, 0x42, 0x71, 0xa9, 0xe9, - 0x05, 0x68, 0xe8, 0xce, 0x0d, 0x21, 0xe9, 0xec, - 0xf2, 0x27, 0x67, 0xa7, 0x94, 0xf8, 0x34, - }, -} -var serverResumeTest = [][]byte{ - { - 0x16, 0x03, 0x01, 0x00, 0xc2, 0x01, 0x00, 0x00, - 0xbe, 0x03, 0x01, 0x50, 0x77, 0x3e, 0x4f, 0x1f, - 0x6f, 0xa5, 0x81, 0xeb, 0xb8, 0x80, 0x55, 0xa4, - 0x76, 0xc2, 0x7f, 0x27, 0xf2, 0xe7, 0xc9, 0x7a, - 0x01, 0x3c, 0xd8, 0xc1, 0xde, 0x99, 0x1f, 0x7c, - 0xab, 0x35, 0x98, 0x00, 0x00, 0x28, 0x00, 0x39, - 0x00, 0x38, 0x00, 0x35, 0x00, 0x16, 0x00, 0x13, - 0x00, 0x0a, 0x00, 0x33, 0x00, 0x32, 0x00, 0x2f, - 0x00, 0x05, 0x00, 0x04, 0x00, 0x15, 0x00, 0x12, - 0x00, 0x09, 0x00, 0x14, 0x00, 0x11, 0x00, 0x08, - 0x00, 0x06, 0x00, 0x03, 0x00, 0xff, 0x02, 0x01, - 0x00, 0x00, 0x6c, 0x00, 0x23, 0x00, 0x68, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, - 0xe8, 0x4b, 0xd1, 0xef, 0xba, 0xfb, 0x41, 0x92, - 0x6d, 0x37, 0x5f, 0xf8, 0x7d, 0x90, 0x0f, 0x01, - 0xf8, 0x8c, 0xee, 0xbc, 0xd9, 0x0c, 0x97, 0x7e, - 0x23, 0x46, 0xe2, 0x6b, 0x52, 0xc6, 0xc6, 0x97, - 0x1d, 0xab, 0xde, 0xa0, 0x86, 0x94, 0xc8, 0x2e, - 0x8b, 0x2e, 0x42, 0x5f, 0xc2, 0x70, 0x35, 0xc9, - 0xee, 0x37, 0xeb, 0x70, 0xaa, 0x59, 0x23, 0x6c, - 0xc8, 0xc1, 0x84, 0x89, 0x39, 0x87, 0x73, 0x0a, - 0x7e, 0xba, 0xca, 0xed, 0x63, 0xba, 0x4e, 0x4f, - 0xf3, 0x31, 0x4b, 0xf0, 0xee, 0x91, 0xa5, 0xb4, - 0x62, 0x01, 0x9e, 0xbd, 0xbc, 0xb3, 0x35, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x2a, 0x02, 0x00, 0x00, - 0x26, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x14, - 0x03, 0x01, 0x00, 0x01, 0x01, 0x16, 0x03, 0x01, - 0x00, 0x24, 0xc5, 0x35, 0x74, 0x19, 0x05, 0xc5, - 0x85, 0x68, 0x48, 0xe8, 0xb5, 0xe9, 0xaf, 0x78, - 0xbd, 0x35, 0x6f, 0xe9, 0x79, 0x34, 0x1b, 0xf0, - 0x35, 0xd4, 0x4e, 0x55, 0x2e, 0x3c, 0xd5, 0xaf, - 0xfc, 0xba, 0xf5, 0x1e, 0x83, 0x32, - }, - { - 0x14, 0x03, 0x01, 0x00, 0x01, 0x01, 0x16, 0x03, - 0x01, 0x00, 0x24, 0x27, 0x28, 0x88, 0xe1, 0x7e, - 0x0d, 0x9c, 0x12, 0x50, 0xf6, 0x7a, 0xa7, 0x32, - 0x21, 0x68, 0xba, 0xd8, 0x0a, 0xdc, 0x39, 0xef, - 0x68, 0x95, 0x82, 0xae, 0xbd, 0x12, 0x79, 0xa1, - 0x99, 0xfd, 0xd0, 0x10, 0x8e, 0x4b, 0xd8, - }, - { - 0x17, 0x03, 0x01, 0x00, 0x21, 0xc5, 0x7e, 0x0a, - 0x52, 0x6a, 0xb9, 0xaa, 0x1d, 0xae, 0x9e, 0x24, - 0x9c, 0x34, 0x1e, 0xdb, 0x50, 0x95, 0xee, 0x76, - 0xd7, 0x28, 0x88, 0x08, 0xe3, 0x2e, 0x58, 0xf7, - 0xdb, 0x34, 0x75, 0xa5, 0x7f, 0x9d, 0x15, 0x03, - 0x01, 0x00, 0x16, 0x2c, 0xc1, 0x29, 0x5f, 0x12, - 0x1d, 0x19, 0xab, 0xb3, 0xf4, 0x35, 0x1c, 0x62, - 0x6a, 0x80, 0x29, 0x0d, 0x0e, 0xef, 0x7d, 0x6e, - 0x50, - }, -} - -var clientauthRSATests = []clientauthTest{ - // Server asks for cert with empty CA list, client doesn't give it. - // go test -run "TestRunServer" -serve -clientauth 1 - {"RequestClientCert, none given", RequestClientCert, nil, [][]byte{ - { - 0x16, 0x03, 0x01, 0x01, 0x1e, 0x01, 0x00, 0x01, - 0x1a, 0x03, 0x03, 0x51, 0xe5, 0x6c, 0xb5, 0x5a, - 0xc2, 0xf5, 0xf0, 0x92, 0x94, 0x8a, 0x64, 0x18, - 0xa4, 0x2b, 0x82, 0x07, 0xbc, 0xd9, 0xd9, 0xf9, - 0x7b, 0xd2, 0xd0, 0xee, 0xa2, 0x70, 0x4e, 0x23, - 0x88, 0x7c, 0x95, 0x00, 0x00, 0x82, 0xc0, 0x30, - 0xc0, 0x2c, 0xc0, 0x28, 0xc0, 0x24, 0xc0, 0x14, - 0xc0, 0x0a, 0x00, 0xa3, 0x00, 0x9f, 0x00, 0x6b, - 0x00, 0x6a, 0x00, 0x39, 0x00, 0x38, 0xc0, 0x32, - 0xc0, 0x2e, 0xc0, 0x2a, 0xc0, 0x26, 0xc0, 0x0f, - 0xc0, 0x05, 0x00, 0x9d, 0x00, 0x3d, 0x00, 0x35, - 0xc0, 0x12, 0xc0, 0x08, 0x00, 0x16, 0x00, 0x13, - 0xc0, 0x0d, 0xc0, 0x03, 0x00, 0x0a, 0xc0, 0x2f, - 0xc0, 0x2b, 0xc0, 0x27, 0xc0, 0x23, 0xc0, 0x13, - 0xc0, 0x09, 0x00, 0xa2, 0x00, 0x9e, 0x00, 0x67, - 0x00, 0x40, 0x00, 0x33, 0x00, 0x32, 0xc0, 0x31, - 0xc0, 0x2d, 0xc0, 0x29, 0xc0, 0x25, 0xc0, 0x0e, - 0xc0, 0x04, 0x00, 0x9c, 0x00, 0x3c, 0x00, 0x2f, - 0x00, 0x07, 0xc0, 0x11, 0xc0, 0x07, 0xc0, 0x0c, - 0xc0, 0x02, 0x00, 0x05, 0x00, 0x04, 0x00, 0x15, - 0x00, 0x12, 0x00, 0x09, 0x00, 0x14, 0x00, 0x11, - 0x00, 0x08, 0x00, 0x06, 0x00, 0x03, 0x00, 0xff, - 0x01, 0x00, 0x00, 0x6f, 0x00, 0x0b, 0x00, 0x04, - 0x03, 0x00, 0x01, 0x02, 0x00, 0x0a, 0x00, 0x34, - 0x00, 0x32, 0x00, 0x0e, 0x00, 0x0d, 0x00, 0x19, - 0x00, 0x0b, 0x00, 0x0c, 0x00, 0x18, 0x00, 0x09, - 0x00, 0x0a, 0x00, 0x16, 0x00, 0x17, 0x00, 0x08, - 0x00, 0x06, 0x00, 0x07, 0x00, 0x14, 0x00, 0x15, - 0x00, 0x04, 0x00, 0x05, 0x00, 0x12, 0x00, 0x13, - 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x0f, - 0x00, 0x10, 0x00, 0x11, 0x00, 0x23, 0x00, 0x00, - 0x00, 0x0d, 0x00, 0x22, 0x00, 0x20, 0x06, 0x01, - 0x06, 0x02, 0x06, 0x03, 0x05, 0x01, 0x05, 0x02, - 0x05, 0x03, 0x04, 0x01, 0x04, 0x02, 0x04, 0x03, - 0x03, 0x01, 0x03, 0x02, 0x03, 0x03, 0x02, 0x01, - 0x02, 0x02, 0x02, 0x03, 0x01, 0x01, 0x00, 0x0f, - 0x00, 0x01, 0x01, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x30, 0x02, 0x00, 0x00, - 0x2c, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, - 0x04, 0x00, 0x23, 0x00, 0x00, 0x16, 0x03, 0x01, - 0x02, 0xbe, 0x0b, 0x00, 0x02, 0xba, 0x00, 0x02, - 0xb7, 0x00, 0x02, 0xb4, 0x30, 0x82, 0x02, 0xb0, - 0x30, 0x82, 0x02, 0x19, 0xa0, 0x03, 0x02, 0x01, - 0x02, 0x02, 0x09, 0x00, 0x85, 0xb0, 0xbb, 0xa4, - 0x8a, 0x7f, 0xb8, 0xca, 0x30, 0x0d, 0x06, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x05, 0x05, 0x00, 0x30, 0x45, 0x31, 0x0b, 0x30, - 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, - 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, - 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, 0x6d, - 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, - 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, - 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, - 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, - 0x74, 0x64, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x30, - 0x30, 0x34, 0x32, 0x34, 0x30, 0x39, 0x30, 0x39, - 0x33, 0x38, 0x5a, 0x17, 0x0d, 0x31, 0x31, 0x30, - 0x34, 0x32, 0x34, 0x30, 0x39, 0x30, 0x39, 0x33, - 0x38, 0x5a, 0x30, 0x45, 0x31, 0x0b, 0x30, 0x09, - 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x41, - 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, - 0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, 0x6d, 0x65, - 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, 0x21, - 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, - 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, - 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, 0x74, - 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, 0x74, - 0x64, 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, - 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xbb, 0x79, - 0xd6, 0xf5, 0x17, 0xb5, 0xe5, 0xbf, 0x46, 0x10, - 0xd0, 0xdc, 0x69, 0xbe, 0xe6, 0x2b, 0x07, 0x43, - 0x5a, 0xd0, 0x03, 0x2d, 0x8a, 0x7a, 0x43, 0x85, - 0xb7, 0x14, 0x52, 0xe7, 0xa5, 0x65, 0x4c, 0x2c, - 0x78, 0xb8, 0x23, 0x8c, 0xb5, 0xb4, 0x82, 0xe5, - 0xde, 0x1f, 0x95, 0x3b, 0x7e, 0x62, 0xa5, 0x2c, - 0xa5, 0x33, 0xd6, 0xfe, 0x12, 0x5c, 0x7a, 0x56, - 0xfc, 0xf5, 0x06, 0xbf, 0xfa, 0x58, 0x7b, 0x26, - 0x3f, 0xb5, 0xcd, 0x04, 0xd3, 0xd0, 0xc9, 0x21, - 0x96, 0x4a, 0xc7, 0xf4, 0x54, 0x9f, 0x5a, 0xbf, - 0xef, 0x42, 0x71, 0x00, 0xfe, 0x18, 0x99, 0x07, - 0x7f, 0x7e, 0x88, 0x7d, 0x7d, 0xf1, 0x04, 0x39, - 0xc4, 0xa2, 0x2e, 0xdb, 0x51, 0xc9, 0x7c, 0xe3, - 0xc0, 0x4c, 0x3b, 0x32, 0x66, 0x01, 0xcf, 0xaf, - 0xb1, 0x1d, 0xb8, 0x71, 0x9a, 0x1d, 0xdb, 0xdb, - 0x89, 0x6b, 0xae, 0xda, 0x2d, 0x79, 0x02, 0x03, - 0x01, 0x00, 0x01, 0xa3, 0x81, 0xa7, 0x30, 0x81, - 0xa4, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, - 0x04, 0x16, 0x04, 0x14, 0xb1, 0xad, 0xe2, 0x85, - 0x5a, 0xcf, 0xcb, 0x28, 0xdb, 0x69, 0xce, 0x23, - 0x69, 0xde, 0xd3, 0x26, 0x8e, 0x18, 0x88, 0x39, - 0x30, 0x75, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, - 0x6e, 0x30, 0x6c, 0x80, 0x14, 0xb1, 0xad, 0xe2, - 0x85, 0x5a, 0xcf, 0xcb, 0x28, 0xdb, 0x69, 0xce, - 0x23, 0x69, 0xde, 0xd3, 0x26, 0x8e, 0x18, 0x88, - 0x39, 0xa1, 0x49, 0xa4, 0x47, 0x30, 0x45, 0x31, - 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, - 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, - 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, - 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, - 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, - 0x20, 0x4c, 0x74, 0x64, 0x82, 0x09, 0x00, 0x85, - 0xb0, 0xbb, 0xa4, 0x8a, 0x7f, 0xb8, 0xca, 0x30, - 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, - 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, - 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, - 0x01, 0x05, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, - 0x08, 0x6c, 0x45, 0x24, 0xc7, 0x6b, 0xb1, 0x59, - 0xab, 0x0c, 0x52, 0xcc, 0xf2, 0xb0, 0x14, 0xd7, - 0x87, 0x9d, 0x7a, 0x64, 0x75, 0xb5, 0x5a, 0x95, - 0x66, 0xe4, 0xc5, 0x2b, 0x8e, 0xae, 0x12, 0x66, - 0x1f, 0xeb, 0x4f, 0x38, 0xb3, 0x6e, 0x60, 0xd3, - 0x92, 0xfd, 0xf7, 0x41, 0x08, 0xb5, 0x25, 0x13, - 0xb1, 0x18, 0x7a, 0x24, 0xfb, 0x30, 0x1d, 0xba, - 0xed, 0x98, 0xb9, 0x17, 0xec, 0xe7, 0xd7, 0x31, - 0x59, 0xdb, 0x95, 0xd3, 0x1d, 0x78, 0xea, 0x50, - 0x56, 0x5c, 0xd5, 0x82, 0x5a, 0x2d, 0x5a, 0x5f, - 0x33, 0xc4, 0xb6, 0xd8, 0xc9, 0x75, 0x90, 0x96, - 0x8c, 0x0f, 0x52, 0x98, 0xb5, 0xcd, 0x98, 0x1f, - 0x89, 0x20, 0x5f, 0xf2, 0xa0, 0x1c, 0xa3, 0x1b, - 0x96, 0x94, 0xdd, 0xa9, 0xfd, 0x57, 0xe9, 0x70, - 0xe8, 0x26, 0x6d, 0x71, 0x99, 0x9b, 0x26, 0x6e, - 0x38, 0x50, 0x29, 0x6c, 0x90, 0xa7, 0xbd, 0xd9, - 0x16, 0x03, 0x01, 0x00, 0x09, 0x0d, 0x00, 0x00, - 0x05, 0x02, 0x01, 0x40, 0x00, 0x00, 0x16, 0x03, - 0x01, 0x00, 0x04, 0x0e, 0x00, 0x00, 0x00, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x07, 0x0b, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x16, 0x03, 0x01, 0x00, - 0x86, 0x10, 0x00, 0x00, 0x82, 0x00, 0x80, 0x36, - 0xfc, 0xd8, 0xc8, 0xa2, 0x67, 0xc8, 0xc6, 0xf4, - 0x28, 0x70, 0xe1, 0x5a, 0x02, 0x8f, 0xef, 0x42, - 0xe0, 0xd3, 0xb8, 0xd6, 0x6b, 0xe4, 0xee, 0x5c, - 0xcf, 0x42, 0xc4, 0xfa, 0xcd, 0x0f, 0xfe, 0xf4, - 0x76, 0x76, 0x47, 0x73, 0xa8, 0x72, 0x8f, 0xa2, - 0x56, 0x81, 0x83, 0xb8, 0x84, 0x72, 0x67, 0xdd, - 0xbe, 0x05, 0x4b, 0x84, 0xd9, 0xd2, 0xb6, 0xc2, - 0xe7, 0x20, 0xac, 0x1f, 0x46, 0x9d, 0x05, 0x47, - 0x8e, 0x89, 0xc0, 0x42, 0x57, 0x4a, 0xa2, 0x98, - 0xe5, 0x39, 0x4f, 0xc4, 0x27, 0x6d, 0x43, 0xa8, - 0x83, 0x76, 0xe6, 0xad, 0xe3, 0x17, 0x68, 0x31, - 0xcb, 0x7e, 0xfc, 0xe7, 0x4b, 0x76, 0x3d, 0x3c, - 0xfa, 0x77, 0x65, 0xc9, 0x4c, 0x5b, 0xce, 0x5e, - 0xf7, 0x8b, 0xa8, 0xa6, 0xdd, 0xb2, 0xef, 0x0b, - 0x46, 0x83, 0xdf, 0x0a, 0x8c, 0x22, 0x12, 0x6e, - 0xe1, 0x45, 0x54, 0x88, 0xd1, 0xe8, 0xd2, 0x14, - 0x03, 0x01, 0x00, 0x01, 0x01, 0x16, 0x03, 0x01, - 0x00, 0x24, 0x30, 0x8c, 0x7d, 0x40, 0xfc, 0x5e, - 0x80, 0x9c, 0xc4, 0x7c, 0x62, 0x01, 0xa1, 0x37, - 0xcf, 0x1a, 0x75, 0x28, 0x8d, 0xeb, 0x63, 0xcc, - 0x02, 0xa6, 0x66, 0xdf, 0x36, 0x01, 0xb3, 0x9d, - 0x38, 0x42, 0x16, 0x91, 0xf0, 0x02, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x72, 0x04, 0x00, 0x00, - 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, - 0xe8, 0x4b, 0xd1, 0xef, 0xba, 0x96, 0x9a, 0x2a, - 0x6c, 0x8c, 0x7e, 0x38, 0x10, 0x46, 0x86, 0x1d, - 0x19, 0x1d, 0x62, 0x29, 0x3f, 0x58, 0xfb, 0x6d, - 0x89, 0xd2, 0x81, 0x9a, 0x1c, 0xb3, 0x58, 0xb3, - 0x19, 0x39, 0x17, 0x47, 0x49, 0xc9, 0xfe, 0x4a, - 0x7a, 0x32, 0xac, 0x2c, 0x43, 0xf9, 0xa9, 0xea, - 0xec, 0x51, 0x46, 0xf1, 0xb8, 0x59, 0x23, 0x70, - 0xce, 0x7c, 0xb9, 0x47, 0x70, 0xa3, 0xc9, 0xae, - 0x47, 0x7b, 0x7e, 0xc7, 0xcf, 0x76, 0x12, 0x76, - 0x18, 0x90, 0x12, 0xcd, 0xf3, 0xd4, 0x27, 0x81, - 0xfc, 0x46, 0x03, 0x3e, 0x05, 0x87, 0x6f, 0x14, - 0x03, 0x01, 0x00, 0x01, 0x01, 0x16, 0x03, 0x01, - 0x00, 0x24, 0xc3, 0xa0, 0x29, 0xb1, 0x52, 0x82, - 0xef, 0x85, 0xa1, 0x64, 0x0f, 0xe4, 0xa3, 0xfb, - 0xa7, 0x1d, 0x22, 0x4c, 0xcb, 0xd6, 0x5b, 0x18, - 0x61, 0xc7, 0x7c, 0xf2, 0x67, 0x4a, 0xc7, 0x11, - 0x9d, 0x8e, 0x0e, 0x15, 0x22, 0xcf, 0x17, 0x03, - 0x01, 0x00, 0x21, 0xfd, 0xbb, 0xf1, 0xa9, 0x7c, - 0xbf, 0x92, 0xb3, 0xfa, 0x2c, 0x08, 0x6f, 0x22, - 0x78, 0x80, 0xf2, 0x2e, 0x86, 0x26, 0x21, 0x36, - 0x3f, 0x32, 0xdf, 0xb6, 0x47, 0xa5, 0xf8, 0x27, - 0xc1, 0xe9, 0x53, 0x90, 0x15, 0x03, 0x01, 0x00, - 0x16, 0xfe, 0xef, 0x2e, 0xa0, 0x5d, 0xe0, 0xce, - 0x94, 0x20, 0x56, 0x61, 0x6e, 0xe5, 0x62, 0xce, - 0x27, 0x57, 0x3e, 0x30, 0x32, 0x77, 0x53, - }, - }}, - - // Server asks for cert with empty CA list, client gives one - // go test -run "TestRunServer" -serve -clientauth 1 - {"RequestClientCert, client gives it", RequestClientCert, []*x509.Certificate{clientCertificate}, [][]byte{ - { - 0x16, 0x03, 0x01, 0x01, 0x1e, 0x01, 0x00, 0x01, - 0x1a, 0x03, 0x03, 0x51, 0xe5, 0x74, 0x0e, 0x95, - 0x6f, 0x4f, 0x4a, 0xbf, 0xb7, 0xc0, 0x6c, 0xac, - 0xd9, 0xfe, 0x7d, 0xd0, 0x51, 0x19, 0x62, 0x62, - 0x1c, 0x6e, 0x57, 0x77, 0xd2, 0x31, 0xaf, 0x88, - 0xb9, 0xc0, 0x1d, 0x00, 0x00, 0x82, 0xc0, 0x30, - 0xc0, 0x2c, 0xc0, 0x28, 0xc0, 0x24, 0xc0, 0x14, - 0xc0, 0x0a, 0x00, 0xa3, 0x00, 0x9f, 0x00, 0x6b, - 0x00, 0x6a, 0x00, 0x39, 0x00, 0x38, 0xc0, 0x32, - 0xc0, 0x2e, 0xc0, 0x2a, 0xc0, 0x26, 0xc0, 0x0f, - 0xc0, 0x05, 0x00, 0x9d, 0x00, 0x3d, 0x00, 0x35, - 0xc0, 0x12, 0xc0, 0x08, 0x00, 0x16, 0x00, 0x13, - 0xc0, 0x0d, 0xc0, 0x03, 0x00, 0x0a, 0xc0, 0x2f, - 0xc0, 0x2b, 0xc0, 0x27, 0xc0, 0x23, 0xc0, 0x13, - 0xc0, 0x09, 0x00, 0xa2, 0x00, 0x9e, 0x00, 0x67, - 0x00, 0x40, 0x00, 0x33, 0x00, 0x32, 0xc0, 0x31, - 0xc0, 0x2d, 0xc0, 0x29, 0xc0, 0x25, 0xc0, 0x0e, - 0xc0, 0x04, 0x00, 0x9c, 0x00, 0x3c, 0x00, 0x2f, - 0x00, 0x07, 0xc0, 0x11, 0xc0, 0x07, 0xc0, 0x0c, - 0xc0, 0x02, 0x00, 0x05, 0x00, 0x04, 0x00, 0x15, - 0x00, 0x12, 0x00, 0x09, 0x00, 0x14, 0x00, 0x11, - 0x00, 0x08, 0x00, 0x06, 0x00, 0x03, 0x00, 0xff, - 0x01, 0x00, 0x00, 0x6f, 0x00, 0x0b, 0x00, 0x04, - 0x03, 0x00, 0x01, 0x02, 0x00, 0x0a, 0x00, 0x34, - 0x00, 0x32, 0x00, 0x0e, 0x00, 0x0d, 0x00, 0x19, - 0x00, 0x0b, 0x00, 0x0c, 0x00, 0x18, 0x00, 0x09, - 0x00, 0x0a, 0x00, 0x16, 0x00, 0x17, 0x00, 0x08, - 0x00, 0x06, 0x00, 0x07, 0x00, 0x14, 0x00, 0x15, - 0x00, 0x04, 0x00, 0x05, 0x00, 0x12, 0x00, 0x13, - 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x0f, - 0x00, 0x10, 0x00, 0x11, 0x00, 0x23, 0x00, 0x00, - 0x00, 0x0d, 0x00, 0x22, 0x00, 0x20, 0x06, 0x01, - 0x06, 0x02, 0x06, 0x03, 0x05, 0x01, 0x05, 0x02, - 0x05, 0x03, 0x04, 0x01, 0x04, 0x02, 0x04, 0x03, - 0x03, 0x01, 0x03, 0x02, 0x03, 0x03, 0x02, 0x01, - 0x02, 0x02, 0x02, 0x03, 0x01, 0x01, 0x00, 0x0f, - 0x00, 0x01, 0x01, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x30, 0x02, 0x00, 0x00, - 0x2c, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, - 0x04, 0x00, 0x23, 0x00, 0x00, 0x16, 0x03, 0x01, - 0x02, 0xbe, 0x0b, 0x00, 0x02, 0xba, 0x00, 0x02, - 0xb7, 0x00, 0x02, 0xb4, 0x30, 0x82, 0x02, 0xb0, - 0x30, 0x82, 0x02, 0x19, 0xa0, 0x03, 0x02, 0x01, - 0x02, 0x02, 0x09, 0x00, 0x85, 0xb0, 0xbb, 0xa4, - 0x8a, 0x7f, 0xb8, 0xca, 0x30, 0x0d, 0x06, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x05, 0x05, 0x00, 0x30, 0x45, 0x31, 0x0b, 0x30, - 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, - 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, - 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, 0x6d, - 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, - 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, - 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, - 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, - 0x74, 0x64, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x30, - 0x30, 0x34, 0x32, 0x34, 0x30, 0x39, 0x30, 0x39, - 0x33, 0x38, 0x5a, 0x17, 0x0d, 0x31, 0x31, 0x30, - 0x34, 0x32, 0x34, 0x30, 0x39, 0x30, 0x39, 0x33, - 0x38, 0x5a, 0x30, 0x45, 0x31, 0x0b, 0x30, 0x09, - 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x41, - 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, - 0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, 0x6d, 0x65, - 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, 0x21, - 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, - 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, - 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, 0x74, - 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, 0x74, - 0x64, 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, - 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xbb, 0x79, - 0xd6, 0xf5, 0x17, 0xb5, 0xe5, 0xbf, 0x46, 0x10, - 0xd0, 0xdc, 0x69, 0xbe, 0xe6, 0x2b, 0x07, 0x43, - 0x5a, 0xd0, 0x03, 0x2d, 0x8a, 0x7a, 0x43, 0x85, - 0xb7, 0x14, 0x52, 0xe7, 0xa5, 0x65, 0x4c, 0x2c, - 0x78, 0xb8, 0x23, 0x8c, 0xb5, 0xb4, 0x82, 0xe5, - 0xde, 0x1f, 0x95, 0x3b, 0x7e, 0x62, 0xa5, 0x2c, - 0xa5, 0x33, 0xd6, 0xfe, 0x12, 0x5c, 0x7a, 0x56, - 0xfc, 0xf5, 0x06, 0xbf, 0xfa, 0x58, 0x7b, 0x26, - 0x3f, 0xb5, 0xcd, 0x04, 0xd3, 0xd0, 0xc9, 0x21, - 0x96, 0x4a, 0xc7, 0xf4, 0x54, 0x9f, 0x5a, 0xbf, - 0xef, 0x42, 0x71, 0x00, 0xfe, 0x18, 0x99, 0x07, - 0x7f, 0x7e, 0x88, 0x7d, 0x7d, 0xf1, 0x04, 0x39, - 0xc4, 0xa2, 0x2e, 0xdb, 0x51, 0xc9, 0x7c, 0xe3, - 0xc0, 0x4c, 0x3b, 0x32, 0x66, 0x01, 0xcf, 0xaf, - 0xb1, 0x1d, 0xb8, 0x71, 0x9a, 0x1d, 0xdb, 0xdb, - 0x89, 0x6b, 0xae, 0xda, 0x2d, 0x79, 0x02, 0x03, - 0x01, 0x00, 0x01, 0xa3, 0x81, 0xa7, 0x30, 0x81, - 0xa4, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, - 0x04, 0x16, 0x04, 0x14, 0xb1, 0xad, 0xe2, 0x85, - 0x5a, 0xcf, 0xcb, 0x28, 0xdb, 0x69, 0xce, 0x23, - 0x69, 0xde, 0xd3, 0x26, 0x8e, 0x18, 0x88, 0x39, - 0x30, 0x75, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, - 0x6e, 0x30, 0x6c, 0x80, 0x14, 0xb1, 0xad, 0xe2, - 0x85, 0x5a, 0xcf, 0xcb, 0x28, 0xdb, 0x69, 0xce, - 0x23, 0x69, 0xde, 0xd3, 0x26, 0x8e, 0x18, 0x88, - 0x39, 0xa1, 0x49, 0xa4, 0x47, 0x30, 0x45, 0x31, - 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, - 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, - 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, - 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, - 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, - 0x20, 0x4c, 0x74, 0x64, 0x82, 0x09, 0x00, 0x85, - 0xb0, 0xbb, 0xa4, 0x8a, 0x7f, 0xb8, 0xca, 0x30, - 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, - 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, - 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, - 0x01, 0x05, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, - 0x08, 0x6c, 0x45, 0x24, 0xc7, 0x6b, 0xb1, 0x59, - 0xab, 0x0c, 0x52, 0xcc, 0xf2, 0xb0, 0x14, 0xd7, - 0x87, 0x9d, 0x7a, 0x64, 0x75, 0xb5, 0x5a, 0x95, - 0x66, 0xe4, 0xc5, 0x2b, 0x8e, 0xae, 0x12, 0x66, - 0x1f, 0xeb, 0x4f, 0x38, 0xb3, 0x6e, 0x60, 0xd3, - 0x92, 0xfd, 0xf7, 0x41, 0x08, 0xb5, 0x25, 0x13, - 0xb1, 0x18, 0x7a, 0x24, 0xfb, 0x30, 0x1d, 0xba, - 0xed, 0x98, 0xb9, 0x17, 0xec, 0xe7, 0xd7, 0x31, - 0x59, 0xdb, 0x95, 0xd3, 0x1d, 0x78, 0xea, 0x50, - 0x56, 0x5c, 0xd5, 0x82, 0x5a, 0x2d, 0x5a, 0x5f, - 0x33, 0xc4, 0xb6, 0xd8, 0xc9, 0x75, 0x90, 0x96, - 0x8c, 0x0f, 0x52, 0x98, 0xb5, 0xcd, 0x98, 0x1f, - 0x89, 0x20, 0x5f, 0xf2, 0xa0, 0x1c, 0xa3, 0x1b, - 0x96, 0x94, 0xdd, 0xa9, 0xfd, 0x57, 0xe9, 0x70, - 0xe8, 0x26, 0x6d, 0x71, 0x99, 0x9b, 0x26, 0x6e, - 0x38, 0x50, 0x29, 0x6c, 0x90, 0xa7, 0xbd, 0xd9, - 0x16, 0x03, 0x01, 0x00, 0x09, 0x0d, 0x00, 0x00, - 0x05, 0x02, 0x01, 0x40, 0x00, 0x00, 0x16, 0x03, - 0x01, 0x00, 0x04, 0x0e, 0x00, 0x00, 0x00, - }, - { - 0x16, 0x03, 0x01, 0x01, 0xfb, 0x0b, 0x00, 0x01, - 0xf7, 0x00, 0x01, 0xf4, 0x00, 0x01, 0xf1, 0x30, - 0x82, 0x01, 0xed, 0x30, 0x82, 0x01, 0x58, 0xa0, - 0x03, 0x02, 0x01, 0x02, 0x02, 0x01, 0x00, 0x30, - 0x0b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, - 0x0d, 0x01, 0x01, 0x05, 0x30, 0x26, 0x31, 0x10, - 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, - 0x07, 0x41, 0x63, 0x6d, 0x65, 0x20, 0x43, 0x6f, - 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, - 0x03, 0x13, 0x09, 0x31, 0x32, 0x37, 0x2e, 0x30, - 0x2e, 0x30, 0x2e, 0x31, 0x30, 0x1e, 0x17, 0x0d, - 0x31, 0x31, 0x31, 0x32, 0x30, 0x38, 0x30, 0x37, - 0x35, 0x35, 0x31, 0x32, 0x5a, 0x17, 0x0d, 0x31, - 0x32, 0x31, 0x32, 0x30, 0x37, 0x30, 0x38, 0x30, - 0x30, 0x31, 0x32, 0x5a, 0x30, 0x26, 0x31, 0x10, - 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, - 0x07, 0x41, 0x63, 0x6d, 0x65, 0x20, 0x43, 0x6f, - 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, - 0x03, 0x13, 0x09, 0x31, 0x32, 0x37, 0x2e, 0x30, - 0x2e, 0x30, 0x2e, 0x31, 0x30, 0x81, 0x9c, 0x30, - 0x0b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, - 0x0d, 0x01, 0x01, 0x01, 0x03, 0x81, 0x8c, 0x00, - 0x30, 0x81, 0x88, 0x02, 0x81, 0x80, 0x4e, 0xd0, - 0x7b, 0x31, 0xe3, 0x82, 0x64, 0xd9, 0x59, 0xc0, - 0xc2, 0x87, 0xa4, 0x5e, 0x1e, 0x8b, 0x73, 0x33, - 0xc7, 0x63, 0x53, 0xdf, 0x66, 0x92, 0x06, 0x84, - 0xf6, 0x64, 0xd5, 0x8f, 0xe4, 0x36, 0xa7, 0x1d, - 0x2b, 0xe8, 0xb3, 0x20, 0x36, 0x45, 0x23, 0xb5, - 0xe3, 0x95, 0xae, 0xed, 0xe0, 0xf5, 0x20, 0x9c, - 0x8d, 0x95, 0xdf, 0x7f, 0x5a, 0x12, 0xef, 0x87, - 0xe4, 0x5b, 0x68, 0xe4, 0xe9, 0x0e, 0x74, 0xec, - 0x04, 0x8a, 0x7f, 0xde, 0x93, 0x27, 0xc4, 0x01, - 0x19, 0x7a, 0xbd, 0xf2, 0xdc, 0x3d, 0x14, 0xab, - 0xd0, 0x54, 0xca, 0x21, 0x0c, 0xd0, 0x4d, 0x6e, - 0x87, 0x2e, 0x5c, 0xc5, 0xd2, 0xbb, 0x4d, 0x4b, - 0x4f, 0xce, 0xb6, 0x2c, 0xf7, 0x7e, 0x88, 0xec, - 0x7c, 0xd7, 0x02, 0x91, 0x74, 0xa6, 0x1e, 0x0c, - 0x1a, 0xda, 0xe3, 0x4a, 0x5a, 0x2e, 0xde, 0x13, - 0x9c, 0x4c, 0x40, 0x88, 0x59, 0x93, 0x02, 0x03, - 0x01, 0x00, 0x01, 0xa3, 0x32, 0x30, 0x30, 0x30, - 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, - 0xff, 0x04, 0x04, 0x03, 0x02, 0x00, 0xa0, 0x30, - 0x0d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x06, - 0x04, 0x04, 0x01, 0x02, 0x03, 0x04, 0x30, 0x0f, - 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x08, 0x30, - 0x06, 0x80, 0x04, 0x01, 0x02, 0x03, 0x04, 0x30, - 0x0b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, - 0x0d, 0x01, 0x01, 0x05, 0x03, 0x81, 0x81, 0x00, - 0x36, 0x1f, 0xb3, 0x7a, 0x0c, 0x75, 0xc9, 0x6e, - 0x37, 0x46, 0x61, 0x2b, 0xd5, 0xbd, 0xc0, 0xa7, - 0x4b, 0xcc, 0x46, 0x9a, 0x81, 0x58, 0x7c, 0x85, - 0x79, 0x29, 0xc8, 0xc8, 0xc6, 0x67, 0xdd, 0x32, - 0x56, 0x45, 0x2b, 0x75, 0xb6, 0xe9, 0x24, 0xa9, - 0x50, 0x9a, 0xbe, 0x1f, 0x5a, 0xfa, 0x1a, 0x15, - 0xd9, 0xcc, 0x55, 0x95, 0x72, 0x16, 0x83, 0xb9, - 0xc2, 0xb6, 0x8f, 0xfd, 0x88, 0x8c, 0x38, 0x84, - 0x1d, 0xab, 0x5d, 0x92, 0x31, 0x13, 0x4f, 0xfd, - 0x83, 0x3b, 0xc6, 0x9d, 0xf1, 0x11, 0x62, 0xb6, - 0x8b, 0xec, 0xab, 0x67, 0xbe, 0xc8, 0x64, 0xb0, - 0x11, 0x50, 0x46, 0x58, 0x17, 0x6b, 0x99, 0x1c, - 0xd3, 0x1d, 0xfc, 0x06, 0xf1, 0x0e, 0xe5, 0x96, - 0xa8, 0x0c, 0xf9, 0x78, 0x20, 0xb7, 0x44, 0x18, - 0x51, 0x8d, 0x10, 0x7e, 0x4f, 0x94, 0x67, 0xdf, - 0xa3, 0x4e, 0x70, 0x73, 0x8e, 0x90, 0x91, 0x85, - 0x16, 0x03, 0x01, 0x00, 0x86, 0x10, 0x00, 0x00, - 0x82, 0x00, 0x80, 0x0a, 0x4e, 0x89, 0xdf, 0x3a, - 0x3f, 0xf0, 0x4f, 0xef, 0x1a, 0x90, 0xd4, 0x3c, - 0xaf, 0x10, 0x57, 0xb0, 0xa1, 0x5f, 0xcd, 0x62, - 0x01, 0xe9, 0x0c, 0x36, 0x42, 0xfd, 0xaf, 0x23, - 0xf9, 0x14, 0xa6, 0x72, 0x26, 0x4e, 0x01, 0xdb, - 0xac, 0xb7, 0x4c, 0xe6, 0xa9, 0x52, 0xe2, 0xec, - 0x26, 0x8c, 0x7a, 0x64, 0xf8, 0x0b, 0x4c, 0x2f, - 0xa9, 0xcb, 0x75, 0xaf, 0x60, 0xd4, 0xb4, 0xe6, - 0xe8, 0xdb, 0x78, 0x78, 0x85, 0xf6, 0x0c, 0x95, - 0xcc, 0xb6, 0x55, 0xb9, 0xba, 0x9e, 0x91, 0xbc, - 0x66, 0xdb, 0x1e, 0x28, 0xab, 0x73, 0xce, 0x8b, - 0xd0, 0xd3, 0xe8, 0xbc, 0xd0, 0x21, 0x28, 0xbd, - 0xfb, 0x74, 0x64, 0xde, 0x3b, 0x3b, 0xd3, 0x4c, - 0x32, 0x40, 0x82, 0xba, 0x91, 0x1e, 0xe8, 0x47, - 0xc2, 0x09, 0xb7, 0x16, 0xaa, 0x25, 0xa9, 0x3c, - 0x6c, 0xa7, 0xf8, 0xc9, 0x54, 0x84, 0xc6, 0xf7, - 0x56, 0x05, 0xa4, 0x16, 0x03, 0x01, 0x00, 0x86, - 0x0f, 0x00, 0x00, 0x82, 0x00, 0x80, 0x4b, 0xab, - 0xda, 0xac, 0x2a, 0xb3, 0xe6, 0x34, 0x55, 0xcd, - 0xf2, 0x4b, 0x67, 0xe3, 0xd3, 0xff, 0xa3, 0xf4, - 0x79, 0x82, 0x01, 0x47, 0x8a, 0xe3, 0x9f, 0x89, - 0x70, 0xbe, 0x24, 0x24, 0xb7, 0x69, 0x60, 0xed, - 0x55, 0xa0, 0xca, 0x72, 0xb6, 0x4a, 0xbc, 0x1d, - 0xe2, 0x3f, 0xb5, 0x31, 0xda, 0x02, 0xf6, 0x37, - 0x51, 0xf8, 0x4c, 0x88, 0x2e, 0xb3, 0x8a, 0xe8, - 0x7b, 0x4a, 0x90, 0x36, 0xe4, 0xa6, 0x31, 0x95, - 0x8b, 0xa0, 0xc6, 0x91, 0x12, 0xb9, 0x35, 0x4e, - 0x72, 0xeb, 0x5c, 0xa2, 0xe8, 0x4c, 0x68, 0xf9, - 0x69, 0xfa, 0x70, 0x60, 0x6c, 0x7f, 0x32, 0x99, - 0xf1, 0xc3, 0x2d, 0xb4, 0x59, 0x58, 0x87, 0xaf, - 0x67, 0x62, 0x90, 0xe7, 0x8d, 0xd0, 0xa3, 0x77, - 0x33, 0xc2, 0x9b, 0xd5, 0x9c, 0xc7, 0xea, 0x25, - 0x98, 0x76, 0x9c, 0xe0, 0x6a, 0x03, 0x3a, 0x10, - 0xfd, 0x10, 0x3d, 0x55, 0x53, 0xa0, 0x14, 0x03, - 0x01, 0x00, 0x01, 0x01, 0x16, 0x03, 0x01, 0x00, - 0x24, 0xd5, 0x12, 0xfc, 0xb9, 0x5a, 0xe3, 0x27, - 0x01, 0xbe, 0xc3, 0x77, 0x17, 0x1a, 0xbb, 0x4f, - 0xae, 0xd5, 0xa7, 0xee, 0x56, 0x61, 0x0d, 0x40, - 0xf4, 0xa4, 0xb5, 0xcc, 0x76, 0xfd, 0xbd, 0x13, - 0x04, 0xe1, 0xb8, 0xc7, 0x36, - }, - { - 0x16, 0x03, 0x01, 0x02, 0x67, 0x04, 0x00, 0x02, - 0x63, 0x00, 0x00, 0x00, 0x00, 0x02, 0x5d, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, - 0xe8, 0x4b, 0xd1, 0xef, 0xba, 0x1f, 0xe2, 0x69, - 0x07, 0x7f, 0x85, 0x2d, 0x4e, 0x2a, 0x2e, 0xbd, - 0x05, 0xe9, 0xc1, 0x6c, 0x9e, 0xbf, 0x47, 0x18, - 0x91, 0x77, 0xf7, 0xe8, 0xb6, 0x27, 0x37, 0xa6, - 0x6b, 0x87, 0x29, 0xbb, 0x3b, 0xe5, 0x68, 0x62, - 0x04, 0x3e, 0xad, 0x4d, 0xff, 0xad, 0xf1, 0x22, - 0x87, 0x8d, 0xf6, 0x04, 0x3b, 0x59, 0x22, 0xf7, - 0xfd, 0x88, 0x0e, 0xa4, 0x09, 0xc0, 0x0d, 0x10, - 0x80, 0x10, 0x79, 0xee, 0x70, 0x96, 0xdb, 0x22, - 0x8b, 0xb7, 0xac, 0xe0, 0x98, 0xad, 0xe9, 0xe3, - 0xcb, 0xea, 0x9f, 0xe6, 0x83, 0x28, 0x7c, 0x7e, - 0x4e, 0x9a, 0x8d, 0xd9, 0xf3, 0x86, 0xf4, 0x89, - 0x8b, 0x79, 0x8f, 0xbb, 0xe9, 0x74, 0x02, 0x02, - 0x14, 0x04, 0xea, 0xba, 0x16, 0x10, 0xa1, 0x85, - 0xbe, 0x4e, 0x4e, 0x92, 0xc5, 0x83, 0xf6, 0x1e, - 0x1f, 0xd4, 0x25, 0xc2, 0xc2, 0xb9, 0xce, 0x33, - 0x63, 0x66, 0x79, 0x1f, 0x54, 0x35, 0xc1, 0xe8, - 0x89, 0x34, 0x78, 0x94, 0x36, 0x14, 0xef, 0x01, - 0x1f, 0xf1, 0xbd, 0x77, 0x2c, 0x4d, 0xac, 0x5c, - 0x5c, 0x4a, 0xc6, 0xed, 0xd8, 0x0e, 0x72, 0x84, - 0x83, 0xdc, 0x56, 0x84, 0xc8, 0xf3, 0x89, 0x56, - 0xfd, 0x89, 0xc1, 0xc9, 0x9a, 0x29, 0x91, 0x7e, - 0x19, 0xe9, 0x8b, 0x5b, 0x11, 0x15, 0x4e, 0x6c, - 0xf4, 0x89, 0xe7, 0x6d, 0x68, 0x1e, 0xf9, 0x6c, - 0x23, 0x72, 0x05, 0x68, 0x82, 0x60, 0x84, 0x1f, - 0x83, 0x20, 0x09, 0x86, 0x10, 0x81, 0xec, 0xec, - 0xdc, 0x25, 0x53, 0x20, 0xfa, 0xa9, 0x41, 0x64, - 0xd6, 0x20, 0xf3, 0xf4, 0x52, 0xf2, 0x80, 0x62, - 0x83, 0xc9, 0x23, 0x66, 0x44, 0x95, 0x5a, 0x99, - 0x8a, 0xe1, 0x26, 0x63, 0xc1, 0x8b, 0x31, 0xf9, - 0x21, 0x06, 0x77, 0x04, 0x27, 0xf2, 0x0c, 0x63, - 0x83, 0x45, 0xa0, 0xa9, 0x7b, 0xcf, 0xdf, 0xd7, - 0x56, 0x75, 0xbc, 0xdd, 0x95, 0x36, 0xb1, 0x75, - 0x39, 0x05, 0x00, 0x3c, 0x8a, 0x79, 0xd6, 0xe9, - 0xf0, 0x4b, 0xdc, 0x51, 0x6b, 0x01, 0x94, 0x16, - 0x87, 0x12, 0x92, 0x6c, 0x07, 0xc1, 0xf5, 0x58, - 0xb7, 0x2a, 0x81, 0xf5, 0xa0, 0x37, 0x8b, 0xa6, - 0x22, 0xfe, 0x28, 0x0a, 0x7e, 0x68, 0xe2, 0xda, - 0x6c, 0x53, 0xee, 0x0e, 0x8d, 0x2d, 0x8b, 0x0b, - 0xda, 0xf8, 0x99, 0x3e, 0x0e, 0xed, 0x9f, 0xc1, - 0x2b, 0xf6, 0xfe, 0xe9, 0x52, 0x38, 0x7b, 0x83, - 0x9a, 0x50, 0xa6, 0xd7, 0x49, 0x83, 0x43, 0x7e, - 0x82, 0xec, 0xc7, 0x09, 0x3d, 0x3d, 0xb1, 0xee, - 0xe8, 0xc5, 0x6a, 0xc3, 0x3d, 0x4b, 0x4c, 0x6a, - 0xbb, 0x0b, 0x2c, 0x24, 0x2e, 0xdb, 0x7d, 0x57, - 0x87, 0xb4, 0x80, 0xa5, 0xae, 0xff, 0x54, 0xa8, - 0xa5, 0x27, 0x69, 0x95, 0xc8, 0xe7, 0x79, 0xc7, - 0x89, 0x2a, 0x73, 0x49, 0xcb, 0xf5, 0xc5, 0xbc, - 0x4a, 0xe0, 0x73, 0xa9, 0xbc, 0x88, 0x64, 0x96, - 0x98, 0xa5, 0x1e, 0xe3, 0x43, 0xc1, 0x7d, 0x78, - 0xc7, 0x94, 0x72, 0xd4, 0x2c, 0x6e, 0x85, 0x39, - 0x9a, 0xaf, 0xdb, 0xa1, 0xe9, 0xe2, 0xcb, 0x37, - 0x04, 0xc6, 0x8c, 0x81, 0xd3, 0x2a, 0xb7, 0xbe, - 0x6c, 0x07, 0x1f, 0x5e, 0xd9, 0x00, 0xd2, 0xf7, - 0xe1, 0xa7, 0xbc, 0x0c, 0xb6, 0x6d, 0xfb, 0x3f, - 0x3d, 0x24, 0xaa, 0xfb, 0x7e, 0xe1, 0xb5, 0x1b, - 0xff, 0x38, 0xaa, 0x69, 0x59, 0x38, 0x52, 0x9a, - 0x0e, 0x6d, 0xbc, 0xde, 0x4f, 0x13, 0x09, 0x17, - 0xc4, 0xa9, 0x05, 0x84, 0xbc, 0x50, 0xef, 0x40, - 0xb0, 0x4c, 0x24, 0x32, 0xed, 0x94, 0x2c, 0xdd, - 0xda, 0x20, 0x24, 0x67, 0xe2, 0xea, 0x71, 0x3d, - 0x4a, 0x04, 0x0d, 0x98, 0x29, 0x20, 0x4c, 0xeb, - 0x70, 0xce, 0x45, 0x9e, 0x5a, 0xaf, 0xb6, 0xa3, - 0x92, 0xc8, 0x28, 0xf2, 0xe3, 0xe8, 0x8a, 0x5d, - 0x0a, 0x33, 0x79, 0x9b, 0x6a, 0xf3, 0x30, 0x01, - 0x1d, 0x47, 0xbd, 0x01, 0xcc, 0x4d, 0x71, 0xc0, - 0x56, 0xfa, 0xfd, 0x37, 0xed, 0x0f, 0x27, 0xc0, - 0xbb, 0xa0, 0xee, 0xc3, 0x79, 0x8b, 0xe7, 0x41, - 0x8f, 0xfa, 0x3a, 0xcb, 0x45, 0x3b, 0x85, 0x9f, - 0x06, 0x90, 0xb2, 0x51, 0x7a, 0xc3, 0x11, 0x41, - 0x4b, 0xe3, 0x26, 0x94, 0x3e, 0xa2, 0xfd, 0x0a, - 0xda, 0x50, 0xf6, 0x50, 0x78, 0x19, 0x6c, 0x52, - 0xd1, 0x12, 0x76, 0xc2, 0x50, 0x2f, 0x0b, 0xca, - 0x33, 0xe5, 0x79, 0x93, 0x14, 0x03, 0x01, 0x00, - 0x01, 0x01, 0x16, 0x03, 0x01, 0x00, 0x24, 0x2b, - 0x51, 0x42, 0x95, 0x6b, 0xca, 0x9f, 0x42, 0x5d, - 0xd2, 0xd9, 0x67, 0xf9, 0x49, 0x30, 0xfd, 0x2a, - 0x46, 0xd3, 0x04, 0xf4, 0x86, 0xf9, 0x11, 0x34, - 0x82, 0xac, 0xe2, 0xc2, 0x2d, 0xc4, 0xd0, 0xfe, - 0xa9, 0xc9, 0x4b, 0x17, 0x03, 0x01, 0x00, 0x21, - 0x65, 0x1c, 0xe9, 0x5c, 0xb6, 0xe2, 0x7c, 0x8e, - 0x49, 0x12, 0x1b, 0xe6, 0x40, 0xd3, 0x97, 0x21, - 0x76, 0x01, 0xe5, 0x80, 0x5e, 0xf3, 0x11, 0x47, - 0x25, 0x02, 0x78, 0x8e, 0x6b, 0xae, 0xb3, 0xf3, - 0x59, 0x15, 0x03, 0x01, 0x00, 0x16, 0x38, 0xc1, - 0x99, 0x2e, 0xf8, 0x6f, 0x45, 0xa4, 0x10, 0x79, - 0x5b, 0xc1, 0x47, 0x9a, 0xf6, 0x5c, 0x90, 0xeb, - 0xa6, 0xe3, 0x1a, 0x24, - }, - }}, -} - -var tls11ECDHEAESServerScript = [][]byte{ - { - 0x16, 0x03, 0x01, 0x01, 0x46, 0x01, 0x00, 0x01, - 0x42, 0x03, 0x03, 0x51, 0x9f, 0xa3, 0xb0, 0xb7, - 0x1d, 0x26, 0x93, 0x36, 0xc0, 0x8d, 0x7e, 0xf8, - 0x4f, 0x6f, 0xc9, 0x3c, 0x31, 0x1e, 0x7f, 0xb1, - 0xf0, 0xc1, 0x0f, 0xf9, 0x0c, 0xa2, 0xd5, 0xca, - 0x48, 0xe5, 0x35, 0x00, 0x00, 0xd0, 0xc0, 0x30, - 0xc0, 0x2c, 0xc0, 0x28, 0xc0, 0x24, 0xc0, 0x14, - 0xc0, 0x0a, 0xc0, 0x22, 0xc0, 0x21, 0x00, 0xa5, - 0x00, 0xa3, 0x00, 0xa1, 0x00, 0x9f, 0x00, 0x6b, - 0x00, 0x6a, 0x00, 0x69, 0x00, 0x68, 0x00, 0x39, - 0x00, 0x38, 0x00, 0x37, 0x00, 0x36, 0x00, 0x88, - 0x00, 0x87, 0x00, 0x86, 0x00, 0x85, 0xc0, 0x32, - 0xc0, 0x2e, 0xc0, 0x2a, 0xc0, 0x26, 0xc0, 0x0f, - 0xc0, 0x05, 0x00, 0x9d, 0x00, 0x3d, 0x00, 0x35, - 0x00, 0x84, 0xc0, 0x12, 0xc0, 0x08, 0xc0, 0x1c, - 0xc0, 0x1b, 0x00, 0x16, 0x00, 0x13, 0x00, 0x10, - 0x00, 0x0d, 0xc0, 0x0d, 0xc0, 0x03, 0x00, 0x0a, - 0xc0, 0x2f, 0xc0, 0x2b, 0xc0, 0x27, 0xc0, 0x23, - 0xc0, 0x13, 0xc0, 0x09, 0xc0, 0x1f, 0xc0, 0x1e, - 0x00, 0xa4, 0x00, 0xa2, 0x00, 0xa0, 0x00, 0x9e, - 0x00, 0x67, 0x00, 0x40, 0x00, 0x3f, 0x00, 0x3e, - 0x00, 0x33, 0x00, 0x32, 0x00, 0x31, 0x00, 0x30, - 0x00, 0x9a, 0x00, 0x99, 0x00, 0x98, 0x00, 0x97, - 0x00, 0x45, 0x00, 0x44, 0x00, 0x43, 0x00, 0x42, - 0xc0, 0x31, 0xc0, 0x2d, 0xc0, 0x29, 0xc0, 0x25, - 0xc0, 0x0e, 0xc0, 0x04, 0x00, 0x9c, 0x00, 0x3c, - 0x00, 0x2f, 0x00, 0x96, 0x00, 0x41, 0x00, 0x07, - 0xc0, 0x11, 0xc0, 0x07, 0xc0, 0x0c, 0xc0, 0x02, - 0x00, 0x05, 0x00, 0x04, 0x00, 0x15, 0x00, 0x12, - 0x00, 0x0f, 0x00, 0x0c, 0x00, 0x09, 0x00, 0x14, - 0x00, 0x11, 0x00, 0x0e, 0x00, 0x0b, 0x00, 0x08, - 0x00, 0x06, 0x00, 0x03, 0x00, 0xff, 0x01, 0x00, - 0x00, 0x49, 0x00, 0x0b, 0x00, 0x04, 0x03, 0x00, - 0x01, 0x02, 0x00, 0x0a, 0x00, 0x34, 0x00, 0x32, - 0x00, 0x0e, 0x00, 0x0d, 0x00, 0x19, 0x00, 0x0b, - 0x00, 0x0c, 0x00, 0x18, 0x00, 0x09, 0x00, 0x0a, - 0x00, 0x16, 0x00, 0x17, 0x00, 0x08, 0x00, 0x06, - 0x00, 0x07, 0x00, 0x14, 0x00, 0x15, 0x00, 0x04, - 0x00, 0x05, 0x00, 0x12, 0x00, 0x13, 0x00, 0x01, - 0x00, 0x02, 0x00, 0x03, 0x00, 0x0f, 0x00, 0x10, - 0x00, 0x11, 0x00, 0x23, 0x00, 0x00, 0x00, 0x0f, - 0x00, 0x01, 0x01, - }, - { - 0x16, 0x03, 0x02, 0x00, 0x30, 0x02, 0x00, 0x00, - 0x2c, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xc0, 0x13, 0x00, 0x00, - 0x04, 0x00, 0x23, 0x00, 0x00, 0x16, 0x03, 0x02, - 0x02, 0xbe, 0x0b, 0x00, 0x02, 0xba, 0x00, 0x02, - 0xb7, 0x00, 0x02, 0xb4, 0x30, 0x82, 0x02, 0xb0, - 0x30, 0x82, 0x02, 0x19, 0xa0, 0x03, 0x02, 0x01, - 0x02, 0x02, 0x09, 0x00, 0x85, 0xb0, 0xbb, 0xa4, - 0x8a, 0x7f, 0xb8, 0xca, 0x30, 0x0d, 0x06, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x05, 0x05, 0x00, 0x30, 0x45, 0x31, 0x0b, 0x30, - 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, - 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, - 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, 0x6d, - 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, - 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, - 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, - 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, - 0x74, 0x64, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x30, - 0x30, 0x34, 0x32, 0x34, 0x30, 0x39, 0x30, 0x39, - 0x33, 0x38, 0x5a, 0x17, 0x0d, 0x31, 0x31, 0x30, - 0x34, 0x32, 0x34, 0x30, 0x39, 0x30, 0x39, 0x33, - 0x38, 0x5a, 0x30, 0x45, 0x31, 0x0b, 0x30, 0x09, - 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x41, - 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, - 0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, 0x6d, 0x65, - 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, 0x21, - 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, - 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, - 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, 0x74, - 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, 0x74, - 0x64, 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, - 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xbb, 0x79, - 0xd6, 0xf5, 0x17, 0xb5, 0xe5, 0xbf, 0x46, 0x10, - 0xd0, 0xdc, 0x69, 0xbe, 0xe6, 0x2b, 0x07, 0x43, - 0x5a, 0xd0, 0x03, 0x2d, 0x8a, 0x7a, 0x43, 0x85, - 0xb7, 0x14, 0x52, 0xe7, 0xa5, 0x65, 0x4c, 0x2c, - 0x78, 0xb8, 0x23, 0x8c, 0xb5, 0xb4, 0x82, 0xe5, - 0xde, 0x1f, 0x95, 0x3b, 0x7e, 0x62, 0xa5, 0x2c, - 0xa5, 0x33, 0xd6, 0xfe, 0x12, 0x5c, 0x7a, 0x56, - 0xfc, 0xf5, 0x06, 0xbf, 0xfa, 0x58, 0x7b, 0x26, - 0x3f, 0xb5, 0xcd, 0x04, 0xd3, 0xd0, 0xc9, 0x21, - 0x96, 0x4a, 0xc7, 0xf4, 0x54, 0x9f, 0x5a, 0xbf, - 0xef, 0x42, 0x71, 0x00, 0xfe, 0x18, 0x99, 0x07, - 0x7f, 0x7e, 0x88, 0x7d, 0x7d, 0xf1, 0x04, 0x39, - 0xc4, 0xa2, 0x2e, 0xdb, 0x51, 0xc9, 0x7c, 0xe3, - 0xc0, 0x4c, 0x3b, 0x32, 0x66, 0x01, 0xcf, 0xaf, - 0xb1, 0x1d, 0xb8, 0x71, 0x9a, 0x1d, 0xdb, 0xdb, - 0x89, 0x6b, 0xae, 0xda, 0x2d, 0x79, 0x02, 0x03, - 0x01, 0x00, 0x01, 0xa3, 0x81, 0xa7, 0x30, 0x81, - 0xa4, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, - 0x04, 0x16, 0x04, 0x14, 0xb1, 0xad, 0xe2, 0x85, - 0x5a, 0xcf, 0xcb, 0x28, 0xdb, 0x69, 0xce, 0x23, - 0x69, 0xde, 0xd3, 0x26, 0x8e, 0x18, 0x88, 0x39, - 0x30, 0x75, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, - 0x6e, 0x30, 0x6c, 0x80, 0x14, 0xb1, 0xad, 0xe2, - 0x85, 0x5a, 0xcf, 0xcb, 0x28, 0xdb, 0x69, 0xce, - 0x23, 0x69, 0xde, 0xd3, 0x26, 0x8e, 0x18, 0x88, - 0x39, 0xa1, 0x49, 0xa4, 0x47, 0x30, 0x45, 0x31, - 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, - 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, - 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, - 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, - 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, - 0x20, 0x4c, 0x74, 0x64, 0x82, 0x09, 0x00, 0x85, - 0xb0, 0xbb, 0xa4, 0x8a, 0x7f, 0xb8, 0xca, 0x30, - 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, - 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, - 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, - 0x01, 0x05, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, - 0x08, 0x6c, 0x45, 0x24, 0xc7, 0x6b, 0xb1, 0x59, - 0xab, 0x0c, 0x52, 0xcc, 0xf2, 0xb0, 0x14, 0xd7, - 0x87, 0x9d, 0x7a, 0x64, 0x75, 0xb5, 0x5a, 0x95, - 0x66, 0xe4, 0xc5, 0x2b, 0x8e, 0xae, 0x12, 0x66, - 0x1f, 0xeb, 0x4f, 0x38, 0xb3, 0x6e, 0x60, 0xd3, - 0x92, 0xfd, 0xf7, 0x41, 0x08, 0xb5, 0x25, 0x13, - 0xb1, 0x18, 0x7a, 0x24, 0xfb, 0x30, 0x1d, 0xba, - 0xed, 0x98, 0xb9, 0x17, 0xec, 0xe7, 0xd7, 0x31, - 0x59, 0xdb, 0x95, 0xd3, 0x1d, 0x78, 0xea, 0x50, - 0x56, 0x5c, 0xd5, 0x82, 0x5a, 0x2d, 0x5a, 0x5f, - 0x33, 0xc4, 0xb6, 0xd8, 0xc9, 0x75, 0x90, 0x96, - 0x8c, 0x0f, 0x52, 0x98, 0xb5, 0xcd, 0x98, 0x1f, - 0x89, 0x20, 0x5f, 0xf2, 0xa0, 0x1c, 0xa3, 0x1b, - 0x96, 0x94, 0xdd, 0xa9, 0xfd, 0x57, 0xe9, 0x70, - 0xe8, 0x26, 0x6d, 0x71, 0x99, 0x9b, 0x26, 0x6e, - 0x38, 0x50, 0x29, 0x6c, 0x90, 0xa7, 0xbd, 0xd9, - 0x16, 0x03, 0x02, 0x01, 0x0f, 0x0c, 0x00, 0x01, - 0x0b, 0x03, 0x00, 0x19, 0x85, 0x04, 0x01, 0x39, - 0xdc, 0xee, 0x44, 0x17, 0x5e, 0xdb, 0xd7, 0x27, - 0xaf, 0xb6, 0x56, 0xd9, 0xb4, 0x43, 0x5a, 0x99, - 0xcf, 0xaa, 0x31, 0x37, 0x0c, 0x6f, 0x3a, 0xa0, - 0xf8, 0x53, 0xc4, 0x74, 0xd1, 0x91, 0x0a, 0x46, - 0xf5, 0x38, 0x3b, 0x5c, 0x09, 0xd8, 0x97, 0xdc, - 0x4b, 0xaa, 0x70, 0x26, 0x48, 0xf2, 0xd6, 0x0b, - 0x31, 0xc9, 0xf8, 0xd4, 0x98, 0x43, 0xe1, 0x6c, - 0xd5, 0xc7, 0xb2, 0x8e, 0x0b, 0x01, 0xe6, 0xb6, - 0x00, 0x28, 0x80, 0x7b, 0xfc, 0x96, 0x8f, 0x0d, - 0xa2, 0x4f, 0xb0, 0x79, 0xaf, 0xdc, 0x61, 0x28, - 0x63, 0x33, 0x78, 0xf6, 0x31, 0x39, 0xfd, 0x8a, - 0xf4, 0x15, 0x18, 0x11, 0xfe, 0xdb, 0xd5, 0x07, - 0xda, 0x2c, 0xed, 0x49, 0xa0, 0x23, 0xbf, 0xd0, - 0x3a, 0x38, 0x1d, 0x54, 0xae, 0x1c, 0x7b, 0xea, - 0x29, 0xee, 0xd0, 0x38, 0xc1, 0x76, 0xa7, 0x7f, - 0x2a, 0xf4, 0xce, 0x1e, 0xac, 0xcc, 0x94, 0x79, - 0x90, 0x33, 0x00, 0x80, 0x16, 0x83, 0x9b, 0xf9, - 0x72, 0xdb, 0x9f, 0x55, 0x02, 0xe1, 0x04, 0xf7, - 0xb5, 0x3f, 0x4c, 0x71, 0x13, 0x5a, 0x91, 0xe9, - 0x1d, 0xeb, 0x9d, 0x9c, 0xfb, 0x88, 0xef, 0xca, - 0xec, 0x7d, 0x9b, 0xdd, 0xd9, 0xee, 0x2b, 0x8e, - 0xef, 0xf8, 0xb6, 0xc7, 0x7d, 0xfe, 0xda, 0x7f, - 0x90, 0x2e, 0x53, 0xf1, 0x64, 0x95, 0xfc, 0x66, - 0xfc, 0x87, 0x27, 0xb6, 0x9f, 0xc8, 0x3a, 0x95, - 0x68, 0x17, 0xe1, 0x7d, 0xf1, 0x88, 0xe8, 0x17, - 0x5f, 0x99, 0x90, 0x3f, 0x47, 0x47, 0x81, 0x06, - 0xe2, 0x8e, 0x22, 0x56, 0x8f, 0xc2, 0x14, 0xe5, - 0x62, 0xa7, 0x0d, 0x41, 0x3c, 0xc7, 0x4a, 0x0a, - 0x74, 0x4b, 0xda, 0x00, 0x8e, 0x4f, 0x90, 0xe6, - 0xd7, 0x68, 0xe5, 0x8b, 0xf2, 0x3f, 0x53, 0x1d, - 0x7a, 0xe6, 0xb3, 0xe9, 0x8a, 0xc9, 0x4d, 0x19, - 0xa6, 0xcf, 0xf9, 0xed, 0x5e, 0x26, 0xdc, 0x90, - 0x1c, 0x41, 0xad, 0x7c, 0x16, 0x03, 0x02, 0x00, - 0x04, 0x0e, 0x00, 0x00, 0x00, - }, - { - 0x16, 0x03, 0x02, 0x00, 0x8a, 0x10, 0x00, 0x00, - 0x86, 0x85, 0x04, 0x01, 0x11, 0xf2, 0xa4, 0x2d, - 0x1a, 0x75, 0x6c, 0xbc, 0x2d, 0x91, 0x95, 0x07, - 0xbe, 0xd6, 0x41, 0x7a, 0xbb, 0xc2, 0x7b, 0xa6, - 0x9b, 0xe3, 0xdc, 0x41, 0x7f, 0x1e, 0x2e, 0xcc, - 0x6d, 0xa3, 0x85, 0x53, 0x98, 0x9f, 0x2d, 0xe6, - 0x3c, 0xb9, 0x82, 0xa6, 0x80, 0x53, 0x9b, 0x71, - 0xfd, 0x27, 0xe5, 0xe5, 0xdf, 0x13, 0xba, 0x56, - 0x62, 0x30, 0x4a, 0x57, 0x27, 0xa7, 0xcc, 0x26, - 0x54, 0xe8, 0x65, 0x6e, 0x4d, 0x00, 0xbf, 0x8a, - 0xcc, 0x89, 0x6a, 0x6c, 0x88, 0xda, 0x79, 0x4f, - 0xc5, 0xad, 0x6d, 0x1d, 0x7c, 0x53, 0x7b, 0x1a, - 0x96, 0xf2, 0xf8, 0x30, 0x01, 0x0b, 0xc2, 0xf0, - 0x78, 0x41, 0xf4, 0x0d, 0xe0, 0xbe, 0xb9, 0x36, - 0xe0, 0xb7, 0xee, 0x16, 0xeb, 0x25, 0x67, 0x04, - 0xc0, 0x2e, 0xd8, 0x34, 0x4a, 0x65, 0xa5, 0xf1, - 0x95, 0x75, 0xc7, 0x39, 0xa9, 0x68, 0xa9, 0x53, - 0x93, 0x5b, 0xca, 0x7b, 0x7f, 0xc0, 0x63, 0x14, - 0x03, 0x02, 0x00, 0x01, 0x01, 0x16, 0x03, 0x02, - 0x00, 0x40, 0x01, 0xb1, 0xae, 0x1b, 0x8a, 0x65, - 0xf8, 0x37, 0x50, 0x39, 0x76, 0xef, 0xaa, 0xda, - 0x84, 0xc9, 0x5f, 0x80, 0xdc, 0xfa, 0xe0, 0x46, - 0x5a, 0xc7, 0x77, 0x9d, 0x76, 0x03, 0xa6, 0xd5, - 0x0e, 0xbf, 0x25, 0x30, 0x5c, 0x99, 0x7d, 0xcd, - 0x2b, 0xaa, 0x2e, 0x8c, 0xdd, 0xda, 0xaa, 0xd7, - 0xf1, 0xf6, 0x33, 0x47, 0x51, 0x1e, 0x83, 0xa1, - 0x83, 0x04, 0xd2, 0xb2, 0xc8, 0xbc, 0x11, 0xc5, - 0x1a, 0x87, - }, - { - 0x16, 0x03, 0x02, 0x00, 0x72, 0x04, 0x00, 0x00, - 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, - 0xeb, 0x8b, 0xc7, 0xef, 0xba, 0xe8, 0x0f, 0x69, - 0xfe, 0xfb, 0xc3, 0x3d, 0x90, 0x5d, 0xd7, 0xb2, - 0x51, 0x64, 0xac, 0xc3, 0xae, 0x33, 0x03, 0x42, - 0x45, 0x2d, 0xa7, 0x57, 0xbd, 0xa3, 0x85, 0x64, - 0xa6, 0xfe, 0x5c, 0x33, 0x04, 0x93, 0xf2, 0x7c, - 0x06, 0x6d, 0xd7, 0xd7, 0xcf, 0x4a, 0xaf, 0xb2, - 0xdd, 0x06, 0xdc, 0x28, 0x14, 0x59, 0x23, 0x02, - 0xef, 0x97, 0x6a, 0xe8, 0xec, 0xca, 0x10, 0x44, - 0xcd, 0xb8, 0x50, 0x16, 0x46, 0x5a, 0x05, 0xda, - 0x04, 0xb3, 0x0e, 0xe9, 0xf0, 0x74, 0xc5, 0x23, - 0xc2, 0x0e, 0xa1, 0x54, 0x66, 0x7b, 0xe8, 0x14, - 0x03, 0x02, 0x00, 0x01, 0x01, 0x16, 0x03, 0x02, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x6b, 0x43, 0x1c, 0x58, 0xbc, 0x85, - 0xf7, 0xc1, 0x76, 0xbc, 0x72, 0x33, 0x41, 0x6b, - 0xb8, 0xf8, 0xfd, 0x53, 0x21, 0xc2, 0x41, 0x1b, - 0x72, 0x4f, 0xce, 0x97, 0xca, 0x14, 0x23, 0x4d, - 0xbc, 0x44, 0xd6, 0xd7, 0xfc, 0xbc, 0xfd, 0xfd, - 0x5d, 0x33, 0x42, 0x1b, 0x52, 0x40, 0x0a, 0x2b, - 0x6c, 0x98, 0x17, 0x03, 0x02, 0x00, 0x40, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, - 0x31, 0xef, 0x03, 0x7d, 0xa5, 0x74, 0x92, 0x24, - 0x34, 0xae, 0x4e, 0xc9, 0xfc, 0x59, 0xcb, 0x64, - 0xf4, 0x45, 0xb1, 0xac, 0x02, 0xf2, 0x87, 0xe7, - 0x2f, 0xfd, 0x01, 0xca, 0x78, 0x02, 0x2e, 0x3a, - 0x38, 0xcd, 0xb1, 0xe0, 0xf2, 0x2e, 0xf6, 0x27, - 0xa0, 0xac, 0x1f, 0x91, 0x43, 0xc2, 0x3d, 0x15, - 0x03, 0x02, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x9f, 0x30, 0x24, 0x56, - 0x2c, 0xde, 0xa0, 0xe6, 0x44, 0x35, 0x30, 0x51, - 0xec, 0xd4, 0x69, 0x2d, 0x46, 0x64, 0x04, 0x21, - 0xfe, 0x7c, 0x4d, 0xc5, 0xd0, 0x8c, 0xf9, 0xd2, - 0x3f, 0x88, 0x69, 0xd5, - }, -} - -// $ go test -run TestRunServer -serve -clientauth 1 \ -// -ciphersuites=0xc011 -minversion=0x0303 -maxversion=0x0303 -var tls12ServerScript = [][]byte{ - { - 0x16, 0x03, 0x01, 0x01, 0x1e, 0x01, 0x00, 0x01, - 0x1a, 0x03, 0x03, 0x51, 0xe5, 0x76, 0x84, 0x0e, - 0xb9, 0x17, 0xca, 0x08, 0x47, 0xd9, 0xbd, 0xd0, - 0x94, 0xd1, 0x97, 0xca, 0x5b, 0xe7, 0x20, 0xac, - 0x8e, 0xbb, 0xc7, 0x29, 0xe9, 0x26, 0xcf, 0x7d, - 0xb3, 0xdc, 0x99, 0x00, 0x00, 0x82, 0xc0, 0x30, - 0xc0, 0x2c, 0xc0, 0x28, 0xc0, 0x24, 0xc0, 0x14, - 0xc0, 0x0a, 0x00, 0xa3, 0x00, 0x9f, 0x00, 0x6b, - 0x00, 0x6a, 0x00, 0x39, 0x00, 0x38, 0xc0, 0x32, - 0xc0, 0x2e, 0xc0, 0x2a, 0xc0, 0x26, 0xc0, 0x0f, - 0xc0, 0x05, 0x00, 0x9d, 0x00, 0x3d, 0x00, 0x35, - 0xc0, 0x12, 0xc0, 0x08, 0x00, 0x16, 0x00, 0x13, - 0xc0, 0x0d, 0xc0, 0x03, 0x00, 0x0a, 0xc0, 0x2f, - 0xc0, 0x2b, 0xc0, 0x27, 0xc0, 0x23, 0xc0, 0x13, - 0xc0, 0x09, 0x00, 0xa2, 0x00, 0x9e, 0x00, 0x67, - 0x00, 0x40, 0x00, 0x33, 0x00, 0x32, 0xc0, 0x31, - 0xc0, 0x2d, 0xc0, 0x29, 0xc0, 0x25, 0xc0, 0x0e, - 0xc0, 0x04, 0x00, 0x9c, 0x00, 0x3c, 0x00, 0x2f, - 0x00, 0x07, 0xc0, 0x11, 0xc0, 0x07, 0xc0, 0x0c, - 0xc0, 0x02, 0x00, 0x05, 0x00, 0x04, 0x00, 0x15, - 0x00, 0x12, 0x00, 0x09, 0x00, 0x14, 0x00, 0x11, - 0x00, 0x08, 0x00, 0x06, 0x00, 0x03, 0x00, 0xff, - 0x01, 0x00, 0x00, 0x6f, 0x00, 0x0b, 0x00, 0x04, - 0x03, 0x00, 0x01, 0x02, 0x00, 0x0a, 0x00, 0x34, - 0x00, 0x32, 0x00, 0x0e, 0x00, 0x0d, 0x00, 0x19, - 0x00, 0x0b, 0x00, 0x0c, 0x00, 0x18, 0x00, 0x09, - 0x00, 0x0a, 0x00, 0x16, 0x00, 0x17, 0x00, 0x08, - 0x00, 0x06, 0x00, 0x07, 0x00, 0x14, 0x00, 0x15, - 0x00, 0x04, 0x00, 0x05, 0x00, 0x12, 0x00, 0x13, - 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x0f, - 0x00, 0x10, 0x00, 0x11, 0x00, 0x23, 0x00, 0x00, - 0x00, 0x0d, 0x00, 0x22, 0x00, 0x20, 0x06, 0x01, - 0x06, 0x02, 0x06, 0x03, 0x05, 0x01, 0x05, 0x02, - 0x05, 0x03, 0x04, 0x01, 0x04, 0x02, 0x04, 0x03, - 0x03, 0x01, 0x03, 0x02, 0x03, 0x03, 0x02, 0x01, - 0x02, 0x02, 0x02, 0x03, 0x01, 0x01, 0x00, 0x0f, - 0x00, 0x01, 0x01, - }, - { - 0x16, 0x03, 0x03, 0x00, 0x30, 0x02, 0x00, 0x00, - 0x2c, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xc0, 0x11, 0x00, 0x00, - 0x04, 0x00, 0x23, 0x00, 0x00, 0x16, 0x03, 0x03, - 0x02, 0xbe, 0x0b, 0x00, 0x02, 0xba, 0x00, 0x02, - 0xb7, 0x00, 0x02, 0xb4, 0x30, 0x82, 0x02, 0xb0, - 0x30, 0x82, 0x02, 0x19, 0xa0, 0x03, 0x02, 0x01, - 0x02, 0x02, 0x09, 0x00, 0x85, 0xb0, 0xbb, 0xa4, - 0x8a, 0x7f, 0xb8, 0xca, 0x30, 0x0d, 0x06, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x05, 0x05, 0x00, 0x30, 0x45, 0x31, 0x0b, 0x30, - 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, - 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, - 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, 0x6d, - 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, - 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, - 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, - 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, - 0x74, 0x64, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x30, - 0x30, 0x34, 0x32, 0x34, 0x30, 0x39, 0x30, 0x39, - 0x33, 0x38, 0x5a, 0x17, 0x0d, 0x31, 0x31, 0x30, - 0x34, 0x32, 0x34, 0x30, 0x39, 0x30, 0x39, 0x33, - 0x38, 0x5a, 0x30, 0x45, 0x31, 0x0b, 0x30, 0x09, - 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x41, - 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, - 0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, 0x6d, 0x65, - 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, 0x21, - 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, - 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, - 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, 0x74, - 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, 0x74, - 0x64, 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, - 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xbb, 0x79, - 0xd6, 0xf5, 0x17, 0xb5, 0xe5, 0xbf, 0x46, 0x10, - 0xd0, 0xdc, 0x69, 0xbe, 0xe6, 0x2b, 0x07, 0x43, - 0x5a, 0xd0, 0x03, 0x2d, 0x8a, 0x7a, 0x43, 0x85, - 0xb7, 0x14, 0x52, 0xe7, 0xa5, 0x65, 0x4c, 0x2c, - 0x78, 0xb8, 0x23, 0x8c, 0xb5, 0xb4, 0x82, 0xe5, - 0xde, 0x1f, 0x95, 0x3b, 0x7e, 0x62, 0xa5, 0x2c, - 0xa5, 0x33, 0xd6, 0xfe, 0x12, 0x5c, 0x7a, 0x56, - 0xfc, 0xf5, 0x06, 0xbf, 0xfa, 0x58, 0x7b, 0x26, - 0x3f, 0xb5, 0xcd, 0x04, 0xd3, 0xd0, 0xc9, 0x21, - 0x96, 0x4a, 0xc7, 0xf4, 0x54, 0x9f, 0x5a, 0xbf, - 0xef, 0x42, 0x71, 0x00, 0xfe, 0x18, 0x99, 0x07, - 0x7f, 0x7e, 0x88, 0x7d, 0x7d, 0xf1, 0x04, 0x39, - 0xc4, 0xa2, 0x2e, 0xdb, 0x51, 0xc9, 0x7c, 0xe3, - 0xc0, 0x4c, 0x3b, 0x32, 0x66, 0x01, 0xcf, 0xaf, - 0xb1, 0x1d, 0xb8, 0x71, 0x9a, 0x1d, 0xdb, 0xdb, - 0x89, 0x6b, 0xae, 0xda, 0x2d, 0x79, 0x02, 0x03, - 0x01, 0x00, 0x01, 0xa3, 0x81, 0xa7, 0x30, 0x81, - 0xa4, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, - 0x04, 0x16, 0x04, 0x14, 0xb1, 0xad, 0xe2, 0x85, - 0x5a, 0xcf, 0xcb, 0x28, 0xdb, 0x69, 0xce, 0x23, - 0x69, 0xde, 0xd3, 0x26, 0x8e, 0x18, 0x88, 0x39, - 0x30, 0x75, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, - 0x6e, 0x30, 0x6c, 0x80, 0x14, 0xb1, 0xad, 0xe2, - 0x85, 0x5a, 0xcf, 0xcb, 0x28, 0xdb, 0x69, 0xce, - 0x23, 0x69, 0xde, 0xd3, 0x26, 0x8e, 0x18, 0x88, - 0x39, 0xa1, 0x49, 0xa4, 0x47, 0x30, 0x45, 0x31, - 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, - 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, - 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, - 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, - 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, - 0x20, 0x4c, 0x74, 0x64, 0x82, 0x09, 0x00, 0x85, - 0xb0, 0xbb, 0xa4, 0x8a, 0x7f, 0xb8, 0xca, 0x30, - 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, - 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, - 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, - 0x01, 0x05, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, - 0x08, 0x6c, 0x45, 0x24, 0xc7, 0x6b, 0xb1, 0x59, - 0xab, 0x0c, 0x52, 0xcc, 0xf2, 0xb0, 0x14, 0xd7, - 0x87, 0x9d, 0x7a, 0x64, 0x75, 0xb5, 0x5a, 0x95, - 0x66, 0xe4, 0xc5, 0x2b, 0x8e, 0xae, 0x12, 0x66, - 0x1f, 0xeb, 0x4f, 0x38, 0xb3, 0x6e, 0x60, 0xd3, - 0x92, 0xfd, 0xf7, 0x41, 0x08, 0xb5, 0x25, 0x13, - 0xb1, 0x18, 0x7a, 0x24, 0xfb, 0x30, 0x1d, 0xba, - 0xed, 0x98, 0xb9, 0x17, 0xec, 0xe7, 0xd7, 0x31, - 0x59, 0xdb, 0x95, 0xd3, 0x1d, 0x78, 0xea, 0x50, - 0x56, 0x5c, 0xd5, 0x82, 0x5a, 0x2d, 0x5a, 0x5f, - 0x33, 0xc4, 0xb6, 0xd8, 0xc9, 0x75, 0x90, 0x96, - 0x8c, 0x0f, 0x52, 0x98, 0xb5, 0xcd, 0x98, 0x1f, - 0x89, 0x20, 0x5f, 0xf2, 0xa0, 0x1c, 0xa3, 0x1b, - 0x96, 0x94, 0xdd, 0xa9, 0xfd, 0x57, 0xe9, 0x70, - 0xe8, 0x26, 0x6d, 0x71, 0x99, 0x9b, 0x26, 0x6e, - 0x38, 0x50, 0x29, 0x6c, 0x90, 0xa7, 0xbd, 0xd9, - 0x16, 0x03, 0x03, 0x01, 0x11, 0x0c, 0x00, 0x01, - 0x0d, 0x03, 0x00, 0x19, 0x85, 0x04, 0x01, 0x39, - 0xdc, 0xee, 0x44, 0x17, 0x5e, 0xdb, 0xd7, 0x27, - 0xaf, 0xb6, 0x56, 0xd9, 0xb4, 0x43, 0x5a, 0x99, - 0xcf, 0xaa, 0x31, 0x37, 0x0c, 0x6f, 0x3a, 0xa0, - 0xf8, 0x53, 0xc4, 0x74, 0xd1, 0x91, 0x0a, 0x46, - 0xf5, 0x38, 0x3b, 0x5c, 0x09, 0xd8, 0x97, 0xdc, - 0x4b, 0xaa, 0x70, 0x26, 0x48, 0xf2, 0xd6, 0x0b, - 0x31, 0xc9, 0xf8, 0xd4, 0x98, 0x43, 0xe1, 0x6c, - 0xd5, 0xc7, 0xb2, 0x8e, 0x0b, 0x01, 0xe6, 0xb6, - 0x00, 0x28, 0x80, 0x7b, 0xfc, 0x96, 0x8f, 0x0d, - 0xa2, 0x4f, 0xb0, 0x79, 0xaf, 0xdc, 0x61, 0x28, - 0x63, 0x33, 0x78, 0xf6, 0x31, 0x39, 0xfd, 0x8a, - 0xf4, 0x15, 0x18, 0x11, 0xfe, 0xdb, 0xd5, 0x07, - 0xda, 0x2c, 0xed, 0x49, 0xa0, 0x23, 0xbf, 0xd0, - 0x3a, 0x38, 0x1d, 0x54, 0xae, 0x1c, 0x7b, 0xea, - 0x29, 0xee, 0xd0, 0x38, 0xc1, 0x76, 0xa7, 0x7f, - 0x2a, 0xf4, 0xce, 0x1e, 0xac, 0xcc, 0x94, 0x79, - 0x90, 0x33, 0x04, 0x01, 0x00, 0x80, 0x4a, 0xf9, - 0xf5, 0x0a, 0x61, 0x37, 0x7e, 0x4e, 0x92, 0xb5, - 0x1c, 0x91, 0x21, 0xb2, 0xb5, 0x17, 0x00, 0xbf, - 0x01, 0x5f, 0x30, 0xec, 0x62, 0x08, 0xd6, 0x9d, - 0x1a, 0x08, 0x05, 0x72, 0x8b, 0xf4, 0x49, 0x85, - 0xa7, 0xbf, 0x3f, 0x75, 0x58, 0x3e, 0x26, 0x82, - 0xc3, 0x28, 0x07, 0xf9, 0x41, 0x7d, 0x03, 0x14, - 0x3b, 0xc3, 0x05, 0x64, 0xff, 0x52, 0xf4, 0x75, - 0x6a, 0x87, 0xcd, 0xdf, 0x93, 0x31, 0x0a, 0x71, - 0x60, 0x17, 0xc6, 0x33, 0xf0, 0x79, 0xb6, 0x7b, - 0xd0, 0x9c, 0xa0, 0x5f, 0x74, 0x14, 0x2c, 0x5a, - 0xb4, 0x3f, 0x39, 0xf5, 0xe4, 0x9f, 0xbe, 0x6d, - 0x21, 0xd2, 0xa9, 0x42, 0xf7, 0xdc, 0xa6, 0x65, - 0xb7, 0x6a, 0x7e, 0x2e, 0x14, 0xd3, 0xf6, 0xf3, - 0x4b, 0x4c, 0x5b, 0x1a, 0x70, 0x7a, 0xbc, 0xb0, - 0x12, 0xf3, 0x6e, 0x0c, 0xcf, 0x43, 0x22, 0xae, - 0x5b, 0xba, 0x00, 0xf8, 0xfd, 0xaf, 0x16, 0x03, - 0x03, 0x00, 0x0f, 0x0d, 0x00, 0x00, 0x0b, 0x02, - 0x01, 0x40, 0x00, 0x04, 0x04, 0x01, 0x04, 0x03, - 0x00, 0x00, 0x16, 0x03, 0x03, 0x00, 0x04, 0x0e, - 0x00, 0x00, 0x00, - }, - { - 0x16, 0x03, 0x03, 0x01, 0xfb, 0x0b, 0x00, 0x01, - 0xf7, 0x00, 0x01, 0xf4, 0x00, 0x01, 0xf1, 0x30, - 0x82, 0x01, 0xed, 0x30, 0x82, 0x01, 0x58, 0xa0, - 0x03, 0x02, 0x01, 0x02, 0x02, 0x01, 0x00, 0x30, - 0x0b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, - 0x0d, 0x01, 0x01, 0x05, 0x30, 0x26, 0x31, 0x10, - 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, - 0x07, 0x41, 0x63, 0x6d, 0x65, 0x20, 0x43, 0x6f, - 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, - 0x03, 0x13, 0x09, 0x31, 0x32, 0x37, 0x2e, 0x30, - 0x2e, 0x30, 0x2e, 0x31, 0x30, 0x1e, 0x17, 0x0d, - 0x31, 0x31, 0x31, 0x32, 0x30, 0x38, 0x30, 0x37, - 0x35, 0x35, 0x31, 0x32, 0x5a, 0x17, 0x0d, 0x31, - 0x32, 0x31, 0x32, 0x30, 0x37, 0x30, 0x38, 0x30, - 0x30, 0x31, 0x32, 0x5a, 0x30, 0x26, 0x31, 0x10, - 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, - 0x07, 0x41, 0x63, 0x6d, 0x65, 0x20, 0x43, 0x6f, - 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, - 0x03, 0x13, 0x09, 0x31, 0x32, 0x37, 0x2e, 0x30, - 0x2e, 0x30, 0x2e, 0x31, 0x30, 0x81, 0x9c, 0x30, - 0x0b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, - 0x0d, 0x01, 0x01, 0x01, 0x03, 0x81, 0x8c, 0x00, - 0x30, 0x81, 0x88, 0x02, 0x81, 0x80, 0x4e, 0xd0, - 0x7b, 0x31, 0xe3, 0x82, 0x64, 0xd9, 0x59, 0xc0, - 0xc2, 0x87, 0xa4, 0x5e, 0x1e, 0x8b, 0x73, 0x33, - 0xc7, 0x63, 0x53, 0xdf, 0x66, 0x92, 0x06, 0x84, - 0xf6, 0x64, 0xd5, 0x8f, 0xe4, 0x36, 0xa7, 0x1d, - 0x2b, 0xe8, 0xb3, 0x20, 0x36, 0x45, 0x23, 0xb5, - 0xe3, 0x95, 0xae, 0xed, 0xe0, 0xf5, 0x20, 0x9c, - 0x8d, 0x95, 0xdf, 0x7f, 0x5a, 0x12, 0xef, 0x87, - 0xe4, 0x5b, 0x68, 0xe4, 0xe9, 0x0e, 0x74, 0xec, - 0x04, 0x8a, 0x7f, 0xde, 0x93, 0x27, 0xc4, 0x01, - 0x19, 0x7a, 0xbd, 0xf2, 0xdc, 0x3d, 0x14, 0xab, - 0xd0, 0x54, 0xca, 0x21, 0x0c, 0xd0, 0x4d, 0x6e, - 0x87, 0x2e, 0x5c, 0xc5, 0xd2, 0xbb, 0x4d, 0x4b, - 0x4f, 0xce, 0xb6, 0x2c, 0xf7, 0x7e, 0x88, 0xec, - 0x7c, 0xd7, 0x02, 0x91, 0x74, 0xa6, 0x1e, 0x0c, - 0x1a, 0xda, 0xe3, 0x4a, 0x5a, 0x2e, 0xde, 0x13, - 0x9c, 0x4c, 0x40, 0x88, 0x59, 0x93, 0x02, 0x03, - 0x01, 0x00, 0x01, 0xa3, 0x32, 0x30, 0x30, 0x30, - 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, - 0xff, 0x04, 0x04, 0x03, 0x02, 0x00, 0xa0, 0x30, - 0x0d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x06, - 0x04, 0x04, 0x01, 0x02, 0x03, 0x04, 0x30, 0x0f, - 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x08, 0x30, - 0x06, 0x80, 0x04, 0x01, 0x02, 0x03, 0x04, 0x30, - 0x0b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, - 0x0d, 0x01, 0x01, 0x05, 0x03, 0x81, 0x81, 0x00, - 0x36, 0x1f, 0xb3, 0x7a, 0x0c, 0x75, 0xc9, 0x6e, - 0x37, 0x46, 0x61, 0x2b, 0xd5, 0xbd, 0xc0, 0xa7, - 0x4b, 0xcc, 0x46, 0x9a, 0x81, 0x58, 0x7c, 0x85, - 0x79, 0x29, 0xc8, 0xc8, 0xc6, 0x67, 0xdd, 0x32, - 0x56, 0x45, 0x2b, 0x75, 0xb6, 0xe9, 0x24, 0xa9, - 0x50, 0x9a, 0xbe, 0x1f, 0x5a, 0xfa, 0x1a, 0x15, - 0xd9, 0xcc, 0x55, 0x95, 0x72, 0x16, 0x83, 0xb9, - 0xc2, 0xb6, 0x8f, 0xfd, 0x88, 0x8c, 0x38, 0x84, - 0x1d, 0xab, 0x5d, 0x92, 0x31, 0x13, 0x4f, 0xfd, - 0x83, 0x3b, 0xc6, 0x9d, 0xf1, 0x11, 0x62, 0xb6, - 0x8b, 0xec, 0xab, 0x67, 0xbe, 0xc8, 0x64, 0xb0, - 0x11, 0x50, 0x46, 0x58, 0x17, 0x6b, 0x99, 0x1c, - 0xd3, 0x1d, 0xfc, 0x06, 0xf1, 0x0e, 0xe5, 0x96, - 0xa8, 0x0c, 0xf9, 0x78, 0x20, 0xb7, 0x44, 0x18, - 0x51, 0x8d, 0x10, 0x7e, 0x4f, 0x94, 0x67, 0xdf, - 0xa3, 0x4e, 0x70, 0x73, 0x8e, 0x90, 0x91, 0x85, - 0x16, 0x03, 0x03, 0x00, 0x8a, 0x10, 0x00, 0x00, - 0x86, 0x85, 0x04, 0x01, 0x5d, 0x3a, 0x92, 0x59, - 0x7f, 0x9a, 0x22, 0x36, 0x0e, 0x1b, 0x1d, 0x2a, - 0x05, 0xb7, 0xa4, 0xb6, 0x5d, 0xfc, 0x51, 0x6e, - 0x15, 0xe5, 0x89, 0x7c, 0xe2, 0xfa, 0x87, 0x38, - 0x05, 0x79, 0x15, 0x92, 0xb4, 0x8f, 0x88, 0x8f, - 0x9d, 0x5d, 0xa0, 0xaf, 0xf8, 0xce, 0xf9, 0x6f, - 0x83, 0xf4, 0x08, 0x69, 0xe4, 0x91, 0xc5, 0xed, - 0xb9, 0xc5, 0xa8, 0x1f, 0x4b, 0xec, 0xef, 0x91, - 0xc1, 0xa3, 0x34, 0x24, 0x18, 0x00, 0x2d, 0xcd, - 0xe6, 0x44, 0xef, 0x5a, 0x3e, 0x52, 0x63, 0x5b, - 0x36, 0x1f, 0x7e, 0xce, 0x9e, 0xaa, 0xda, 0x8d, - 0xb5, 0xc9, 0xea, 0xd8, 0x1b, 0xd1, 0x1c, 0x7c, - 0x07, 0xfc, 0x3c, 0x2d, 0x70, 0x1f, 0xf9, 0x4d, - 0xcb, 0xaa, 0xad, 0x07, 0xd5, 0x6d, 0xbd, 0xa6, - 0x61, 0xf3, 0x2f, 0xa3, 0x9c, 0x45, 0x02, 0x4a, - 0xac, 0x6c, 0xb6, 0x37, 0x95, 0xb1, 0x4a, 0xb5, - 0x0a, 0x4e, 0x60, 0x67, 0xd7, 0xe0, 0x04, 0x16, - 0x03, 0x03, 0x00, 0x88, 0x0f, 0x00, 0x00, 0x84, - 0x04, 0x01, 0x00, 0x80, 0x08, 0x83, 0x53, 0xf0, - 0xf8, 0x14, 0xf5, 0xc2, 0xd1, 0x8b, 0xf0, 0xa5, - 0xc1, 0xd8, 0x1a, 0x36, 0x4b, 0x75, 0x77, 0x02, - 0x19, 0xd8, 0x11, 0x3f, 0x5a, 0x36, 0xfc, 0xe9, - 0x2b, 0x4b, 0xf9, 0xfe, 0xda, 0x8a, 0x0f, 0x6e, - 0x3d, 0xd3, 0x52, 0x87, 0xf7, 0x9c, 0x78, 0x39, - 0xa8, 0xf1, 0xd7, 0xf7, 0x4e, 0x35, 0x33, 0xf9, - 0xc5, 0x76, 0xa8, 0x12, 0xc4, 0x91, 0x33, 0x1d, - 0x93, 0x8c, 0xbf, 0xb1, 0x83, 0x00, 0x90, 0xc5, - 0x52, 0x3e, 0xe0, 0x0a, 0xe8, 0x92, 0x75, 0xdf, - 0x54, 0x5f, 0x9f, 0x95, 0x76, 0x62, 0xb5, 0x85, - 0x69, 0xa4, 0x86, 0x85, 0x6c, 0xf3, 0x6b, 0x2a, - 0x72, 0x7b, 0x4d, 0x42, 0x33, 0x67, 0x4a, 0xce, - 0xb5, 0xdb, 0x9b, 0xae, 0xc0, 0xb0, 0x10, 0xeb, - 0x3b, 0xf4, 0xc2, 0x9a, 0x64, 0x47, 0x4c, 0x1e, - 0xa5, 0x91, 0x7f, 0x6d, 0xd1, 0x03, 0xf5, 0x4a, - 0x90, 0x69, 0x18, 0xb1, 0x14, 0x03, 0x03, 0x00, - 0x01, 0x01, 0x16, 0x03, 0x03, 0x00, 0x24, 0x59, - 0xfc, 0x7e, 0xae, 0xb3, 0xbf, 0xab, 0x4d, 0xdb, - 0x4e, 0xab, 0xa9, 0x6d, 0x6b, 0x4c, 0x60, 0xb6, - 0x16, 0xe0, 0xab, 0x7f, 0x52, 0x2d, 0xa1, 0xfc, - 0xe1, 0x80, 0xd2, 0x8a, 0xa1, 0xe5, 0x8f, 0xa1, - 0x70, 0x93, 0x23, - }, - { - 0x16, 0x03, 0x03, 0x02, 0x67, 0x04, 0x00, 0x02, - 0x63, 0x00, 0x00, 0x00, 0x00, 0x02, 0x5d, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, - 0xea, 0x8b, 0xc5, 0xef, 0xba, 0x64, 0xb7, 0x23, - 0x08, 0x86, 0x4f, 0x37, 0xe0, 0x8f, 0xbd, 0x75, - 0x71, 0x2b, 0xcb, 0x20, 0x75, 0x11, 0x3b, 0xa2, - 0x9e, 0x39, 0x3c, 0x03, 0xef, 0x6e, 0x41, 0xd7, - 0xcf, 0x1a, 0x2c, 0xf2, 0xfe, 0xc2, 0xd3, 0x65, - 0x59, 0x00, 0x9d, 0x03, 0xb4, 0xf2, 0x20, 0xe4, - 0x33, 0x80, 0xcd, 0xf6, 0xe4, 0x59, 0x22, 0xf7, - 0xfd, 0x88, 0x0e, 0xa4, 0x09, 0xc0, 0x0d, 0x10, - 0x80, 0x10, 0x79, 0xee, 0x70, 0x96, 0xdb, 0x22, - 0x8b, 0xb7, 0xac, 0xe0, 0x98, 0xad, 0xe9, 0xe3, - 0xcb, 0xea, 0x9f, 0xe6, 0x83, 0x28, 0x7c, 0x7e, - 0x4e, 0x9a, 0x8d, 0xd9, 0xf3, 0x86, 0xf4, 0x89, - 0x8b, 0x79, 0x8f, 0xbb, 0xe9, 0x74, 0x02, 0x02, - 0x14, 0x04, 0xea, 0xba, 0x16, 0x10, 0xa1, 0x85, - 0xbe, 0x4e, 0x4e, 0x92, 0xc5, 0x83, 0xf6, 0x1e, - 0x1f, 0xd4, 0x25, 0xc2, 0xc2, 0xb9, 0xce, 0x33, - 0x63, 0x66, 0x79, 0x1f, 0x54, 0x35, 0xc1, 0xe8, - 0x89, 0x34, 0x78, 0x94, 0x36, 0x14, 0xef, 0x01, - 0x1f, 0xf1, 0xbd, 0x77, 0x2c, 0x4d, 0xac, 0x5c, - 0x5c, 0x4a, 0xc6, 0xed, 0xd8, 0x0e, 0x72, 0x84, - 0x83, 0xdc, 0x56, 0x84, 0xc8, 0xf3, 0x89, 0x56, - 0xfd, 0x89, 0xc1, 0xc9, 0x9a, 0x29, 0x91, 0x7e, - 0x19, 0xe9, 0x8b, 0x5b, 0x11, 0x15, 0x4e, 0x6c, - 0xf4, 0x89, 0xe7, 0x6d, 0x68, 0x1e, 0xf9, 0x6c, - 0x23, 0x72, 0x05, 0x68, 0x82, 0x60, 0x84, 0x1f, - 0x83, 0x20, 0x09, 0x86, 0x10, 0x81, 0xec, 0xec, - 0xdc, 0x25, 0x53, 0x20, 0xfa, 0xa9, 0x41, 0x64, - 0xd6, 0x20, 0xf3, 0xf4, 0x52, 0xf2, 0x80, 0x62, - 0x83, 0xc9, 0x23, 0x66, 0x44, 0x95, 0x5a, 0x99, - 0x8a, 0xe1, 0x26, 0x63, 0xc1, 0x8b, 0x31, 0xf9, - 0x21, 0x06, 0x77, 0x04, 0x27, 0xf2, 0x0c, 0x63, - 0x83, 0x45, 0xa0, 0xa9, 0x7b, 0xcf, 0xdf, 0xd7, - 0x56, 0x75, 0xbc, 0xdd, 0x95, 0x36, 0xb1, 0x75, - 0x39, 0x05, 0x00, 0x3c, 0x8a, 0x79, 0xd6, 0xe9, - 0xf0, 0x4b, 0xdc, 0x51, 0x6b, 0x01, 0x94, 0x16, - 0x87, 0x12, 0x92, 0x6c, 0x07, 0xc1, 0xf5, 0x58, - 0xb7, 0x2a, 0x81, 0xf5, 0xa0, 0x37, 0x8b, 0xa6, - 0x22, 0xfe, 0x28, 0x0a, 0x7e, 0x68, 0xe2, 0xda, - 0x6c, 0x53, 0xee, 0x0e, 0x8d, 0x2d, 0x8b, 0x0b, - 0xda, 0xf8, 0x99, 0x3e, 0x0e, 0xed, 0x9f, 0xc1, - 0x2b, 0xf6, 0xfe, 0xe9, 0x52, 0x38, 0x7b, 0x83, - 0x9a, 0x50, 0xa6, 0xd7, 0x49, 0x83, 0x43, 0x7e, - 0x82, 0xec, 0xc7, 0x09, 0x3d, 0x3d, 0xb1, 0xee, - 0xe8, 0xc5, 0x6a, 0xc3, 0x3d, 0x4b, 0x4c, 0x6a, - 0xbb, 0x0b, 0x2c, 0x24, 0x2e, 0xdb, 0x7d, 0x57, - 0x87, 0xb4, 0x80, 0xa5, 0xae, 0xff, 0x54, 0xa8, - 0xa5, 0x27, 0x69, 0x95, 0xc8, 0xe7, 0x79, 0xc7, - 0x89, 0x2a, 0x73, 0x49, 0xcb, 0xf5, 0xc5, 0xbc, - 0x4a, 0xe0, 0x73, 0xa9, 0xbc, 0x88, 0x64, 0x96, - 0x98, 0xa5, 0x1e, 0xe3, 0x43, 0xc1, 0x7d, 0x78, - 0xc7, 0x94, 0x72, 0xd4, 0x2c, 0x6e, 0x85, 0x39, - 0x9a, 0xaf, 0xdb, 0xa1, 0xe9, 0xe2, 0xcb, 0x37, - 0x04, 0xc6, 0x8c, 0x81, 0xd3, 0x2a, 0xb7, 0xbe, - 0x6c, 0x07, 0x1f, 0x5e, 0xd9, 0x00, 0xd2, 0xf7, - 0xe1, 0xa7, 0xbc, 0x0c, 0xb6, 0x6d, 0xfb, 0x3f, - 0x3d, 0x24, 0xaa, 0xfb, 0x7e, 0xe1, 0xb5, 0x1b, - 0xff, 0x38, 0xaa, 0x69, 0x59, 0x38, 0x52, 0x9a, - 0x0e, 0x6d, 0xbc, 0xde, 0x4f, 0x13, 0x09, 0x17, - 0xc4, 0xa9, 0x05, 0x84, 0xbc, 0x50, 0xef, 0x40, - 0xb0, 0x4c, 0x24, 0x32, 0xed, 0x94, 0x2c, 0xdd, - 0xda, 0x20, 0x24, 0x67, 0xe2, 0xea, 0x71, 0x3d, - 0x4a, 0x04, 0x0d, 0x98, 0x29, 0x20, 0x4c, 0xeb, - 0x70, 0xce, 0x45, 0x9e, 0x5a, 0xaf, 0xb6, 0xa3, - 0x92, 0xc8, 0x28, 0xf2, 0xe3, 0xe8, 0x8a, 0x5d, - 0x0a, 0x33, 0x79, 0x9b, 0x6a, 0xf3, 0x30, 0x01, - 0x1d, 0x47, 0xbd, 0x01, 0xcc, 0x4d, 0x71, 0xc0, - 0x56, 0xfa, 0xfd, 0x37, 0xed, 0x0f, 0x27, 0xc0, - 0xbb, 0xa0, 0xee, 0xc3, 0x79, 0x8b, 0xe7, 0x41, - 0x8f, 0xfa, 0x3a, 0xcb, 0x45, 0x3b, 0x85, 0x9f, - 0x06, 0x90, 0xb2, 0x51, 0xc0, 0x48, 0x10, 0xac, - 0x2a, 0xec, 0xec, 0x48, 0x7a, 0x19, 0x47, 0xc4, - 0x2a, 0xeb, 0xb3, 0xa2, 0x07, 0x22, 0x32, 0x78, - 0xf4, 0x73, 0x5e, 0x92, 0x42, 0x15, 0xa1, 0x90, - 0x91, 0xd0, 0xeb, 0x12, 0x14, 0x03, 0x03, 0x00, - 0x01, 0x01, 0x16, 0x03, 0x03, 0x00, 0x24, 0x45, - 0x4b, 0x80, 0x42, 0x46, 0xde, 0xbb, 0xe7, 0x76, - 0xd1, 0x33, 0x92, 0xfc, 0x46, 0x17, 0x6d, 0x21, - 0xf6, 0x0e, 0x16, 0xca, 0x9b, 0x9b, 0x04, 0x65, - 0x16, 0x40, 0x44, 0x64, 0xbc, 0x58, 0xfa, 0x2a, - 0x49, 0xe9, 0xed, 0x17, 0x03, 0x03, 0x00, 0x21, - 0x89, 0x71, 0xcd, 0x56, 0x54, 0xbf, 0x73, 0xde, - 0xfb, 0x4b, 0x4e, 0xf1, 0x7f, 0xc6, 0x75, 0xa6, - 0xbd, 0x6b, 0x6c, 0xd9, 0xdc, 0x0c, 0x71, 0xb4, - 0xb9, 0xbb, 0x6e, 0xfa, 0x9e, 0xc7, 0xc7, 0x4c, - 0x24, 0x15, 0x03, 0x03, 0x00, 0x16, 0x62, 0xea, - 0x65, 0x69, 0x68, 0x4a, 0xce, 0xa7, 0x9e, 0xce, - 0xc0, 0xf1, 0x5c, 0x96, 0xd9, 0x1f, 0x49, 0xac, - 0x2d, 0x05, 0x89, 0x94, - }, -} - -// cert.pem and key.pem were generated with generate_cert.go -// Thus, they have no ExtKeyUsage fields and trigger an error -// when verification is turned on. - -var clientCertificate = loadPEMCert(` ------BEGIN CERTIFICATE----- -MIIB7TCCAVigAwIBAgIBADALBgkqhkiG9w0BAQUwJjEQMA4GA1UEChMHQWNtZSBD -bzESMBAGA1UEAxMJMTI3LjAuMC4xMB4XDTExMTIwODA3NTUxMloXDTEyMTIwNzA4 -MDAxMlowJjEQMA4GA1UEChMHQWNtZSBDbzESMBAGA1UEAxMJMTI3LjAuMC4xMIGc -MAsGCSqGSIb3DQEBAQOBjAAwgYgCgYBO0Hsx44Jk2VnAwoekXh6LczPHY1PfZpIG -hPZk1Y/kNqcdK+izIDZFI7Xjla7t4PUgnI2V339aEu+H5Fto5OkOdOwEin/ekyfE -ARl6vfLcPRSr0FTKIQzQTW6HLlzF0rtNS0/Otiz3fojsfNcCkXSmHgwa2uNKWi7e -E5xMQIhZkwIDAQABozIwMDAOBgNVHQ8BAf8EBAMCAKAwDQYDVR0OBAYEBAECAwQw -DwYDVR0jBAgwBoAEAQIDBDALBgkqhkiG9w0BAQUDgYEANh+zegx1yW43RmEr1b3A -p0vMRpqBWHyFeSnIyMZn3TJWRSt1tukkqVCavh9a+hoV2cxVlXIWg7nCto/9iIw4 -hB2rXZIxE0/9gzvGnfERYraL7KtnvshksBFQRlgXa5kc0x38BvEO5ZaoDPl4ILdE -GFGNEH5PlGffo05wc46QkYU= ------END CERTIFICATE----- -`) - -/* corresponding key.pem for cert.pem is: ------BEGIN RSA PRIVATE KEY----- -MIICWgIBAAKBgE7QezHjgmTZWcDCh6ReHotzM8djU99mkgaE9mTVj+Q2px0r6LMg -NkUjteOVru3g9SCcjZXff1oS74fkW2jk6Q507ASKf96TJ8QBGXq98tw9FKvQVMoh -DNBNbocuXMXSu01LT862LPd+iOx81wKRdKYeDBra40paLt4TnExAiFmTAgMBAAEC -gYBxvXd8yNteFTns8A/2yomEMC4yeosJJSpp1CsN3BJ7g8/qTnrVPxBy+RU+qr63 -t2WquaOu/cr5P8iEsa6lk20tf8pjKLNXeX0b1RTzK8rJLbS7nGzP3tvOhL096VtQ -dAo4ROEaro0TzYpHmpciSvxVIeEIAAdFDObDJPKqcJAxyQJBAJizfYgK8Gzx9fsx -hxp+VteCbVPg2euASH5Yv3K5LukRdKoSzHE2grUVQgN/LafC0eZibRanxHegYSr7 -7qaswKUCQQCEIWor/X4XTMdVj3Oj+vpiw75y/S9gh682+myZL+d/02IEkwnB098P -RkKVpenBHyrGg0oeN5La7URILWKj7CPXAkBKo6F+d+phNjwIFoN1Xb/RA32w/D1I -saG9sF+UEhRt9AxUfW/U/tIQ9V0ZHHcSg1XaCM5Nvp934brdKdvTOKnJAkBD5h/3 -Rybatlvg/fzBEaJFyq09zhngkxlZOUtBVTqzl17RVvY2orgH02U4HbCHy4phxOn7 -qTdQRYlHRftgnWK1AkANibn9PRYJ7mJyJ9Dyj2QeNcSkSTzrt0tPvUMf4+meJymN -1Ntu5+S1DLLzfxlaljWG6ylW6DNxujCyuXIV2rvA ------END RSA PRIVATE KEY----- -*/ - -var clientECDSACertificate = loadPEMCert(` ------BEGIN CERTIFICATE----- -MIIB/DCCAV4CCQCaMIRsJjXZFzAJBgcqhkjOPQQBMEUxCzAJBgNVBAYTAkFVMRMw -EQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0 -eSBMdGQwHhcNMTIxMTE0MTMyNTUzWhcNMjIxMTEyMTMyNTUzWjBBMQswCQYDVQQG -EwJBVTEMMAoGA1UECBMDTlNXMRAwDgYDVQQHEwdQeXJtb250MRIwEAYDVQQDEwlK -b2VsIFNpbmcwgZswEAYHKoZIzj0CAQYFK4EEACMDgYYABACVjJF1FMBexFe01MNv -ja5oHt1vzobhfm6ySD6B5U7ixohLZNz1MLvT/2XMW/TdtWo+PtAd3kfDdq0Z9kUs -jLzYHQFMH3CQRnZIi4+DzEpcj0B22uCJ7B0rxE4wdihBsmKo+1vx+U56jb0JuK7q -ixgnTy5w/hOWusPTQBbNZU6sER7m8TAJBgcqhkjOPQQBA4GMADCBiAJCAOAUxGBg -C3JosDJdYUoCdFzCgbkWqD8pyDbHgf9stlvZcPE4O1BIKJTLCRpS8V3ujfK58PDa -2RU6+b0DeoeiIzXsAkIBo9SKeDUcSpoj0gq+KxAxnZxfvuiRs9oa9V2jI/Umi0Vw -jWVim34BmT0Y9hCaOGGbLlfk+syxis7iI6CH8OFnUes= ------END CERTIFICATE----- -`) - -/* corresponding key for cert is: ------BEGIN EC PARAMETERS----- -BgUrgQQAIw== ------END EC PARAMETERS----- ------BEGIN EC PRIVATE KEY----- -MIHcAgEBBEIBkJN9X4IqZIguiEVKMqeBUP5xtRsEv4HJEtOpOGLELwO53SD78Ew8 -k+wLWoqizS3NpQyMtrU8JFdWfj+C57UNkOugBwYFK4EEACOhgYkDgYYABACVjJF1 -FMBexFe01MNvja5oHt1vzobhfm6ySD6B5U7ixohLZNz1MLvT/2XMW/TdtWo+PtAd -3kfDdq0Z9kUsjLzYHQFMH3CQRnZIi4+DzEpcj0B22uCJ7B0rxE4wdihBsmKo+1vx -+U56jb0JuK7qixgnTy5w/hOWusPTQBbNZU6sER7m8Q== ------END EC PRIVATE KEY----- -*/ -var clientauthECDSATests = []clientauthTest{ - // Server asks for cert with empty CA list, client gives one - // go test -run "TestRunServer" -serve \ - // -clientauth 1 -ciphersuites=0xc00a - // openssl s_client -host 127.0.0.1 -port 10443 \ - // -cipher ECDHE-ECDSA-AES256-SHA -key client.key -cert client.crt - {"RequestClientCert, client gives it", RequestClientCert, []*x509.Certificate{clientECDSACertificate}, [][]byte{ - { - 0x16, 0x03, 0x01, 0x00, 0xa0, 0x01, 0x00, 0x00, - 0x9c, 0x03, 0x03, 0x51, 0xe5, 0x73, 0xc5, 0xae, - 0x51, 0x94, 0xb4, 0xf2, 0xe8, 0xf6, 0x03, 0x0e, - 0x3b, 0x34, 0xaf, 0xf0, 0xdc, 0x1b, 0xcc, 0xd8, - 0x0c, 0x45, 0x82, 0xd4, 0xd6, 0x76, 0x04, 0x6e, - 0x4f, 0x7a, 0x24, 0x00, 0x00, 0x04, 0xc0, 0x0a, - 0x00, 0xff, 0x01, 0x00, 0x00, 0x6f, 0x00, 0x0b, - 0x00, 0x04, 0x03, 0x00, 0x01, 0x02, 0x00, 0x0a, - 0x00, 0x34, 0x00, 0x32, 0x00, 0x0e, 0x00, 0x0d, - 0x00, 0x19, 0x00, 0x0b, 0x00, 0x0c, 0x00, 0x18, - 0x00, 0x09, 0x00, 0x0a, 0x00, 0x16, 0x00, 0x17, - 0x00, 0x08, 0x00, 0x06, 0x00, 0x07, 0x00, 0x14, - 0x00, 0x15, 0x00, 0x04, 0x00, 0x05, 0x00, 0x12, - 0x00, 0x13, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, - 0x00, 0x0f, 0x00, 0x10, 0x00, 0x11, 0x00, 0x23, - 0x00, 0x00, 0x00, 0x0d, 0x00, 0x22, 0x00, 0x20, - 0x06, 0x01, 0x06, 0x02, 0x06, 0x03, 0x05, 0x01, - 0x05, 0x02, 0x05, 0x03, 0x04, 0x01, 0x04, 0x02, - 0x04, 0x03, 0x03, 0x01, 0x03, 0x02, 0x03, 0x03, - 0x02, 0x01, 0x02, 0x02, 0x02, 0x03, 0x01, 0x01, - 0x00, 0x0f, 0x00, 0x01, 0x01, - }, - { - 0x16, 0x03, 0x01, 0x00, 0x30, 0x02, 0x00, 0x00, - 0x2c, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xc0, 0x0a, 0x00, 0x00, - 0x04, 0x00, 0x23, 0x00, 0x00, 0x16, 0x03, 0x01, - 0x02, 0x0e, 0x0b, 0x00, 0x02, 0x0a, 0x00, 0x02, - 0x07, 0x00, 0x02, 0x04, 0x30, 0x82, 0x02, 0x00, - 0x30, 0x82, 0x01, 0x62, 0x02, 0x09, 0x00, 0xb8, - 0xbf, 0x2d, 0x47, 0xa0, 0xd2, 0xeb, 0xf4, 0x30, - 0x09, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, - 0x04, 0x01, 0x30, 0x45, 0x31, 0x0b, 0x30, 0x09, - 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x41, - 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, - 0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, 0x6d, 0x65, - 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, 0x21, - 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, - 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, - 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, 0x74, - 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, 0x74, - 0x64, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x32, 0x31, - 0x31, 0x32, 0x32, 0x31, 0x35, 0x30, 0x36, 0x33, - 0x32, 0x5a, 0x17, 0x0d, 0x32, 0x32, 0x31, 0x31, - 0x32, 0x30, 0x31, 0x35, 0x30, 0x36, 0x33, 0x32, - 0x5a, 0x30, 0x45, 0x31, 0x0b, 0x30, 0x09, 0x06, - 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x41, 0x55, - 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, - 0x08, 0x13, 0x0a, 0x53, 0x6f, 0x6d, 0x65, 0x2d, - 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, 0x21, 0x30, - 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x18, - 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, - 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, 0x74, 0x73, - 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, 0x74, 0x64, - 0x30, 0x81, 0x9b, 0x30, 0x10, 0x06, 0x07, 0x2a, - 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, - 0x2b, 0x81, 0x04, 0x00, 0x23, 0x03, 0x81, 0x86, - 0x00, 0x04, 0x00, 0xc4, 0xa1, 0xed, 0xbe, 0x98, - 0xf9, 0x0b, 0x48, 0x73, 0x36, 0x7e, 0xc3, 0x16, - 0x56, 0x11, 0x22, 0xf2, 0x3d, 0x53, 0xc3, 0x3b, - 0x4d, 0x21, 0x3d, 0xcd, 0x6b, 0x75, 0xe6, 0xf6, - 0xb0, 0xdc, 0x9a, 0xdf, 0x26, 0xc1, 0xbc, 0xb2, - 0x87, 0xf0, 0x72, 0x32, 0x7c, 0xb3, 0x64, 0x2f, - 0x1c, 0x90, 0xbc, 0xea, 0x68, 0x23, 0x10, 0x7e, - 0xfe, 0xe3, 0x25, 0xc0, 0x48, 0x3a, 0x69, 0xe0, - 0x28, 0x6d, 0xd3, 0x37, 0x00, 0xef, 0x04, 0x62, - 0xdd, 0x0d, 0xa0, 0x9c, 0x70, 0x62, 0x83, 0xd8, - 0x81, 0xd3, 0x64, 0x31, 0xaa, 0x9e, 0x97, 0x31, - 0xbd, 0x96, 0xb0, 0x68, 0xc0, 0x9b, 0x23, 0xde, - 0x76, 0x64, 0x3f, 0x1a, 0x5c, 0x7f, 0xe9, 0x12, - 0x0e, 0x58, 0x58, 0xb6, 0x5f, 0x70, 0xdd, 0x9b, - 0xd8, 0xea, 0xd5, 0xd7, 0xf5, 0xd5, 0xcc, 0xb9, - 0xb6, 0x9f, 0x30, 0x66, 0x5b, 0x66, 0x9a, 0x20, - 0xe2, 0x27, 0xe5, 0xbf, 0xfe, 0x3b, 0x30, 0x09, - 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, - 0x01, 0x03, 0x81, 0x8c, 0x00, 0x30, 0x81, 0x88, - 0x02, 0x42, 0x01, 0x88, 0xa2, 0x4f, 0xeb, 0xe2, - 0x45, 0xc5, 0x48, 0x7d, 0x1b, 0xac, 0xf5, 0xed, - 0x98, 0x9d, 0xae, 0x47, 0x70, 0xc0, 0x5e, 0x1b, - 0xb6, 0x2f, 0xbd, 0xf1, 0xb6, 0x4d, 0xb7, 0x61, - 0x40, 0xd3, 0x11, 0xa2, 0xce, 0xee, 0x0b, 0x7e, - 0x92, 0x7e, 0xff, 0x76, 0x9d, 0xc3, 0x3b, 0x7e, - 0xa5, 0x3f, 0xce, 0xfa, 0x10, 0xe2, 0x59, 0xec, - 0x47, 0x2d, 0x7c, 0xac, 0xda, 0x4e, 0x97, 0x0e, - 0x15, 0xa0, 0x6f, 0xd0, 0x02, 0x42, 0x01, 0x4d, - 0xfc, 0xbe, 0x67, 0x13, 0x9c, 0x2d, 0x05, 0x0e, - 0xbd, 0x3f, 0xa3, 0x8c, 0x25, 0xc1, 0x33, 0x13, - 0x83, 0x0d, 0x94, 0x06, 0xbb, 0xd4, 0x37, 0x7a, - 0xf6, 0xec, 0x7a, 0xc9, 0x86, 0x2e, 0xdd, 0xd7, - 0x11, 0x69, 0x7f, 0x85, 0x7c, 0x56, 0xde, 0xfb, - 0x31, 0x78, 0x2b, 0xe4, 0xc7, 0x78, 0x0d, 0xae, - 0xcb, 0xbe, 0x9e, 0x4e, 0x36, 0x24, 0x31, 0x7b, - 0x6a, 0x0f, 0x39, 0x95, 0x12, 0x07, 0x8f, 0x2a, - 0x16, 0x03, 0x01, 0x01, 0x1a, 0x0c, 0x00, 0x01, - 0x16, 0x03, 0x00, 0x19, 0x85, 0x04, 0x01, 0x39, - 0xdc, 0xee, 0x44, 0x17, 0x5e, 0xdb, 0xd7, 0x27, - 0xaf, 0xb6, 0x56, 0xd9, 0xb4, 0x43, 0x5a, 0x99, - 0xcf, 0xaa, 0x31, 0x37, 0x0c, 0x6f, 0x3a, 0xa0, - 0xf8, 0x53, 0xc4, 0x74, 0xd1, 0x91, 0x0a, 0x46, - 0xf5, 0x38, 0x3b, 0x5c, 0x09, 0xd8, 0x97, 0xdc, - 0x4b, 0xaa, 0x70, 0x26, 0x48, 0xf2, 0xd6, 0x0b, - 0x31, 0xc9, 0xf8, 0xd4, 0x98, 0x43, 0xe1, 0x6c, - 0xd5, 0xc7, 0xb2, 0x8e, 0x0b, 0x01, 0xe6, 0xb6, - 0x00, 0x28, 0x80, 0x7b, 0xfc, 0x96, 0x8f, 0x0d, - 0xa2, 0x4f, 0xb0, 0x79, 0xaf, 0xdc, 0x61, 0x28, - 0x63, 0x33, 0x78, 0xf6, 0x31, 0x39, 0xfd, 0x8a, - 0xf4, 0x15, 0x18, 0x11, 0xfe, 0xdb, 0xd5, 0x07, - 0xda, 0x2c, 0xed, 0x49, 0xa0, 0x23, 0xbf, 0xd0, - 0x3a, 0x38, 0x1d, 0x54, 0xae, 0x1c, 0x7b, 0xea, - 0x29, 0xee, 0xd0, 0x38, 0xc1, 0x76, 0xa7, 0x7f, - 0x2a, 0xf4, 0xce, 0x1e, 0xac, 0xcc, 0x94, 0x79, - 0x90, 0x33, 0x00, 0x8b, 0x30, 0x81, 0x88, 0x02, - 0x42, 0x00, 0xc6, 0x85, 0x8e, 0x06, 0xb7, 0x04, - 0x04, 0xe9, 0xcd, 0x9e, 0x3e, 0xcb, 0x66, 0x23, - 0x95, 0xb4, 0x42, 0x9c, 0x64, 0x81, 0x39, 0x05, - 0x3f, 0xb5, 0x21, 0xf8, 0x28, 0xaf, 0x60, 0x6b, - 0x4d, 0x3d, 0xba, 0xa1, 0x4b, 0x5e, 0x77, 0xef, - 0xe7, 0x59, 0x28, 0xfe, 0x1d, 0xc1, 0x27, 0xa2, - 0xff, 0xa8, 0xde, 0x33, 0x48, 0xb3, 0xc1, 0x85, - 0x6a, 0x42, 0x9b, 0xf9, 0x7e, 0x7e, 0x31, 0xc2, - 0xe5, 0xbd, 0x66, 0x02, 0x42, 0x00, 0xad, 0x7d, - 0x06, 0x35, 0xab, 0xec, 0x8d, 0xac, 0xd4, 0xba, - 0x1b, 0x49, 0x5e, 0x05, 0x5f, 0xf0, 0x97, 0x93, - 0x82, 0xb8, 0x2b, 0x8d, 0x91, 0x98, 0x63, 0x8e, - 0xb4, 0x14, 0x62, 0xdb, 0x1e, 0xc9, 0x2b, 0x30, - 0xf8, 0x41, 0x9b, 0xa6, 0xe6, 0xbc, 0xde, 0x0e, - 0x68, 0x30, 0x21, 0xf4, 0xa8, 0xa9, 0x1b, 0xec, - 0x44, 0x4f, 0x5d, 0x02, 0x2f, 0x60, 0x45, 0x60, - 0xba, 0xe0, 0x4e, 0xc0, 0xd4, 0x3b, 0x01, 0x16, - 0x03, 0x01, 0x00, 0x09, 0x0d, 0x00, 0x00, 0x05, - 0x02, 0x01, 0x40, 0x00, 0x00, 0x16, 0x03, 0x01, - 0x00, 0x04, 0x0e, 0x00, 0x00, 0x00, - }, - { - 0x16, 0x03, 0x01, 0x02, 0x0a, 0x0b, 0x00, 0x02, - 0x06, 0x00, 0x02, 0x03, 0x00, 0x02, 0x00, 0x30, - 0x82, 0x01, 0xfc, 0x30, 0x82, 0x01, 0x5e, 0x02, - 0x09, 0x00, 0x9a, 0x30, 0x84, 0x6c, 0x26, 0x35, - 0xd9, 0x17, 0x30, 0x09, 0x06, 0x07, 0x2a, 0x86, - 0x48, 0xce, 0x3d, 0x04, 0x01, 0x30, 0x45, 0x31, - 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, - 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, - 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, - 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, - 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, - 0x20, 0x4c, 0x74, 0x64, 0x30, 0x1e, 0x17, 0x0d, - 0x31, 0x32, 0x31, 0x31, 0x31, 0x34, 0x31, 0x33, - 0x32, 0x35, 0x35, 0x33, 0x5a, 0x17, 0x0d, 0x32, - 0x32, 0x31, 0x31, 0x31, 0x32, 0x31, 0x33, 0x32, - 0x35, 0x35, 0x33, 0x5a, 0x30, 0x41, 0x31, 0x0b, - 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, - 0x02, 0x41, 0x55, 0x31, 0x0c, 0x30, 0x0a, 0x06, - 0x03, 0x55, 0x04, 0x08, 0x13, 0x03, 0x4e, 0x53, - 0x57, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, - 0x04, 0x07, 0x13, 0x07, 0x50, 0x79, 0x72, 0x6d, - 0x6f, 0x6e, 0x74, 0x31, 0x12, 0x30, 0x10, 0x06, - 0x03, 0x55, 0x04, 0x03, 0x13, 0x09, 0x4a, 0x6f, - 0x65, 0x6c, 0x20, 0x53, 0x69, 0x6e, 0x67, 0x30, - 0x81, 0x9b, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, - 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, 0x2b, - 0x81, 0x04, 0x00, 0x23, 0x03, 0x81, 0x86, 0x00, - 0x04, 0x00, 0x95, 0x8c, 0x91, 0x75, 0x14, 0xc0, - 0x5e, 0xc4, 0x57, 0xb4, 0xd4, 0xc3, 0x6f, 0x8d, - 0xae, 0x68, 0x1e, 0xdd, 0x6f, 0xce, 0x86, 0xe1, - 0x7e, 0x6e, 0xb2, 0x48, 0x3e, 0x81, 0xe5, 0x4e, - 0xe2, 0xc6, 0x88, 0x4b, 0x64, 0xdc, 0xf5, 0x30, - 0xbb, 0xd3, 0xff, 0x65, 0xcc, 0x5b, 0xf4, 0xdd, - 0xb5, 0x6a, 0x3e, 0x3e, 0xd0, 0x1d, 0xde, 0x47, - 0xc3, 0x76, 0xad, 0x19, 0xf6, 0x45, 0x2c, 0x8c, - 0xbc, 0xd8, 0x1d, 0x01, 0x4c, 0x1f, 0x70, 0x90, - 0x46, 0x76, 0x48, 0x8b, 0x8f, 0x83, 0xcc, 0x4a, - 0x5c, 0x8f, 0x40, 0x76, 0xda, 0xe0, 0x89, 0xec, - 0x1d, 0x2b, 0xc4, 0x4e, 0x30, 0x76, 0x28, 0x41, - 0xb2, 0x62, 0xa8, 0xfb, 0x5b, 0xf1, 0xf9, 0x4e, - 0x7a, 0x8d, 0xbd, 0x09, 0xb8, 0xae, 0xea, 0x8b, - 0x18, 0x27, 0x4f, 0x2e, 0x70, 0xfe, 0x13, 0x96, - 0xba, 0xc3, 0xd3, 0x40, 0x16, 0xcd, 0x65, 0x4e, - 0xac, 0x11, 0x1e, 0xe6, 0xf1, 0x30, 0x09, 0x06, - 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x01, - 0x03, 0x81, 0x8c, 0x00, 0x30, 0x81, 0x88, 0x02, - 0x42, 0x00, 0xe0, 0x14, 0xc4, 0x60, 0x60, 0x0b, - 0x72, 0x68, 0xb0, 0x32, 0x5d, 0x61, 0x4a, 0x02, - 0x74, 0x5c, 0xc2, 0x81, 0xb9, 0x16, 0xa8, 0x3f, - 0x29, 0xc8, 0x36, 0xc7, 0x81, 0xff, 0x6c, 0xb6, - 0x5b, 0xd9, 0x70, 0xf1, 0x38, 0x3b, 0x50, 0x48, - 0x28, 0x94, 0xcb, 0x09, 0x1a, 0x52, 0xf1, 0x5d, - 0xee, 0x8d, 0xf2, 0xb9, 0xf0, 0xf0, 0xda, 0xd9, - 0x15, 0x3a, 0xf9, 0xbd, 0x03, 0x7a, 0x87, 0xa2, - 0x23, 0x35, 0xec, 0x02, 0x42, 0x01, 0xa3, 0xd4, - 0x8a, 0x78, 0x35, 0x1c, 0x4a, 0x9a, 0x23, 0xd2, - 0x0a, 0xbe, 0x2b, 0x10, 0x31, 0x9d, 0x9c, 0x5f, - 0xbe, 0xe8, 0x91, 0xb3, 0xda, 0x1a, 0xf5, 0x5d, - 0xa3, 0x23, 0xf5, 0x26, 0x8b, 0x45, 0x70, 0x8d, - 0x65, 0x62, 0x9b, 0x7e, 0x01, 0x99, 0x3d, 0x18, - 0xf6, 0x10, 0x9a, 0x38, 0x61, 0x9b, 0x2e, 0x57, - 0xe4, 0xfa, 0xcc, 0xb1, 0x8a, 0xce, 0xe2, 0x23, - 0xa0, 0x87, 0xf0, 0xe1, 0x67, 0x51, 0xeb, 0x16, - 0x03, 0x01, 0x00, 0x8a, 0x10, 0x00, 0x00, 0x86, - 0x85, 0x04, 0x00, 0xcd, 0x1c, 0xe8, 0x66, 0x5b, - 0xa8, 0x9d, 0x83, 0x2f, 0x7e, 0x1d, 0x0b, 0x59, - 0x23, 0xbc, 0x30, 0xcf, 0xa3, 0xaf, 0x21, 0xdc, - 0xf2, 0x57, 0x49, 0x56, 0x30, 0x25, 0x7c, 0x84, - 0x5d, 0xad, 0xaa, 0x9c, 0x7b, 0x2a, 0x95, 0x58, - 0x3d, 0x30, 0x87, 0x01, 0x3b, 0xb7, 0xea, 0xcb, - 0xc4, 0xa3, 0xeb, 0x22, 0xbf, 0x2d, 0x61, 0x17, - 0x8c, 0x9b, 0xe8, 0x1b, 0xb2, 0x87, 0x16, 0x78, - 0xd5, 0xfd, 0x8b, 0xdd, 0x00, 0x0f, 0xda, 0x8e, - 0xfd, 0x28, 0x36, 0xeb, 0xe4, 0xc5, 0x42, 0x14, - 0xc7, 0xbd, 0x29, 0x5e, 0x9a, 0xed, 0x5e, 0xc1, - 0xf7, 0xf4, 0xbd, 0xbd, 0x15, 0x9c, 0xe8, 0x44, - 0x71, 0xa7, 0xb6, 0xe9, 0xfa, 0x7e, 0x97, 0xcb, - 0x96, 0x3e, 0x53, 0x76, 0xfb, 0x11, 0x1f, 0x36, - 0x8f, 0x30, 0xfb, 0x71, 0x3a, 0x75, 0x3a, 0x25, - 0x7b, 0xa2, 0xc1, 0xf9, 0x3e, 0x58, 0x5f, 0x07, - 0x16, 0xed, 0xe1, 0xf7, 0xc1, 0xb1, 0x16, 0x03, - 0x01, 0x00, 0x90, 0x0f, 0x00, 0x00, 0x8c, 0x00, - 0x8a, 0x30, 0x81, 0x87, 0x02, 0x42, 0x00, 0xb2, - 0xd3, 0x91, 0xe6, 0xd5, 0x9b, 0xb2, 0xb8, 0x03, - 0xf4, 0x85, 0x4d, 0x43, 0x79, 0x1f, 0xb6, 0x6f, - 0x0c, 0xcd, 0x67, 0x5f, 0x5e, 0xca, 0xee, 0xb3, - 0xe4, 0xab, 0x1e, 0x58, 0xc3, 0x04, 0xa9, 0x8a, - 0xa7, 0xcf, 0xaa, 0x33, 0x88, 0xd5, 0x35, 0xd2, - 0x80, 0x8f, 0xfa, 0x1b, 0x3c, 0x3d, 0xf7, 0x80, - 0x50, 0xde, 0x80, 0x30, 0x64, 0xee, 0xc0, 0xb3, - 0x91, 0x6e, 0x5d, 0x1e, 0xc0, 0xdc, 0x3a, 0x93, - 0x02, 0x41, 0x4e, 0xca, 0x98, 0x41, 0x8c, 0x36, - 0xf2, 0x12, 0xbf, 0x8e, 0x0f, 0x69, 0x8e, 0xf8, - 0x7b, 0x9d, 0xba, 0x9c, 0x5c, 0x48, 0x79, 0xf4, - 0xba, 0x3d, 0x06, 0xa5, 0xab, 0x47, 0xe0, 0x1a, - 0x45, 0x28, 0x3a, 0x8f, 0xbf, 0x14, 0x24, 0x36, - 0xd1, 0x1d, 0x29, 0xdc, 0xde, 0x72, 0x5b, 0x76, - 0x41, 0x67, 0xe8, 0xe5, 0x71, 0x4a, 0x77, 0xe9, - 0xed, 0x02, 0x19, 0xdd, 0xe4, 0xaa, 0xe9, 0x2d, - 0xe7, 0x47, 0x32, 0x14, 0x03, 0x01, 0x00, 0x01, - 0x01, 0x16, 0x03, 0x01, 0x00, 0x30, 0xfa, 0xc3, - 0xf2, 0x35, 0xd0, 0x6d, 0x32, 0x78, 0x6a, 0xd6, - 0xe6, 0x70, 0x5e, 0x00, 0x4c, 0x35, 0xf1, 0xe0, - 0x21, 0xcf, 0xc3, 0x78, 0xcd, 0xe0, 0x2b, 0x0b, - 0xf4, 0xeb, 0xf9, 0xc0, 0x38, 0xf2, 0x9a, 0x31, - 0x55, 0x07, 0x2b, 0x8d, 0x68, 0x40, 0x31, 0x08, - 0xaa, 0xe3, 0x16, 0xcf, 0x4b, 0xd4, - }, - { - 0x16, 0x03, 0x01, 0x02, 0x76, 0x04, 0x00, 0x02, - 0x72, 0x00, 0x00, 0x00, 0x00, 0x02, 0x6c, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, - 0xe8, 0x8b, 0xde, 0xef, 0xba, 0xf9, 0xdb, 0x95, - 0x24, 0xa5, 0x49, 0xb3, 0x23, 0xd8, 0x73, 0x88, - 0x50, 0x42, 0xed, 0xeb, 0xa3, 0xd8, 0xab, 0x31, - 0x9c, 0xd0, 0x00, 0x01, 0xef, 0xc0, 0xbf, 0xab, - 0x59, 0x55, 0xb5, 0xb9, 0xef, 0xa5, 0xa6, 0xec, - 0x69, 0xed, 0x00, 0x2f, 0x47, 0xdb, 0x75, 0x52, - 0x0c, 0xe5, 0x86, 0xb7, 0x02, 0x59, 0x22, 0xf7, - 0xfd, 0x8b, 0xff, 0xa4, 0x09, 0xc0, 0x1c, 0x10, - 0x80, 0x10, 0x7f, 0x4c, 0x7a, 0x94, 0x40, 0x10, - 0x0d, 0xda, 0x8a, 0xe5, 0x4a, 0xbc, 0xd0, 0xc0, - 0x4b, 0xa5, 0x33, 0x97, 0xc6, 0xe7, 0x40, 0x7f, - 0x7f, 0x8c, 0xf9, 0xf8, 0xc8, 0xb8, 0xfb, 0x8c, - 0xdd, 0x28, 0x81, 0xae, 0xfd, 0x37, 0x20, 0x3a, - 0x40, 0x37, 0x99, 0xc4, 0x21, 0x01, 0xc4, 0x91, - 0xb0, 0x5e, 0x11, 0xc5, 0xa9, 0xfd, 0x9a, 0x02, - 0x7e, 0x97, 0x6a, 0x86, 0x89, 0xb8, 0xc1, 0x32, - 0x4c, 0x7e, 0x6d, 0x47, 0x61, 0x0e, 0xe3, 0xc2, - 0xf0, 0x62, 0x3c, 0xc6, 0x71, 0x4f, 0xbb, 0x47, - 0x65, 0xb1, 0xd9, 0x22, 0x79, 0x15, 0xea, 0x1f, - 0x4b, 0x2a, 0x8a, 0xa4, 0xc8, 0x73, 0x34, 0xba, - 0x83, 0xe4, 0x70, 0x99, 0xc9, 0xcf, 0xbe, 0x64, - 0x99, 0xb9, 0xfa, 0xe9, 0xaf, 0x5d, 0xc7, 0x20, - 0x26, 0xde, 0xc5, 0x06, 0x12, 0x36, 0x4f, 0x4d, - 0xc0, 0xbb, 0x81, 0x5b, 0x5e, 0x38, 0xc3, 0x07, - 0x21, 0x04, 0x1a, 0x53, 0x9c, 0x59, 0xac, 0x2d, - 0xe6, 0xa5, 0x93, 0xa5, 0x19, 0xc6, 0xb0, 0xf7, - 0x56, 0x5d, 0xdf, 0xd1, 0xf4, 0xfd, 0x44, 0x6d, - 0xc6, 0xa2, 0x31, 0xa7, 0x35, 0x42, 0x18, 0x50, - 0x0c, 0x4f, 0x6e, 0xe3, 0x3b, 0xa3, 0xaa, 0x1c, - 0xbe, 0x41, 0x0d, 0xce, 0x6c, 0x62, 0xe1, 0x96, - 0x2d, 0xbd, 0x14, 0x31, 0xe3, 0xc4, 0x5b, 0xbf, - 0xf6, 0xde, 0xec, 0x42, 0xe8, 0xc7, 0x2a, 0x0b, - 0xdb, 0x2d, 0x7c, 0xf0, 0x3f, 0x45, 0x32, 0x45, - 0x09, 0x47, 0x09, 0x0f, 0x21, 0x22, 0x45, 0x06, - 0x11, 0xb8, 0xf9, 0xe6, 0x67, 0x90, 0x4b, 0x4a, - 0xde, 0x81, 0xfb, 0xeb, 0xe7, 0x9a, 0x08, 0x30, - 0xcf, 0x51, 0xe1, 0xd9, 0xfa, 0x79, 0xa3, 0xcc, - 0x65, 0x1a, 0x83, 0x86, 0xc9, 0x7a, 0x41, 0xf5, - 0xdf, 0xa0, 0x7c, 0x44, 0x23, 0x17, 0xf3, 0x62, - 0xe8, 0xa9, 0x31, 0x1e, 0x6b, 0x05, 0x4b, 0x4f, - 0x9d, 0x91, 0x46, 0x92, 0xa6, 0x25, 0x32, 0xca, - 0xa1, 0x75, 0xda, 0xe6, 0x80, 0x3e, 0x7f, 0xd1, - 0x26, 0x57, 0x07, 0x42, 0xe4, 0x91, 0xff, 0xbd, - 0x44, 0xae, 0x98, 0x5c, 0x1d, 0xdf, 0x11, 0xe3, - 0xae, 0x87, 0x5e, 0xb7, 0x69, 0xad, 0x34, 0x7f, - 0x3a, 0x07, 0x7c, 0xdf, 0xfc, 0x76, 0x17, 0x8b, - 0x62, 0xc8, 0xe1, 0x78, 0x2a, 0xc8, 0xb9, 0x8a, - 0xbb, 0x5c, 0xfb, 0x38, 0x74, 0x91, 0x6e, 0x12, - 0x0c, 0x1f, 0x8e, 0xe1, 0xc2, 0x01, 0xd8, 0x9d, - 0x23, 0x0f, 0xc4, 0x67, 0x5d, 0xe5, 0x67, 0x4b, - 0x94, 0x6e, 0x69, 0x72, 0x90, 0x2d, 0x52, 0x78, - 0x8e, 0x61, 0xba, 0xdf, 0x4e, 0xf5, 0xdc, 0xfb, - 0x73, 0xbe, 0x03, 0x70, 0xd9, 0x01, 0x30, 0xf3, - 0xa1, 0xbb, 0x9a, 0x5f, 0xec, 0x9e, 0xed, 0x8d, - 0xdd, 0x53, 0xfd, 0x60, 0xc3, 0x2b, 0x7a, 0x00, - 0x2c, 0xf9, 0x0a, 0x57, 0x47, 0x45, 0x43, 0xb3, - 0x23, 0x01, 0x9c, 0xee, 0x54, 0x4d, 0x58, 0xd3, - 0x71, 0x1c, 0xc9, 0xd3, 0x30, 0x9e, 0x14, 0xa5, - 0xf3, 0xbf, 0x4d, 0x9b, 0xb7, 0x13, 0x21, 0xae, - 0xd2, 0x8d, 0x6e, 0x6f, 0x1c, 0xcc, 0xb2, 0x41, - 0xb2, 0x64, 0x56, 0x83, 0xce, 0xd1, 0x0c, 0x79, - 0x32, 0x78, 0xef, 0xc5, 0x21, 0xb1, 0xe8, 0xc4, - 0x42, 0xa7, 0x8d, 0xc1, 0xfa, 0xa1, 0x9c, 0x3c, - 0x21, 0xd8, 0xe9, 0x90, 0xe2, 0x7c, 0x14, 0x26, - 0xfe, 0x61, 0x3e, 0xf9, 0x71, 0x1d, 0x5d, 0x49, - 0x3b, 0xb1, 0xb8, 0x42, 0xa1, 0xb8, 0x1c, 0x75, - 0x7d, 0xee, 0xed, 0xfc, 0xe6, 0x20, 0x2b, 0x9e, - 0x10, 0x52, 0xda, 0x56, 0x4d, 0x64, 0x6c, 0x41, - 0xc1, 0xf7, 0x60, 0x0c, 0x10, 0x65, 0x6f, 0xd4, - 0xe9, 0x9b, 0x0d, 0x83, 0x13, 0xc8, 0x5a, 0xa3, - 0x56, 0x2a, 0x42, 0xc6, 0x1c, 0xfe, 0xdb, 0xba, - 0x3d, 0x04, 0x12, 0xfd, 0x28, 0xeb, 0x78, 0xdd, - 0xbc, 0xc8, 0x0d, 0xa1, 0xce, 0xd4, 0x54, 0xbf, - 0xaf, 0xe1, 0x60, 0x0c, 0xa3, 0xc3, 0xc3, 0x62, - 0x58, 0xc1, 0x79, 0xa7, 0x95, 0x41, 0x09, 0x24, - 0xc6, 0x9a, 0x50, 0x14, 0x03, 0x01, 0x00, 0x01, - 0x01, 0x16, 0x03, 0x01, 0x00, 0x30, 0x4d, 0x7b, - 0x5f, 0x28, 0x5e, 0x68, 0x6c, 0xa3, 0x65, 0xc7, - 0x7e, 0x49, 0x6c, 0xb3, 0x67, 0xbb, 0xd0, 0x75, - 0xa2, 0x9e, 0x8c, 0x92, 0x4f, 0x8c, 0x33, 0x14, - 0x7c, 0x6c, 0xf1, 0x74, 0x97, 0xc3, 0xe0, 0x10, - 0xe9, 0x0d, 0xc2, 0x30, 0x5c, 0x23, 0xee, 0x1d, - 0x16, 0x2e, 0xb9, 0x96, 0x2b, 0x2d, 0x17, 0x03, - 0x01, 0x00, 0x20, 0xf2, 0xc8, 0xa7, 0x1b, 0x60, - 0x46, 0xee, 0xe5, 0x7e, 0xc9, 0x35, 0xb3, 0xf1, - 0x7c, 0x32, 0x0c, 0x85, 0x94, 0x59, 0x57, 0x27, - 0xb0, 0xbd, 0x52, 0x86, 0x90, 0xf1, 0xb7, 0x4d, - 0x1e, 0xc1, 0x16, 0x17, 0x03, 0x01, 0x00, 0x30, - 0xff, 0x85, 0x50, 0xdf, 0x3f, 0xfc, 0xa2, 0x61, - 0x1a, 0x12, 0xc0, 0x1e, 0x10, 0x32, 0x88, 0x50, - 0xa0, 0x2c, 0x80, 0xda, 0x77, 0xea, 0x09, 0x47, - 0xe0, 0x85, 0x07, 0x29, 0x45, 0x65, 0x19, 0xa3, - 0x8d, 0x99, 0xb8, 0xbf, 0xb6, 0xbc, 0x76, 0xe2, - 0x50, 0x24, 0x82, 0x0a, 0xfd, 0xdd, 0x35, 0x09, - 0x15, 0x03, 0x01, 0x00, 0x20, 0xe7, 0x36, 0xf6, - 0x61, 0xd2, 0x95, 0x3c, 0xb6, 0x65, 0x7b, 0xb2, - 0xb8, 0xdf, 0x03, 0x53, 0xeb, 0xf7, 0x16, 0xe0, - 0xe0, 0x15, 0x22, 0x71, 0x70, 0x62, 0x73, 0xad, - 0xb5, 0x1a, 0x77, 0x44, 0x57, - }, - }}, -} - -var aesGCMServerScript = [][]byte{ - { - 0x16, 0x03, 0x01, 0x01, 0x1c, 0x01, 0x00, 0x01, - 0x18, 0x03, 0x03, 0x52, 0x1e, 0x74, 0xf0, 0xb0, - 0xc1, 0x8b, 0x16, 0xf9, 0x74, 0xfc, 0x16, 0xc4, - 0x11, 0x18, 0x96, 0x08, 0x25, 0x38, 0x4f, 0x98, - 0x98, 0xbe, 0xb5, 0x61, 0xdf, 0x94, 0x15, 0xcc, - 0x9b, 0x61, 0xef, 0x00, 0x00, 0x80, 0xc0, 0x30, - 0xc0, 0x2c, 0xc0, 0x28, 0xc0, 0x24, 0xc0, 0x14, - 0xc0, 0x0a, 0x00, 0xa3, 0x00, 0x9f, 0x00, 0x6b, - 0x00, 0x6a, 0x00, 0x39, 0x00, 0x38, 0xc0, 0x32, - 0xc0, 0x2e, 0xc0, 0x2a, 0xc0, 0x26, 0xc0, 0x0f, - 0xc0, 0x05, 0x00, 0x9d, 0x00, 0x3d, 0x00, 0x35, - 0xc0, 0x12, 0xc0, 0x08, 0x00, 0x16, 0x00, 0x13, - 0xc0, 0x0d, 0xc0, 0x03, 0x00, 0x0a, 0xc0, 0x2f, - 0xc0, 0x2b, 0xc0, 0x27, 0xc0, 0x23, 0xc0, 0x13, - 0xc0, 0x09, 0x00, 0xa2, 0x00, 0x9e, 0x00, 0x67, - 0x00, 0x40, 0x00, 0x33, 0x00, 0x32, 0xc0, 0x31, - 0xc0, 0x2d, 0xc0, 0x29, 0xc0, 0x25, 0xc0, 0x0e, - 0xc0, 0x04, 0x00, 0x9c, 0x00, 0x3c, 0x00, 0x2f, - 0xc0, 0x11, 0xc0, 0x07, 0xc0, 0x0c, 0xc0, 0x02, - 0x00, 0x05, 0x00, 0x04, 0x00, 0x15, 0x00, 0x12, - 0x00, 0x09, 0x00, 0x14, 0x00, 0x11, 0x00, 0x08, - 0x00, 0x06, 0x00, 0x03, 0x00, 0xff, 0x01, 0x00, - 0x00, 0x6f, 0x00, 0x0b, 0x00, 0x04, 0x03, 0x00, - 0x01, 0x02, 0x00, 0x0a, 0x00, 0x34, 0x00, 0x32, - 0x00, 0x0e, 0x00, 0x0d, 0x00, 0x19, 0x00, 0x0b, - 0x00, 0x0c, 0x00, 0x18, 0x00, 0x09, 0x00, 0x0a, - 0x00, 0x16, 0x00, 0x17, 0x00, 0x08, 0x00, 0x06, - 0x00, 0x07, 0x00, 0x14, 0x00, 0x15, 0x00, 0x04, - 0x00, 0x05, 0x00, 0x12, 0x00, 0x13, 0x00, 0x01, - 0x00, 0x02, 0x00, 0x03, 0x00, 0x0f, 0x00, 0x10, - 0x00, 0x11, 0x00, 0x23, 0x00, 0x00, 0x00, 0x0d, - 0x00, 0x22, 0x00, 0x20, 0x06, 0x01, 0x06, 0x02, - 0x06, 0x03, 0x05, 0x01, 0x05, 0x02, 0x05, 0x03, - 0x04, 0x01, 0x04, 0x02, 0x04, 0x03, 0x03, 0x01, - 0x03, 0x02, 0x03, 0x03, 0x02, 0x01, 0x02, 0x02, - 0x02, 0x03, 0x01, 0x01, 0x00, 0x0f, 0x00, 0x01, - 0x01, - }, - { - 0x16, 0x03, 0x03, 0x00, 0x30, 0x02, 0x00, 0x00, - 0x2c, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xc0, 0x2f, 0x00, 0x00, - 0x04, 0x00, 0x23, 0x00, 0x00, 0x16, 0x03, 0x03, - 0x02, 0xbe, 0x0b, 0x00, 0x02, 0xba, 0x00, 0x02, - 0xb7, 0x00, 0x02, 0xb4, 0x30, 0x82, 0x02, 0xb0, - 0x30, 0x82, 0x02, 0x19, 0xa0, 0x03, 0x02, 0x01, - 0x02, 0x02, 0x09, 0x00, 0x85, 0xb0, 0xbb, 0xa4, - 0x8a, 0x7f, 0xb8, 0xca, 0x30, 0x0d, 0x06, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x05, 0x05, 0x00, 0x30, 0x45, 0x31, 0x0b, 0x30, - 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, - 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, - 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, 0x6d, - 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, - 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, - 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, - 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, - 0x74, 0x64, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x30, - 0x30, 0x34, 0x32, 0x34, 0x30, 0x39, 0x30, 0x39, - 0x33, 0x38, 0x5a, 0x17, 0x0d, 0x31, 0x31, 0x30, - 0x34, 0x32, 0x34, 0x30, 0x39, 0x30, 0x39, 0x33, - 0x38, 0x5a, 0x30, 0x45, 0x31, 0x0b, 0x30, 0x09, - 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x41, - 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, - 0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, 0x6d, 0x65, - 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, 0x21, - 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, - 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, - 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, 0x74, - 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, 0x74, - 0x64, 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, - 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, - 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xbb, 0x79, - 0xd6, 0xf5, 0x17, 0xb5, 0xe5, 0xbf, 0x46, 0x10, - 0xd0, 0xdc, 0x69, 0xbe, 0xe6, 0x2b, 0x07, 0x43, - 0x5a, 0xd0, 0x03, 0x2d, 0x8a, 0x7a, 0x43, 0x85, - 0xb7, 0x14, 0x52, 0xe7, 0xa5, 0x65, 0x4c, 0x2c, - 0x78, 0xb8, 0x23, 0x8c, 0xb5, 0xb4, 0x82, 0xe5, - 0xde, 0x1f, 0x95, 0x3b, 0x7e, 0x62, 0xa5, 0x2c, - 0xa5, 0x33, 0xd6, 0xfe, 0x12, 0x5c, 0x7a, 0x56, - 0xfc, 0xf5, 0x06, 0xbf, 0xfa, 0x58, 0x7b, 0x26, - 0x3f, 0xb5, 0xcd, 0x04, 0xd3, 0xd0, 0xc9, 0x21, - 0x96, 0x4a, 0xc7, 0xf4, 0x54, 0x9f, 0x5a, 0xbf, - 0xef, 0x42, 0x71, 0x00, 0xfe, 0x18, 0x99, 0x07, - 0x7f, 0x7e, 0x88, 0x7d, 0x7d, 0xf1, 0x04, 0x39, - 0xc4, 0xa2, 0x2e, 0xdb, 0x51, 0xc9, 0x7c, 0xe3, - 0xc0, 0x4c, 0x3b, 0x32, 0x66, 0x01, 0xcf, 0xaf, - 0xb1, 0x1d, 0xb8, 0x71, 0x9a, 0x1d, 0xdb, 0xdb, - 0x89, 0x6b, 0xae, 0xda, 0x2d, 0x79, 0x02, 0x03, - 0x01, 0x00, 0x01, 0xa3, 0x81, 0xa7, 0x30, 0x81, - 0xa4, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, - 0x04, 0x16, 0x04, 0x14, 0xb1, 0xad, 0xe2, 0x85, - 0x5a, 0xcf, 0xcb, 0x28, 0xdb, 0x69, 0xce, 0x23, - 0x69, 0xde, 0xd3, 0x26, 0x8e, 0x18, 0x88, 0x39, - 0x30, 0x75, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, - 0x6e, 0x30, 0x6c, 0x80, 0x14, 0xb1, 0xad, 0xe2, - 0x85, 0x5a, 0xcf, 0xcb, 0x28, 0xdb, 0x69, 0xce, - 0x23, 0x69, 0xde, 0xd3, 0x26, 0x8e, 0x18, 0x88, - 0x39, 0xa1, 0x49, 0xa4, 0x47, 0x30, 0x45, 0x31, - 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, - 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, - 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, - 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, - 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, - 0x20, 0x4c, 0x74, 0x64, 0x82, 0x09, 0x00, 0x85, - 0xb0, 0xbb, 0xa4, 0x8a, 0x7f, 0xb8, 0xca, 0x30, - 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, - 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, - 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, - 0x01, 0x05, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, - 0x08, 0x6c, 0x45, 0x24, 0xc7, 0x6b, 0xb1, 0x59, - 0xab, 0x0c, 0x52, 0xcc, 0xf2, 0xb0, 0x14, 0xd7, - 0x87, 0x9d, 0x7a, 0x64, 0x75, 0xb5, 0x5a, 0x95, - 0x66, 0xe4, 0xc5, 0x2b, 0x8e, 0xae, 0x12, 0x66, - 0x1f, 0xeb, 0x4f, 0x38, 0xb3, 0x6e, 0x60, 0xd3, - 0x92, 0xfd, 0xf7, 0x41, 0x08, 0xb5, 0x25, 0x13, - 0xb1, 0x18, 0x7a, 0x24, 0xfb, 0x30, 0x1d, 0xba, - 0xed, 0x98, 0xb9, 0x17, 0xec, 0xe7, 0xd7, 0x31, - 0x59, 0xdb, 0x95, 0xd3, 0x1d, 0x78, 0xea, 0x50, - 0x56, 0x5c, 0xd5, 0x82, 0x5a, 0x2d, 0x5a, 0x5f, - 0x33, 0xc4, 0xb6, 0xd8, 0xc9, 0x75, 0x90, 0x96, - 0x8c, 0x0f, 0x52, 0x98, 0xb5, 0xcd, 0x98, 0x1f, - 0x89, 0x20, 0x5f, 0xf2, 0xa0, 0x1c, 0xa3, 0x1b, - 0x96, 0x94, 0xdd, 0xa9, 0xfd, 0x57, 0xe9, 0x70, - 0xe8, 0x26, 0x6d, 0x71, 0x99, 0x9b, 0x26, 0x6e, - 0x38, 0x50, 0x29, 0x6c, 0x90, 0xa7, 0xbd, 0xd9, - 0x16, 0x03, 0x03, 0x01, 0x11, 0x0c, 0x00, 0x01, - 0x0d, 0x03, 0x00, 0x19, 0x85, 0x04, 0x01, 0x39, - 0xdc, 0xee, 0x44, 0x17, 0x5e, 0xdb, 0xd7, 0x27, - 0xaf, 0xb6, 0x56, 0xd9, 0xb4, 0x43, 0x5a, 0x99, - 0xcf, 0xaa, 0x31, 0x37, 0x0c, 0x6f, 0x3a, 0xa0, - 0xf8, 0x53, 0xc4, 0x74, 0xd1, 0x91, 0x0a, 0x46, - 0xf5, 0x38, 0x3b, 0x5c, 0x09, 0xd8, 0x97, 0xdc, - 0x4b, 0xaa, 0x70, 0x26, 0x48, 0xf2, 0xd6, 0x0b, - 0x31, 0xc9, 0xf8, 0xd4, 0x98, 0x43, 0xe1, 0x6c, - 0xd5, 0xc7, 0xb2, 0x8e, 0x0b, 0x01, 0xe6, 0xb6, - 0x00, 0x28, 0x80, 0x7b, 0xfc, 0x96, 0x8f, 0x0d, - 0xa2, 0x4f, 0xb0, 0x79, 0xaf, 0xdc, 0x61, 0x28, - 0x63, 0x33, 0x78, 0xf6, 0x31, 0x39, 0xfd, 0x8a, - 0xf4, 0x15, 0x18, 0x11, 0xfe, 0xdb, 0xd5, 0x07, - 0xda, 0x2c, 0xed, 0x49, 0xa0, 0x23, 0xbf, 0xd0, - 0x3a, 0x38, 0x1d, 0x54, 0xae, 0x1c, 0x7b, 0xea, - 0x29, 0xee, 0xd0, 0x38, 0xc1, 0x76, 0xa7, 0x7f, - 0x2a, 0xf4, 0xce, 0x1e, 0xac, 0xcc, 0x94, 0x79, - 0x90, 0x33, 0x04, 0x01, 0x00, 0x80, 0x0d, 0x8e, - 0x79, 0xe6, 0x86, 0xf6, 0xb6, 0xfb, 0x6b, 0x6a, - 0xcc, 0x55, 0xe4, 0x80, 0x4d, 0xc5, 0x0c, 0xc6, - 0xa3, 0x9f, 0x1d, 0x39, 0xd2, 0x98, 0x57, 0x31, - 0xa2, 0x90, 0x73, 0xe8, 0xd2, 0xcd, 0xb0, 0x93, - 0x1a, 0x60, 0x0f, 0x38, 0x02, 0x3b, 0x1b, 0x25, - 0x56, 0xec, 0x44, 0xab, 0xbe, 0x2e, 0x0c, 0xc0, - 0x6e, 0x54, 0x91, 0x50, 0xd6, 0xb1, 0xa2, 0x98, - 0x14, 0xa8, 0x35, 0x62, 0x9d, 0xca, 0xfb, 0x0f, - 0x64, 0x2b, 0x05, 0xa0, 0xa0, 0x57, 0xef, 0xcd, - 0x95, 0x45, 0x13, 0x5a, 0x9b, 0x3d, 0xdb, 0x42, - 0x54, 0x7f, 0xb9, 0x17, 0x08, 0x7f, 0xb2, 0xf0, - 0xb1, 0xc3, 0xdf, 0x67, 0x95, 0xe2, 0x73, 0xf2, - 0x76, 0xa3, 0x97, 0xfd, 0x9c, 0x92, 0x4a, 0xdb, - 0x95, 0x1e, 0x91, 0x95, 0xae, 0x3d, 0xae, 0x58, - 0xb5, 0x03, 0x6f, 0x5c, 0x3a, 0x19, 0xab, 0x92, - 0xa5, 0x09, 0x6b, 0x40, 0x61, 0xb0, 0x16, 0x03, - 0x03, 0x00, 0x04, 0x0e, 0x00, 0x00, 0x00, - }, - { - 0x16, 0x03, 0x03, 0x00, 0x8a, 0x10, 0x00, 0x00, - 0x86, 0x85, 0x04, 0x01, 0xba, 0xb8, 0xad, 0x69, - 0x20, 0x5e, 0xc1, 0x61, 0xc3, 0x0f, 0xb4, 0x30, - 0x64, 0x66, 0x70, 0x96, 0x33, 0x3c, 0x8e, 0x12, - 0x56, 0xbf, 0x6d, 0xb8, 0x6d, 0xc6, 0xba, 0xea, - 0xfc, 0x38, 0xc0, 0x8b, 0x87, 0xa8, 0xf3, 0x87, - 0xa1, 0xd5, 0xb6, 0xb0, 0x72, 0xc7, 0xd4, 0x19, - 0x56, 0xa0, 0x91, 0xe1, 0x45, 0xc7, 0xf1, 0x7d, - 0xb0, 0x1d, 0x78, 0x18, 0xf6, 0x3d, 0xbf, 0x1a, - 0x23, 0x93, 0x0b, 0x19, 0xb1, 0x00, 0x56, 0xc9, - 0x5e, 0x89, 0xd4, 0x9d, 0xd9, 0x5b, 0xe0, 0xb8, - 0xff, 0x2f, 0x7d, 0x93, 0xae, 0x5b, 0xa5, 0x1f, - 0x1f, 0x2b, 0x09, 0xe5, 0xf6, 0x07, 0x26, 0xa3, - 0xed, 0xcb, 0x6a, 0x1a, 0xd6, 0x14, 0x83, 0x9b, - 0xd3, 0x9d, 0x47, 0x1b, 0xf3, 0x72, 0x5f, 0x69, - 0x21, 0x8f, 0xfa, 0x09, 0x38, 0x1a, 0x6b, 0x91, - 0xcf, 0x19, 0x32, 0x54, 0x58, 0x8e, 0xee, 0xaf, - 0xeb, 0x06, 0x9b, 0x3a, 0x34, 0x16, 0x66, 0x14, - 0x03, 0x03, 0x00, 0x01, 0x01, 0x16, 0x03, 0x03, - 0x00, 0x28, 0xc6, 0x96, 0x67, 0x62, 0xcc, 0x47, - 0x01, 0xb5, 0xbd, 0xb7, 0x24, 0xd3, 0xb6, 0xfd, - 0xb8, 0x46, 0xce, 0x82, 0x6d, 0x31, 0x1f, 0x15, - 0x11, 0x8f, 0xed, 0x62, 0x71, 0x5f, 0xae, 0xb6, - 0xa9, 0x0c, 0x24, 0x1d, 0xe8, 0x26, 0x51, 0xca, - 0x7c, 0x42, - }, - { - 0x16, 0x03, 0x03, 0x00, 0x72, 0x04, 0x00, 0x00, - 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, - 0xea, 0x8b, 0xfb, 0xef, 0xba, 0xc8, 0x88, 0x94, - 0x44, 0x99, 0x5f, 0x02, 0x68, 0x3a, 0x12, 0x67, - 0x7f, 0xb9, 0x39, 0x71, 0x84, 0xe0, 0x30, 0xe6, - 0x90, 0x6c, 0xcf, 0x32, 0x29, 0x29, 0x5c, 0x5a, - 0x8b, 0x7d, 0xaa, 0x11, 0x28, 0x26, 0xb5, 0xce, - 0xd2, 0x88, 0xd5, 0xb0, 0x5f, 0x94, 0x37, 0xa2, - 0x48, 0xd9, 0x53, 0xb2, 0xab, 0x59, 0x23, 0x3d, - 0x81, 0x6e, 0x64, 0x89, 0xca, 0x1a, 0x84, 0x16, - 0xdf, 0x31, 0x10, 0xde, 0x52, 0x7f, 0x50, 0xf3, - 0xd9, 0x27, 0xa0, 0xe8, 0x34, 0x15, 0x9e, 0x11, - 0xdd, 0xba, 0xce, 0x40, 0x17, 0xf3, 0x67, 0x14, - 0x03, 0x03, 0x00, 0x01, 0x01, 0x16, 0x03, 0x03, - 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x35, 0xcb, 0x17, 0x66, 0xee, 0xfd, - 0x27, 0xdb, 0xb8, 0xa8, 0x8a, 0xf1, 0x56, 0x67, - 0x89, 0x0d, 0x13, 0xac, 0xe2, 0x31, 0xb9, 0xa2, - 0x26, 0xbb, 0x1c, 0xcf, 0xd1, 0xb2, 0x48, 0x1d, - 0x0d, 0xb1, 0x17, 0x03, 0x03, 0x00, 0x25, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, - 0x89, 0x7c, 0x58, 0x6a, 0x9b, 0x00, 0x05, 0x8c, - 0x7f, 0x28, 0x54, 0x61, 0x44, 0x10, 0xee, 0x85, - 0x26, 0xa8, 0x04, 0xcd, 0xca, 0x85, 0x60, 0xf2, - 0xeb, 0x22, 0xbd, 0x9e, 0x15, 0x03, 0x03, 0x00, - 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x10, 0xe4, 0xe5, 0xf9, 0x85, 0xe3, 0xb0, - 0xec, 0x84, 0x29, 0x91, 0x05, 0x7d, 0x86, 0xe3, - 0x97, 0xeb, 0xb2, - }, -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/prf_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/prf_test.go deleted file mode 100644 index a9b6c9e4c7..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/prf_test.go +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package tls - -import ( - "encoding/hex" - "testing" -) - -type testSplitPreMasterSecretTest struct { - in, out1, out2 string -} - -var testSplitPreMasterSecretTests = []testSplitPreMasterSecretTest{ - {"", "", ""}, - {"00", "00", "00"}, - {"0011", "00", "11"}, - {"001122", "0011", "1122"}, - {"00112233", "0011", "2233"}, -} - -func TestSplitPreMasterSecret(t *testing.T) { - for i, test := range testSplitPreMasterSecretTests { - in, _ := hex.DecodeString(test.in) - out1, out2 := splitPreMasterSecret(in) - s1 := hex.EncodeToString(out1) - s2 := hex.EncodeToString(out2) - if s1 != test.out1 || s2 != test.out2 { - t.Errorf("#%d: got: (%s, %s) want: (%s, %s)", i, s1, s2, test.out1, test.out2) - } - } -} - -type testKeysFromTest struct { - version uint16 - preMasterSecret string - clientRandom, serverRandom string - masterSecret string - clientMAC, serverMAC string - clientKey, serverKey string - macLen, keyLen int -} - -func TestKeysFromPreMasterSecret(t *testing.T) { - for i, test := range testKeysFromTests { - in, _ := hex.DecodeString(test.preMasterSecret) - clientRandom, _ := hex.DecodeString(test.clientRandom) - serverRandom, _ := hex.DecodeString(test.serverRandom) - - masterSecret := masterFromPreMasterSecret(test.version, in, clientRandom, serverRandom) - if s := hex.EncodeToString(masterSecret); s != test.masterSecret { - t.Errorf("#%d: bad master secret %s, want %s", i, s, test.masterSecret) - continue - } - - clientMAC, serverMAC, clientKey, serverKey, _, _ := keysFromMasterSecret(test.version, masterSecret, clientRandom, serverRandom, test.macLen, test.keyLen, 0) - clientMACString := hex.EncodeToString(clientMAC) - serverMACString := hex.EncodeToString(serverMAC) - clientKeyString := hex.EncodeToString(clientKey) - serverKeyString := hex.EncodeToString(serverKey) - if clientMACString != test.clientMAC || - serverMACString != test.serverMAC || - clientKeyString != test.clientKey || - serverKeyString != test.serverKey { - t.Errorf("#%d: got: (%s, %s, %s, %s) want: (%s, %s, %s, %s)", i, clientMACString, serverMACString, clientKeyString, serverKeyString, test.clientMAC, test.serverMAC, test.clientKey, test.serverKey) - } - } -} - -// These test vectors were generated from GnuTLS using `gnutls-cli --insecure -d 9 ` -var testKeysFromTests = []testKeysFromTest{ - { - VersionTLS10, - "0302cac83ad4b1db3b9ab49ad05957de2a504a634a386fc600889321e1a971f57479466830ac3e6f468e87f5385fa0c5", - "4ae66303755184a3917fcb44880605fcc53baa01912b22ed94473fc69cebd558", - "4ae663020ec16e6bb5130be918cfcafd4d765979a3136a5d50c593446e4e44db", - "3d851bab6e5556e959a16bc36d66cfae32f672bfa9ecdef6096cbb1b23472df1da63dbbd9827606413221d149ed08ceb", - "805aaa19b3d2c0a0759a4b6c9959890e08480119", - "2d22f9fe519c075c16448305ceee209fc24ad109", - "d50b5771244f850cd8117a9ccafe2cf1", - "e076e33206b30507a85c32855acd0919", - 20, - 16, - }, - { - VersionTLS10, - "03023f7527316bc12cbcd69e4b9e8275d62c028f27e65c745cfcddc7ce01bd3570a111378b63848127f1c36e5f9e4890", - "4ae66364b5ea56b20ce4e25555aed2d7e67f42788dd03f3fee4adae0459ab106", - "4ae66363ab815cbf6a248b87d6b556184e945e9b97fbdf247858b0bdafacfa1c", - "7d64be7c80c59b740200b4b9c26d0baaa1c5ae56705acbcf2307fe62beb4728c19392c83f20483801cce022c77645460", - "97742ed60a0554ca13f04f97ee193177b971e3b0", - "37068751700400e03a8477a5c7eec0813ab9e0dc", - "207cddbc600d2a200abac6502053ee5c", - "df3f94f6e1eacc753b815fe16055cd43", - 20, - 16, - }, - { - VersionTLS10, - "832d515f1d61eebb2be56ba0ef79879efb9b527504abb386fb4310ed5d0e3b1f220d3bb6b455033a2773e6d8bdf951d278a187482b400d45deb88a5d5a6bb7d6a7a1decc04eb9ef0642876cd4a82d374d3b6ff35f0351dc5d411104de431375355addc39bfb1f6329fb163b0bc298d658338930d07d313cd980a7e3d9196cac1", - "4ae663b2ee389c0de147c509d8f18f5052afc4aaf9699efe8cb05ece883d3a5e", - "4ae664d503fd4cff50cfc1fb8fc606580f87b0fcdac9554ba0e01d785bdf278e", - "1aff2e7a2c4279d0126f57a65a77a8d9d0087cf2733366699bec27eb53d5740705a8574bb1acc2abbe90e44f0dd28d6c", - "3c7647c93c1379a31a609542aa44e7f117a70085", - "0d73102994be74a575a3ead8532590ca32a526d4", - "ac7581b0b6c10d85bbd905ffbf36c65e", - "ff07edde49682b45466bd2e39464b306", - 20, - 16, - }, - { - VersionSSL30, - "832d515f1d61eebb2be56ba0ef79879efb9b527504abb386fb4310ed5d0e3b1f220d3bb6b455033a2773e6d8bdf951d278a187482b400d45deb88a5d5a6bb7d6a7a1decc04eb9ef0642876cd4a82d374d3b6ff35f0351dc5d411104de431375355addc39bfb1f6329fb163b0bc298d658338930d07d313cd980a7e3d9196cac1", - "4ae663b2ee389c0de147c509d8f18f5052afc4aaf9699efe8cb05ece883d3a5e", - "4ae664d503fd4cff50cfc1fb8fc606580f87b0fcdac9554ba0e01d785bdf278e", - "a614863e56299dcffeea2938f22c2ba023768dbe4b3f6877bc9c346c6ae529b51d9cb87ff9695ea4d01f2205584405b2", - "2c450d5b6f6e2013ac6bea6a0b32200d4e1ffb94", - "7a7a7438769536f2fb1ae49a61f0703b79b2dc53", - "f8f6b26c10f12855c9aafb1e0e839ccf", - "2b9d4b4a60cb7f396780ebff50650419", - 20, - 16, - }, -} diff --git a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/tls_test.go b/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/tls_test.go deleted file mode 100644 index 38229014cd..0000000000 --- a/vendor/github.com/MSOpenTech/azure-sdk-for-go/core/tls/tls_test.go +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package tls - -import ( - "testing" -) - -var rsaCertPEM = `-----BEGIN CERTIFICATE----- -MIIB0zCCAX2gAwIBAgIJAI/M7BYjwB+uMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV -BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX -aWRnaXRzIFB0eSBMdGQwHhcNMTIwOTEyMjE1MjAyWhcNMTUwOTEyMjE1MjAyWjBF -MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50 -ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANLJ -hPHhITqQbPklG3ibCVxwGMRfp/v4XqhfdQHdcVfHap6NQ5Wok/4xIA+ui35/MmNa -rtNuC+BdZ1tMuVCPFZcCAwEAAaNQME4wHQYDVR0OBBYEFJvKs8RfJaXTH08W+SGv -zQyKn0H8MB8GA1UdIwQYMBaAFJvKs8RfJaXTH08W+SGvzQyKn0H8MAwGA1UdEwQF -MAMBAf8wDQYJKoZIhvcNAQEFBQADQQBJlffJHybjDGxRMqaRmDhX0+6v02TUKZsW -r5QuVbpQhH6u+0UgcW0jp9QwpxoPTLTWGXEWBBBurxFwiCBhkQ+V ------END CERTIFICATE----- -` - -var rsaKeyPEM = `-----BEGIN RSA PRIVATE KEY----- -MIIBOwIBAAJBANLJhPHhITqQbPklG3ibCVxwGMRfp/v4XqhfdQHdcVfHap6NQ5Wo -k/4xIA+ui35/MmNartNuC+BdZ1tMuVCPFZcCAwEAAQJAEJ2N+zsR0Xn8/Q6twa4G -6OB1M1WO+k+ztnX/1SvNeWu8D6GImtupLTYgjZcHufykj09jiHmjHx8u8ZZB/o1N -MQIhAPW+eyZo7ay3lMz1V01WVjNKK9QSn1MJlb06h/LuYv9FAiEA25WPedKgVyCW -SmUwbPw8fnTcpqDWE3yTO3vKcebqMSsCIBF3UmVue8YU3jybC3NxuXq3wNm34R8T -xVLHwDXh/6NJAiEAl2oHGGLz64BuAfjKrqwz7qMYr9HCLIe/YsoWq/olzScCIQDi -D2lWusoe2/nEqfDVVWGWlyJ7yOmqaVm/iNUN9B2N2g== ------END RSA PRIVATE KEY----- -` - -// keyPEM is the same as rsaKeyPEM, but declares itself as just -// "PRIVATE KEY", not "RSA PRIVATE KEY". http://golang.org/issue/4477 -var keyPEM = `-----BEGIN PRIVATE KEY----- -MIIBOwIBAAJBANLJhPHhITqQbPklG3ibCVxwGMRfp/v4XqhfdQHdcVfHap6NQ5Wo -k/4xIA+ui35/MmNartNuC+BdZ1tMuVCPFZcCAwEAAQJAEJ2N+zsR0Xn8/Q6twa4G -6OB1M1WO+k+ztnX/1SvNeWu8D6GImtupLTYgjZcHufykj09jiHmjHx8u8ZZB/o1N -MQIhAPW+eyZo7ay3lMz1V01WVjNKK9QSn1MJlb06h/LuYv9FAiEA25WPedKgVyCW -SmUwbPw8fnTcpqDWE3yTO3vKcebqMSsCIBF3UmVue8YU3jybC3NxuXq3wNm34R8T -xVLHwDXh/6NJAiEAl2oHGGLz64BuAfjKrqwz7qMYr9HCLIe/YsoWq/olzScCIQDi -D2lWusoe2/nEqfDVVWGWlyJ7yOmqaVm/iNUN9B2N2g== ------END PRIVATE KEY----- -` - -var ecdsaCertPEM = `-----BEGIN CERTIFICATE----- -MIIB/jCCAWICCQDscdUxw16XFDAJBgcqhkjOPQQBMEUxCzAJBgNVBAYTAkFVMRMw -EQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0 -eSBMdGQwHhcNMTIxMTE0MTI0MDQ4WhcNMTUxMTE0MTI0MDQ4WjBFMQswCQYDVQQG -EwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lk -Z2l0cyBQdHkgTHRkMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBY9+my9OoeSUR -lDQdV/x8LsOuLilthhiS1Tz4aGDHIPwC1mlvnf7fg5lecYpMCrLLhauAc1UJXcgl -01xoLuzgtAEAgv2P/jgytzRSpUYvgLBt1UA0leLYBy6mQQbrNEuqT3INapKIcUv8 -XxYP0xMEUksLPq6Ca+CRSqTtrd/23uTnapkwCQYHKoZIzj0EAQOBigAwgYYCQXJo -A7Sl2nLVf+4Iu/tAX/IF4MavARKC4PPHK3zfuGfPR3oCCcsAoz3kAzOeijvd0iXb -H5jBImIxPL4WxQNiBTexAkF8D1EtpYuWdlVQ80/h/f4pBcGiXPqX5h2PQSQY7hP1 -+jwM1FGS4fREIOvlBYr/SzzQRtwrvrzGYxDEDbsC0ZGRnA== ------END CERTIFICATE----- -` - -var ecdsaKeyPEM = `-----BEGIN EC PARAMETERS----- -BgUrgQQAIw== ------END EC PARAMETERS----- ------BEGIN EC PRIVATE KEY----- -MIHcAgEBBEIBrsoKp0oqcv6/JovJJDoDVSGWdirrkgCWxrprGlzB9o0X8fV675X0 -NwuBenXFfeZvVcwluO7/Q9wkYoPd/t3jGImgBwYFK4EEACOhgYkDgYYABAFj36bL -06h5JRGUNB1X/Hwuw64uKW2GGJLVPPhoYMcg/ALWaW+d/t+DmV5xikwKssuFq4Bz -VQldyCXTXGgu7OC0AQCC/Y/+ODK3NFKlRi+AsG3VQDSV4tgHLqZBBus0S6pPcg1q -kohxS/xfFg/TEwRSSws+roJr4JFKpO2t3/be5OdqmQ== ------END EC PRIVATE KEY----- -` - -var keyPairTests = []struct { - algo string - cert string - key string -}{ - {"ECDSA", ecdsaCertPEM, ecdsaKeyPEM}, - {"RSA", rsaCertPEM, rsaKeyPEM}, - {"RSA-untyped", rsaCertPEM, keyPEM}, // golang.org/issue/4477 -} - -func TestX509KeyPair(t *testing.T) { - var pem []byte - for _, test := range keyPairTests { - pem = []byte(test.cert + test.key) - if _, err := X509KeyPair(pem, pem); err != nil { - t.Errorf("Failed to load %s cert followed by %s key: %s", test.algo, test.algo, err) - } - pem = []byte(test.key + test.cert) - if _, err := X509KeyPair(pem, pem); err != nil { - t.Errorf("Failed to load %s key followed by %s cert: %s", test.algo, test.algo, err) - } - } -} - -func TestX509MixedKeyPair(t *testing.T) { - if _, err := X509KeyPair([]byte(rsaCertPEM), []byte(ecdsaKeyPEM)); err == nil { - t.Error("Load of RSA certificate succeeded with ECDSA private key") - } - if _, err := X509KeyPair([]byte(ecdsaCertPEM), []byte(rsaKeyPEM)); err == nil { - t.Error("Load of ECDSA certificate succeeded with RSA private key") - } -} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/credentials/stscreds/assume_role_provider.go b/vendor/github.com/aws/aws-sdk-go/aws/credentials/stscreds/assume_role_provider.go deleted file mode 100644 index 0214860d4c..0000000000 --- a/vendor/github.com/aws/aws-sdk-go/aws/credentials/stscreds/assume_role_provider.go +++ /dev/null @@ -1,130 +0,0 @@ -// Package stscreds are credential Providers to retrieve STS AWS credentials. -// -// STS provides multiple ways to retrieve credentials which can be used when making -// future AWS service API operation calls. -package stscreds - -import ( - "fmt" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/client" - "github.com/aws/aws-sdk-go/aws/credentials" - "github.com/aws/aws-sdk-go/service/sts" -) - -// AssumeRoler represents the minimal subset of the STS client API used by this provider. -type AssumeRoler interface { - AssumeRole(input *sts.AssumeRoleInput) (*sts.AssumeRoleOutput, error) -} - -// DefaultDuration is the default amount of time in minutes that the credentials -// will be valid for. -var DefaultDuration = time.Duration(15) * time.Minute - -// AssumeRoleProvider retrieves temporary credentials from the STS service, and -// keeps track of their expiration time. This provider must be used explicitly, -// as it is not included in the credentials chain. -type AssumeRoleProvider struct { - credentials.Expiry - - // STS client to make assume role request with. - Client AssumeRoler - - // Role to be assumed. - RoleARN string - - // Session name, if you wish to reuse the credentials elsewhere. - RoleSessionName string - - // Expiry duration of the STS credentials. Defaults to 15 minutes if not set. - Duration time.Duration - - // Optional ExternalID to pass along, defaults to nil if not set. - ExternalID *string - - // ExpiryWindow will allow the credentials to trigger refreshing prior to - // the credentials actually expiring. This is beneficial so race conditions - // with expiring credentials do not cause request to fail unexpectedly - // due to ExpiredTokenException exceptions. - // - // So a ExpiryWindow of 10s would cause calls to IsExpired() to return true - // 10 seconds before the credentials are actually expired. - // - // If ExpiryWindow is 0 or less it will be ignored. - ExpiryWindow time.Duration -} - -// NewCredentials returns a pointer to a new Credentials object wrapping the -// AssumeRoleProvider. The credentials will expire every 15 minutes and the -// role will be named after a nanosecond timestamp of this operation. -// -// Takes a Config provider to create the STS client. The ConfigProvider is -// satisfied by the session.Session type. -func NewCredentials(c client.ConfigProvider, roleARN string, options ...func(*AssumeRoleProvider)) *credentials.Credentials { - p := &AssumeRoleProvider{ - Client: sts.New(c), - RoleARN: roleARN, - Duration: DefaultDuration, - } - - for _, option := range options { - option(p) - } - - return credentials.NewCredentials(p) -} - -// NewCredentialsWithClient returns a pointer to a new Credentials object wrapping the -// AssumeRoleProvider. The credentials will expire every 15 minutes and the -// role will be named after a nanosecond timestamp of this operation. -// -// Takes an AssumeRoler which can be satisfiede by the STS client. -func NewCredentialsWithClient(svc AssumeRoler, roleARN string, options ...func(*AssumeRoleProvider)) *credentials.Credentials { - p := &AssumeRoleProvider{ - Client: svc, - RoleARN: roleARN, - Duration: DefaultDuration, - } - - for _, option := range options { - option(p) - } - - return credentials.NewCredentials(p) -} - -// Retrieve generates a new set of temporary credentials using STS. -func (p *AssumeRoleProvider) Retrieve() (credentials.Value, error) { - - // Apply defaults where parameters are not set. - if p.RoleSessionName == "" { - // Try to work out a role name that will hopefully end up unique. - p.RoleSessionName = fmt.Sprintf("%d", time.Now().UTC().UnixNano()) - } - if p.Duration == 0 { - // Expire as often as AWS permits. - p.Duration = DefaultDuration - } - - roleOutput, err := p.Client.AssumeRole(&sts.AssumeRoleInput{ - DurationSeconds: aws.Int64(int64(p.Duration / time.Second)), - RoleArn: aws.String(p.RoleARN), - RoleSessionName: aws.String(p.RoleSessionName), - ExternalId: p.ExternalID, - }) - - if err != nil { - return credentials.Value{}, err - } - - // We will proactively generate new credentials before they expire. - p.SetExpiration(*roleOutput.Credentials.Expiration, p.ExpiryWindow) - - return credentials.Value{ - AccessKeyID: *roleOutput.Credentials.AccessKeyId, - SecretAccessKey: *roleOutput.Credentials.SecretAccessKey, - SessionToken: *roleOutput.Credentials.SessionToken, - }, nil -} diff --git a/vendor/github.com/docker/docker/pkg/units/MAINTAINERS b/vendor/github.com/docker/docker/pkg/units/MAINTAINERS deleted file mode 100644 index 96abeae570..0000000000 --- a/vendor/github.com/docker/docker/pkg/units/MAINTAINERS +++ /dev/null @@ -1,2 +0,0 @@ -Victor Vieux (@vieux) -Jessie Frazelle (@jfrazelle) diff --git a/vendor/github.com/docker/docker/pkg/units/duration.go b/vendor/github.com/docker/docker/pkg/units/duration.go deleted file mode 100644 index cd33121496..0000000000 --- a/vendor/github.com/docker/docker/pkg/units/duration.go +++ /dev/null @@ -1,31 +0,0 @@ -package units - -import ( - "fmt" - "time" -) - -// HumanDuration returns a human-readable approximation of a duration -// (eg. "About a minute", "4 hours ago", etc.) -func HumanDuration(d time.Duration) string { - if seconds := int(d.Seconds()); seconds < 1 { - return "Less than a second" - } else if seconds < 60 { - return fmt.Sprintf("%d seconds", seconds) - } else if minutes := int(d.Minutes()); minutes == 1 { - return "About a minute" - } else if minutes < 60 { - return fmt.Sprintf("%d minutes", minutes) - } else if hours := int(d.Hours()); hours == 1 { - return "About an hour" - } else if hours < 48 { - return fmt.Sprintf("%d hours", hours) - } else if hours < 24*7*2 { - return fmt.Sprintf("%d days", hours/24) - } else if hours < 24*30*3 { - return fmt.Sprintf("%d weeks", hours/24/7) - } else if hours < 24*365*2 { - return fmt.Sprintf("%d months", hours/24/30) - } - return fmt.Sprintf("%f years", d.Hours()/24/365) -} diff --git a/vendor/github.com/docker/docker/pkg/units/size.go b/vendor/github.com/docker/docker/pkg/units/size.go deleted file mode 100644 index 7cfb57ba51..0000000000 --- a/vendor/github.com/docker/docker/pkg/units/size.go +++ /dev/null @@ -1,91 +0,0 @@ -package units - -import ( - "fmt" - "regexp" - "strconv" - "strings" -) - -// See: http://en.wikipedia.org/wiki/Binary_prefix -const ( - // Decimal - - KB = 1000 - MB = 1000 * KB - GB = 1000 * MB - TB = 1000 * GB - PB = 1000 * TB - - // Binary - - KiB = 1024 - MiB = 1024 * KiB - GiB = 1024 * MiB - TiB = 1024 * GiB - PiB = 1024 * TiB -) - -type unitMap map[string]int64 - -var ( - decimalMap = unitMap{"k": KB, "m": MB, "g": GB, "t": TB, "p": PB} - binaryMap = unitMap{"k": KiB, "m": MiB, "g": GiB, "t": TiB, "p": PiB} - sizeRegex = regexp.MustCompile(`^(\d+)([kKmMgGtTpP])?[bB]?$`) -) - -var decimapAbbrs = []string{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"} -var binaryAbbrs = []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"} - -// HumanSize returns a human-readable approximation of a size -// using SI standard (eg. "44kB", "17MB") -func HumanSize(size float64) string { - return intToString(float64(size), 1000.0, decimapAbbrs) -} - -func BytesSize(size float64) string { - return intToString(size, 1024.0, binaryAbbrs) -} - -func intToString(size, unit float64, _map []string) string { - i := 0 - for size >= unit { - size = size / unit - i++ - } - return fmt.Sprintf("%.4g %s", size, _map[i]) -} - -// FromHumanSize returns an integer from a human-readable specification of a -// size using SI standard (eg. "44kB", "17MB") -func FromHumanSize(size string) (int64, error) { - return parseSize(size, decimalMap) -} - -// RAMInBytes parses a human-readable string representing an amount of RAM -// in bytes, kibibytes, mebibytes, gibibytes, or tebibytes and -// returns the number of bytes, or -1 if the string is unparseable. -// Units are case-insensitive, and the 'b' suffix is optional. -func RAMInBytes(size string) (int64, error) { - return parseSize(size, binaryMap) -} - -// Parses the human-readable size string into the amount it represents -func parseSize(sizeStr string, uMap unitMap) (int64, error) { - matches := sizeRegex.FindStringSubmatch(sizeStr) - if len(matches) != 3 { - return -1, fmt.Errorf("invalid size: '%s'", sizeStr) - } - - size, err := strconv.ParseInt(matches[1], 10, 0) - if err != nil { - return -1, err - } - - unitPrefix := strings.ToLower(matches[2]) - if mul, ok := uMap[unitPrefix]; ok { - size *= mul - } - - return size, nil -} diff --git a/vendor/github.com/golang/protobuf/LICENSE b/vendor/github.com/golang/protobuf/LICENSE new file mode 100644 index 0000000000..1b1b1921ef --- /dev/null +++ b/vendor/github.com/golang/protobuf/LICENSE @@ -0,0 +1,31 @@ +Go support for Protocol Buffers - Google's data interchange format + +Copyright 2010 The Go Authors. All rights reserved. +https://github.com/golang/protobuf + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/vendor/github.com/golang/protobuf/proto/Makefile b/vendor/github.com/golang/protobuf/proto/Makefile new file mode 100644 index 0000000000..f1f06564a1 --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/Makefile @@ -0,0 +1,43 @@ +# Go support for Protocol Buffers - Google's data interchange format +# +# Copyright 2010 The Go Authors. All rights reserved. +# https://github.com/golang/protobuf +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +install: + go install + +test: install generate-test-pbs + go test + + +generate-test-pbs: + make install + make -C testdata + protoc --go_out=Mtestdata/test.proto=github.com/golang/protobuf/proto/testdata:. proto3_proto/proto3.proto + make diff --git a/vendor/github.com/golang/protobuf/proto/clone.go b/vendor/github.com/golang/protobuf/proto/clone.go new file mode 100644 index 0000000000..e98ddec981 --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/clone.go @@ -0,0 +1,223 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2011 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Protocol buffer deep copy and merge. +// TODO: RawMessage. + +package proto + +import ( + "log" + "reflect" + "strings" +) + +// Clone returns a deep copy of a protocol buffer. +func Clone(pb Message) Message { + in := reflect.ValueOf(pb) + if in.IsNil() { + return pb + } + + out := reflect.New(in.Type().Elem()) + // out is empty so a merge is a deep copy. + mergeStruct(out.Elem(), in.Elem()) + return out.Interface().(Message) +} + +// Merge merges src into dst. +// Required and optional fields that are set in src will be set to that value in dst. +// Elements of repeated fields will be appended. +// Merge panics if src and dst are not the same type, or if dst is nil. +func Merge(dst, src Message) { + in := reflect.ValueOf(src) + out := reflect.ValueOf(dst) + if out.IsNil() { + panic("proto: nil destination") + } + if in.Type() != out.Type() { + // Explicit test prior to mergeStruct so that mistyped nils will fail + panic("proto: type mismatch") + } + if in.IsNil() { + // Merging nil into non-nil is a quiet no-op + return + } + mergeStruct(out.Elem(), in.Elem()) +} + +func mergeStruct(out, in reflect.Value) { + sprop := GetProperties(in.Type()) + for i := 0; i < in.NumField(); i++ { + f := in.Type().Field(i) + if strings.HasPrefix(f.Name, "XXX_") { + continue + } + mergeAny(out.Field(i), in.Field(i), false, sprop.Prop[i]) + } + + if emIn, ok := in.Addr().Interface().(extendableProto); ok { + emOut := out.Addr().Interface().(extendableProto) + mergeExtension(emOut.ExtensionMap(), emIn.ExtensionMap()) + } + + uf := in.FieldByName("XXX_unrecognized") + if !uf.IsValid() { + return + } + uin := uf.Bytes() + if len(uin) > 0 { + out.FieldByName("XXX_unrecognized").SetBytes(append([]byte(nil), uin...)) + } +} + +// mergeAny performs a merge between two values of the same type. +// viaPtr indicates whether the values were indirected through a pointer (implying proto2). +// prop is set if this is a struct field (it may be nil). +func mergeAny(out, in reflect.Value, viaPtr bool, prop *Properties) { + if in.Type() == protoMessageType { + if !in.IsNil() { + if out.IsNil() { + out.Set(reflect.ValueOf(Clone(in.Interface().(Message)))) + } else { + Merge(out.Interface().(Message), in.Interface().(Message)) + } + } + return + } + switch in.Kind() { + case reflect.Bool, reflect.Float32, reflect.Float64, reflect.Int32, reflect.Int64, + reflect.String, reflect.Uint32, reflect.Uint64: + if !viaPtr && isProto3Zero(in) { + return + } + out.Set(in) + case reflect.Interface: + // Probably a oneof field; copy non-nil values. + if in.IsNil() { + return + } + // Allocate destination if it is not set, or set to a different type. + // Otherwise we will merge as normal. + if out.IsNil() || out.Elem().Type() != in.Elem().Type() { + out.Set(reflect.New(in.Elem().Elem().Type())) // interface -> *T -> T -> new(T) + } + mergeAny(out.Elem(), in.Elem(), false, nil) + case reflect.Map: + if in.Len() == 0 { + return + } + if out.IsNil() { + out.Set(reflect.MakeMap(in.Type())) + } + // For maps with value types of *T or []byte we need to deep copy each value. + elemKind := in.Type().Elem().Kind() + for _, key := range in.MapKeys() { + var val reflect.Value + switch elemKind { + case reflect.Ptr: + val = reflect.New(in.Type().Elem().Elem()) + mergeAny(val, in.MapIndex(key), false, nil) + case reflect.Slice: + val = in.MapIndex(key) + val = reflect.ValueOf(append([]byte{}, val.Bytes()...)) + default: + val = in.MapIndex(key) + } + out.SetMapIndex(key, val) + } + case reflect.Ptr: + if in.IsNil() { + return + } + if out.IsNil() { + out.Set(reflect.New(in.Elem().Type())) + } + mergeAny(out.Elem(), in.Elem(), true, nil) + case reflect.Slice: + if in.IsNil() { + return + } + if in.Type().Elem().Kind() == reflect.Uint8 { + // []byte is a scalar bytes field, not a repeated field. + + // Edge case: if this is in a proto3 message, a zero length + // bytes field is considered the zero value, and should not + // be merged. + if prop != nil && prop.proto3 && in.Len() == 0 { + return + } + + // Make a deep copy. + // Append to []byte{} instead of []byte(nil) so that we never end up + // with a nil result. + out.SetBytes(append([]byte{}, in.Bytes()...)) + return + } + n := in.Len() + if out.IsNil() { + out.Set(reflect.MakeSlice(in.Type(), 0, n)) + } + switch in.Type().Elem().Kind() { + case reflect.Bool, reflect.Float32, reflect.Float64, reflect.Int32, reflect.Int64, + reflect.String, reflect.Uint32, reflect.Uint64: + out.Set(reflect.AppendSlice(out, in)) + default: + for i := 0; i < n; i++ { + x := reflect.Indirect(reflect.New(in.Type().Elem())) + mergeAny(x, in.Index(i), false, nil) + out.Set(reflect.Append(out, x)) + } + } + case reflect.Struct: + mergeStruct(out, in) + default: + // unknown type, so not a protocol buffer + log.Printf("proto: don't know how to copy %v", in) + } +} + +func mergeExtension(out, in map[int32]Extension) { + for extNum, eIn := range in { + eOut := Extension{desc: eIn.desc} + if eIn.value != nil { + v := reflect.New(reflect.TypeOf(eIn.value)).Elem() + mergeAny(v, reflect.ValueOf(eIn.value), false, nil) + eOut.value = v.Interface() + } + if eIn.enc != nil { + eOut.enc = make([]byte, len(eIn.enc)) + copy(eOut.enc, eIn.enc) + } + + out[extNum] = eOut + } +} diff --git a/vendor/github.com/golang/protobuf/proto/decode.go b/vendor/github.com/golang/protobuf/proto/decode.go new file mode 100644 index 0000000000..5810782fd8 --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/decode.go @@ -0,0 +1,867 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +/* + * Routines for decoding protocol buffer data to construct in-memory representations. + */ + +import ( + "errors" + "fmt" + "io" + "os" + "reflect" +) + +// errOverflow is returned when an integer is too large to be represented. +var errOverflow = errors.New("proto: integer overflow") + +// ErrInternalBadWireType is returned by generated code when an incorrect +// wire type is encountered. It does not get returned to user code. +var ErrInternalBadWireType = errors.New("proto: internal error: bad wiretype for oneof") + +// The fundamental decoders that interpret bytes on the wire. +// Those that take integer types all return uint64 and are +// therefore of type valueDecoder. + +// DecodeVarint reads a varint-encoded integer from the slice. +// It returns the integer and the number of bytes consumed, or +// zero if there is not enough. +// This is the format for the +// int32, int64, uint32, uint64, bool, and enum +// protocol buffer types. +func DecodeVarint(buf []byte) (x uint64, n int) { + // x, n already 0 + for shift := uint(0); shift < 64; shift += 7 { + if n >= len(buf) { + return 0, 0 + } + b := uint64(buf[n]) + n++ + x |= (b & 0x7F) << shift + if (b & 0x80) == 0 { + return x, n + } + } + + // The number is too large to represent in a 64-bit value. + return 0, 0 +} + +// DecodeVarint reads a varint-encoded integer from the Buffer. +// This is the format for the +// int32, int64, uint32, uint64, bool, and enum +// protocol buffer types. +func (p *Buffer) DecodeVarint() (x uint64, err error) { + // x, err already 0 + + i := p.index + l := len(p.buf) + + for shift := uint(0); shift < 64; shift += 7 { + if i >= l { + err = io.ErrUnexpectedEOF + return + } + b := p.buf[i] + i++ + x |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + p.index = i + return + } + } + + // The number is too large to represent in a 64-bit value. + err = errOverflow + return +} + +// DecodeFixed64 reads a 64-bit integer from the Buffer. +// This is the format for the +// fixed64, sfixed64, and double protocol buffer types. +func (p *Buffer) DecodeFixed64() (x uint64, err error) { + // x, err already 0 + i := p.index + 8 + if i < 0 || i > len(p.buf) { + err = io.ErrUnexpectedEOF + return + } + p.index = i + + x = uint64(p.buf[i-8]) + x |= uint64(p.buf[i-7]) << 8 + x |= uint64(p.buf[i-6]) << 16 + x |= uint64(p.buf[i-5]) << 24 + x |= uint64(p.buf[i-4]) << 32 + x |= uint64(p.buf[i-3]) << 40 + x |= uint64(p.buf[i-2]) << 48 + x |= uint64(p.buf[i-1]) << 56 + return +} + +// DecodeFixed32 reads a 32-bit integer from the Buffer. +// This is the format for the +// fixed32, sfixed32, and float protocol buffer types. +func (p *Buffer) DecodeFixed32() (x uint64, err error) { + // x, err already 0 + i := p.index + 4 + if i < 0 || i > len(p.buf) { + err = io.ErrUnexpectedEOF + return + } + p.index = i + + x = uint64(p.buf[i-4]) + x |= uint64(p.buf[i-3]) << 8 + x |= uint64(p.buf[i-2]) << 16 + x |= uint64(p.buf[i-1]) << 24 + return +} + +// DecodeZigzag64 reads a zigzag-encoded 64-bit integer +// from the Buffer. +// This is the format used for the sint64 protocol buffer type. +func (p *Buffer) DecodeZigzag64() (x uint64, err error) { + x, err = p.DecodeVarint() + if err != nil { + return + } + x = (x >> 1) ^ uint64((int64(x&1)<<63)>>63) + return +} + +// DecodeZigzag32 reads a zigzag-encoded 32-bit integer +// from the Buffer. +// This is the format used for the sint32 protocol buffer type. +func (p *Buffer) DecodeZigzag32() (x uint64, err error) { + x, err = p.DecodeVarint() + if err != nil { + return + } + x = uint64((uint32(x) >> 1) ^ uint32((int32(x&1)<<31)>>31)) + return +} + +// These are not ValueDecoders: they produce an array of bytes or a string. +// bytes, embedded messages + +// DecodeRawBytes reads a count-delimited byte buffer from the Buffer. +// This is the format used for the bytes protocol buffer +// type and for embedded messages. +func (p *Buffer) DecodeRawBytes(alloc bool) (buf []byte, err error) { + n, err := p.DecodeVarint() + if err != nil { + return nil, err + } + + nb := int(n) + if nb < 0 { + return nil, fmt.Errorf("proto: bad byte length %d", nb) + } + end := p.index + nb + if end < p.index || end > len(p.buf) { + return nil, io.ErrUnexpectedEOF + } + + if !alloc { + // todo: check if can get more uses of alloc=false + buf = p.buf[p.index:end] + p.index += nb + return + } + + buf = make([]byte, nb) + copy(buf, p.buf[p.index:]) + p.index += nb + return +} + +// DecodeStringBytes reads an encoded string from the Buffer. +// This is the format used for the proto2 string type. +func (p *Buffer) DecodeStringBytes() (s string, err error) { + buf, err := p.DecodeRawBytes(false) + if err != nil { + return + } + return string(buf), nil +} + +// Skip the next item in the buffer. Its wire type is decoded and presented as an argument. +// If the protocol buffer has extensions, and the field matches, add it as an extension. +// Otherwise, if the XXX_unrecognized field exists, append the skipped data there. +func (o *Buffer) skipAndSave(t reflect.Type, tag, wire int, base structPointer, unrecField field) error { + oi := o.index + + err := o.skip(t, tag, wire) + if err != nil { + return err + } + + if !unrecField.IsValid() { + return nil + } + + ptr := structPointer_Bytes(base, unrecField) + + // Add the skipped field to struct field + obuf := o.buf + + o.buf = *ptr + o.EncodeVarint(uint64(tag<<3 | wire)) + *ptr = append(o.buf, obuf[oi:o.index]...) + + o.buf = obuf + + return nil +} + +// Skip the next item in the buffer. Its wire type is decoded and presented as an argument. +func (o *Buffer) skip(t reflect.Type, tag, wire int) error { + + var u uint64 + var err error + + switch wire { + case WireVarint: + _, err = o.DecodeVarint() + case WireFixed64: + _, err = o.DecodeFixed64() + case WireBytes: + _, err = o.DecodeRawBytes(false) + case WireFixed32: + _, err = o.DecodeFixed32() + case WireStartGroup: + for { + u, err = o.DecodeVarint() + if err != nil { + break + } + fwire := int(u & 0x7) + if fwire == WireEndGroup { + break + } + ftag := int(u >> 3) + err = o.skip(t, ftag, fwire) + if err != nil { + break + } + } + default: + err = fmt.Errorf("proto: can't skip unknown wire type %d for %s", wire, t) + } + return err +} + +// Unmarshaler is the interface representing objects that can +// unmarshal themselves. The method should reset the receiver before +// decoding starts. The argument points to data that may be +// overwritten, so implementations should not keep references to the +// buffer. +type Unmarshaler interface { + Unmarshal([]byte) error +} + +// Unmarshal parses the protocol buffer representation in buf and places the +// decoded result in pb. If the struct underlying pb does not match +// the data in buf, the results can be unpredictable. +// +// Unmarshal resets pb before starting to unmarshal, so any +// existing data in pb is always removed. Use UnmarshalMerge +// to preserve and append to existing data. +func Unmarshal(buf []byte, pb Message) error { + pb.Reset() + return UnmarshalMerge(buf, pb) +} + +// UnmarshalMerge parses the protocol buffer representation in buf and +// writes the decoded result to pb. If the struct underlying pb does not match +// the data in buf, the results can be unpredictable. +// +// UnmarshalMerge merges into existing data in pb. +// Most code should use Unmarshal instead. +func UnmarshalMerge(buf []byte, pb Message) error { + // If the object can unmarshal itself, let it. + if u, ok := pb.(Unmarshaler); ok { + return u.Unmarshal(buf) + } + return NewBuffer(buf).Unmarshal(pb) +} + +// DecodeMessage reads a count-delimited message from the Buffer. +func (p *Buffer) DecodeMessage(pb Message) error { + enc, err := p.DecodeRawBytes(false) + if err != nil { + return err + } + return NewBuffer(enc).Unmarshal(pb) +} + +// DecodeGroup reads a tag-delimited group from the Buffer. +func (p *Buffer) DecodeGroup(pb Message) error { + typ, base, err := getbase(pb) + if err != nil { + return err + } + return p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), true, base) +} + +// Unmarshal parses the protocol buffer representation in the +// Buffer and places the decoded result in pb. If the struct +// underlying pb does not match the data in the buffer, the results can be +// unpredictable. +func (p *Buffer) Unmarshal(pb Message) error { + // If the object can unmarshal itself, let it. + if u, ok := pb.(Unmarshaler); ok { + err := u.Unmarshal(p.buf[p.index:]) + p.index = len(p.buf) + return err + } + + typ, base, err := getbase(pb) + if err != nil { + return err + } + + err = p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), false, base) + + if collectStats { + stats.Decode++ + } + + return err +} + +// unmarshalType does the work of unmarshaling a structure. +func (o *Buffer) unmarshalType(st reflect.Type, prop *StructProperties, is_group bool, base structPointer) error { + var state errorState + required, reqFields := prop.reqCount, uint64(0) + + var err error + for err == nil && o.index < len(o.buf) { + oi := o.index + var u uint64 + u, err = o.DecodeVarint() + if err != nil { + break + } + wire := int(u & 0x7) + if wire == WireEndGroup { + if is_group { + return nil // input is satisfied + } + return fmt.Errorf("proto: %s: wiretype end group for non-group", st) + } + tag := int(u >> 3) + if tag <= 0 { + return fmt.Errorf("proto: %s: illegal tag %d (wire type %d)", st, tag, wire) + } + fieldnum, ok := prop.decoderTags.get(tag) + if !ok { + // Maybe it's an extension? + if prop.extendable { + if e := structPointer_Interface(base, st).(extendableProto); isExtensionField(e, int32(tag)) { + if err = o.skip(st, tag, wire); err == nil { + ext := e.ExtensionMap()[int32(tag)] // may be missing + ext.enc = append(ext.enc, o.buf[oi:o.index]...) + e.ExtensionMap()[int32(tag)] = ext + } + continue + } + } + // Maybe it's a oneof? + if prop.oneofUnmarshaler != nil { + m := structPointer_Interface(base, st).(Message) + // First return value indicates whether tag is a oneof field. + ok, err = prop.oneofUnmarshaler(m, tag, wire, o) + if err == ErrInternalBadWireType { + // Map the error to something more descriptive. + // Do the formatting here to save generated code space. + err = fmt.Errorf("bad wiretype for oneof field in %T", m) + } + if ok { + continue + } + } + err = o.skipAndSave(st, tag, wire, base, prop.unrecField) + continue + } + p := prop.Prop[fieldnum] + + if p.dec == nil { + fmt.Fprintf(os.Stderr, "proto: no protobuf decoder for %s.%s\n", st, st.Field(fieldnum).Name) + continue + } + dec := p.dec + if wire != WireStartGroup && wire != p.WireType { + if wire == WireBytes && p.packedDec != nil { + // a packable field + dec = p.packedDec + } else { + err = fmt.Errorf("proto: bad wiretype for field %s.%s: got wiretype %d, want %d", st, st.Field(fieldnum).Name, wire, p.WireType) + continue + } + } + decErr := dec(o, p, base) + if decErr != nil && !state.shouldContinue(decErr, p) { + err = decErr + } + if err == nil && p.Required { + // Successfully decoded a required field. + if tag <= 64 { + // use bitmap for fields 1-64 to catch field reuse. + var mask uint64 = 1 << uint64(tag-1) + if reqFields&mask == 0 { + // new required field + reqFields |= mask + required-- + } + } else { + // This is imprecise. It can be fooled by a required field + // with a tag > 64 that is encoded twice; that's very rare. + // A fully correct implementation would require allocating + // a data structure, which we would like to avoid. + required-- + } + } + } + if err == nil { + if is_group { + return io.ErrUnexpectedEOF + } + if state.err != nil { + return state.err + } + if required > 0 { + // Not enough information to determine the exact field. If we use extra + // CPU, we could determine the field only if the missing required field + // has a tag <= 64 and we check reqFields. + return &RequiredNotSetError{"{Unknown}"} + } + } + return err +} + +// Individual type decoders +// For each, +// u is the decoded value, +// v is a pointer to the field (pointer) in the struct + +// Sizes of the pools to allocate inside the Buffer. +// The goal is modest amortization and allocation +// on at least 16-byte boundaries. +const ( + boolPoolSize = 16 + uint32PoolSize = 8 + uint64PoolSize = 4 +) + +// Decode a bool. +func (o *Buffer) dec_bool(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + if len(o.bools) == 0 { + o.bools = make([]bool, boolPoolSize) + } + o.bools[0] = u != 0 + *structPointer_Bool(base, p.field) = &o.bools[0] + o.bools = o.bools[1:] + return nil +} + +func (o *Buffer) dec_proto3_bool(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + *structPointer_BoolVal(base, p.field) = u != 0 + return nil +} + +// Decode an int32. +func (o *Buffer) dec_int32(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + word32_Set(structPointer_Word32(base, p.field), o, uint32(u)) + return nil +} + +func (o *Buffer) dec_proto3_int32(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + word32Val_Set(structPointer_Word32Val(base, p.field), uint32(u)) + return nil +} + +// Decode an int64. +func (o *Buffer) dec_int64(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + word64_Set(structPointer_Word64(base, p.field), o, u) + return nil +} + +func (o *Buffer) dec_proto3_int64(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + word64Val_Set(structPointer_Word64Val(base, p.field), o, u) + return nil +} + +// Decode a string. +func (o *Buffer) dec_string(p *Properties, base structPointer) error { + s, err := o.DecodeStringBytes() + if err != nil { + return err + } + *structPointer_String(base, p.field) = &s + return nil +} + +func (o *Buffer) dec_proto3_string(p *Properties, base structPointer) error { + s, err := o.DecodeStringBytes() + if err != nil { + return err + } + *structPointer_StringVal(base, p.field) = s + return nil +} + +// Decode a slice of bytes ([]byte). +func (o *Buffer) dec_slice_byte(p *Properties, base structPointer) error { + b, err := o.DecodeRawBytes(true) + if err != nil { + return err + } + *structPointer_Bytes(base, p.field) = b + return nil +} + +// Decode a slice of bools ([]bool). +func (o *Buffer) dec_slice_bool(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + v := structPointer_BoolSlice(base, p.field) + *v = append(*v, u != 0) + return nil +} + +// Decode a slice of bools ([]bool) in packed format. +func (o *Buffer) dec_slice_packed_bool(p *Properties, base structPointer) error { + v := structPointer_BoolSlice(base, p.field) + + nn, err := o.DecodeVarint() + if err != nil { + return err + } + nb := int(nn) // number of bytes of encoded bools + fin := o.index + nb + if fin < o.index { + return errOverflow + } + + y := *v + for o.index < fin { + u, err := p.valDec(o) + if err != nil { + return err + } + y = append(y, u != 0) + } + + *v = y + return nil +} + +// Decode a slice of int32s ([]int32). +func (o *Buffer) dec_slice_int32(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + structPointer_Word32Slice(base, p.field).Append(uint32(u)) + return nil +} + +// Decode a slice of int32s ([]int32) in packed format. +func (o *Buffer) dec_slice_packed_int32(p *Properties, base structPointer) error { + v := structPointer_Word32Slice(base, p.field) + + nn, err := o.DecodeVarint() + if err != nil { + return err + } + nb := int(nn) // number of bytes of encoded int32s + + fin := o.index + nb + if fin < o.index { + return errOverflow + } + for o.index < fin { + u, err := p.valDec(o) + if err != nil { + return err + } + v.Append(uint32(u)) + } + return nil +} + +// Decode a slice of int64s ([]int64). +func (o *Buffer) dec_slice_int64(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + + structPointer_Word64Slice(base, p.field).Append(u) + return nil +} + +// Decode a slice of int64s ([]int64) in packed format. +func (o *Buffer) dec_slice_packed_int64(p *Properties, base structPointer) error { + v := structPointer_Word64Slice(base, p.field) + + nn, err := o.DecodeVarint() + if err != nil { + return err + } + nb := int(nn) // number of bytes of encoded int64s + + fin := o.index + nb + if fin < o.index { + return errOverflow + } + for o.index < fin { + u, err := p.valDec(o) + if err != nil { + return err + } + v.Append(u) + } + return nil +} + +// Decode a slice of strings ([]string). +func (o *Buffer) dec_slice_string(p *Properties, base structPointer) error { + s, err := o.DecodeStringBytes() + if err != nil { + return err + } + v := structPointer_StringSlice(base, p.field) + *v = append(*v, s) + return nil +} + +// Decode a slice of slice of bytes ([][]byte). +func (o *Buffer) dec_slice_slice_byte(p *Properties, base structPointer) error { + b, err := o.DecodeRawBytes(true) + if err != nil { + return err + } + v := structPointer_BytesSlice(base, p.field) + *v = append(*v, b) + return nil +} + +// Decode a map field. +func (o *Buffer) dec_new_map(p *Properties, base structPointer) error { + raw, err := o.DecodeRawBytes(false) + if err != nil { + return err + } + oi := o.index // index at the end of this map entry + o.index -= len(raw) // move buffer back to start of map entry + + mptr := structPointer_NewAt(base, p.field, p.mtype) // *map[K]V + if mptr.Elem().IsNil() { + mptr.Elem().Set(reflect.MakeMap(mptr.Type().Elem())) + } + v := mptr.Elem() // map[K]V + + // Prepare addressable doubly-indirect placeholders for the key and value types. + // See enc_new_map for why. + keyptr := reflect.New(reflect.PtrTo(p.mtype.Key())).Elem() // addressable *K + keybase := toStructPointer(keyptr.Addr()) // **K + + var valbase structPointer + var valptr reflect.Value + switch p.mtype.Elem().Kind() { + case reflect.Slice: + // []byte + var dummy []byte + valptr = reflect.ValueOf(&dummy) // *[]byte + valbase = toStructPointer(valptr) // *[]byte + case reflect.Ptr: + // message; valptr is **Msg; need to allocate the intermediate pointer + valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V + valptr.Set(reflect.New(valptr.Type().Elem())) + valbase = toStructPointer(valptr) + default: + // everything else + valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V + valbase = toStructPointer(valptr.Addr()) // **V + } + + // Decode. + // This parses a restricted wire format, namely the encoding of a message + // with two fields. See enc_new_map for the format. + for o.index < oi { + // tagcode for key and value properties are always a single byte + // because they have tags 1 and 2. + tagcode := o.buf[o.index] + o.index++ + switch tagcode { + case p.mkeyprop.tagcode[0]: + if err := p.mkeyprop.dec(o, p.mkeyprop, keybase); err != nil { + return err + } + case p.mvalprop.tagcode[0]: + if err := p.mvalprop.dec(o, p.mvalprop, valbase); err != nil { + return err + } + default: + // TODO: Should we silently skip this instead? + return fmt.Errorf("proto: bad map data tag %d", raw[0]) + } + } + keyelem, valelem := keyptr.Elem(), valptr.Elem() + if !keyelem.IsValid() || !valelem.IsValid() { + // We did not decode the key or the value in the map entry. + // Either way, it's an invalid map entry. + return fmt.Errorf("proto: bad map data: missing key/val") + } + + v.SetMapIndex(keyelem, valelem) + return nil +} + +// Decode a group. +func (o *Buffer) dec_struct_group(p *Properties, base structPointer) error { + bas := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(bas) { + // allocate new nested message + bas = toStructPointer(reflect.New(p.stype)) + structPointer_SetStructPointer(base, p.field, bas) + } + return o.unmarshalType(p.stype, p.sprop, true, bas) +} + +// Decode an embedded message. +func (o *Buffer) dec_struct_message(p *Properties, base structPointer) (err error) { + raw, e := o.DecodeRawBytes(false) + if e != nil { + return e + } + + bas := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(bas) { + // allocate new nested message + bas = toStructPointer(reflect.New(p.stype)) + structPointer_SetStructPointer(base, p.field, bas) + } + + // If the object can unmarshal itself, let it. + if p.isUnmarshaler { + iv := structPointer_Interface(bas, p.stype) + return iv.(Unmarshaler).Unmarshal(raw) + } + + obuf := o.buf + oi := o.index + o.buf = raw + o.index = 0 + + err = o.unmarshalType(p.stype, p.sprop, false, bas) + o.buf = obuf + o.index = oi + + return err +} + +// Decode a slice of embedded messages. +func (o *Buffer) dec_slice_struct_message(p *Properties, base structPointer) error { + return o.dec_slice_struct(p, false, base) +} + +// Decode a slice of embedded groups. +func (o *Buffer) dec_slice_struct_group(p *Properties, base structPointer) error { + return o.dec_slice_struct(p, true, base) +} + +// Decode a slice of structs ([]*struct). +func (o *Buffer) dec_slice_struct(p *Properties, is_group bool, base structPointer) error { + v := reflect.New(p.stype) + bas := toStructPointer(v) + structPointer_StructPointerSlice(base, p.field).Append(bas) + + if is_group { + err := o.unmarshalType(p.stype, p.sprop, is_group, bas) + return err + } + + raw, err := o.DecodeRawBytes(false) + if err != nil { + return err + } + + // If the object can unmarshal itself, let it. + if p.isUnmarshaler { + iv := v.Interface() + return iv.(Unmarshaler).Unmarshal(raw) + } + + obuf := o.buf + oi := o.index + o.buf = raw + o.index = 0 + + err = o.unmarshalType(p.stype, p.sprop, is_group, bas) + + o.buf = obuf + o.index = oi + + return err +} diff --git a/vendor/github.com/golang/protobuf/proto/encode.go b/vendor/github.com/golang/protobuf/proto/encode.go new file mode 100644 index 0000000000..231b07401a --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/encode.go @@ -0,0 +1,1325 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +/* + * Routines for encoding data into the wire format for protocol buffers. + */ + +import ( + "errors" + "fmt" + "reflect" + "sort" +) + +// RequiredNotSetError is the error returned if Marshal is called with +// a protocol buffer struct whose required fields have not +// all been initialized. It is also the error returned if Unmarshal is +// called with an encoded protocol buffer that does not include all the +// required fields. +// +// When printed, RequiredNotSetError reports the first unset required field in a +// message. If the field cannot be precisely determined, it is reported as +// "{Unknown}". +type RequiredNotSetError struct { + field string +} + +func (e *RequiredNotSetError) Error() string { + return fmt.Sprintf("proto: required field %q not set", e.field) +} + +var ( + // errRepeatedHasNil is the error returned if Marshal is called with + // a struct with a repeated field containing a nil element. + errRepeatedHasNil = errors.New("proto: repeated field has nil element") + + // ErrNil is the error returned if Marshal is called with nil. + ErrNil = errors.New("proto: Marshal called with nil") +) + +// The fundamental encoders that put bytes on the wire. +// Those that take integer types all accept uint64 and are +// therefore of type valueEncoder. + +const maxVarintBytes = 10 // maximum length of a varint + +// EncodeVarint returns the varint encoding of x. +// This is the format for the +// int32, int64, uint32, uint64, bool, and enum +// protocol buffer types. +// Not used by the package itself, but helpful to clients +// wishing to use the same encoding. +func EncodeVarint(x uint64) []byte { + var buf [maxVarintBytes]byte + var n int + for n = 0; x > 127; n++ { + buf[n] = 0x80 | uint8(x&0x7F) + x >>= 7 + } + buf[n] = uint8(x) + n++ + return buf[0:n] +} + +// EncodeVarint writes a varint-encoded integer to the Buffer. +// This is the format for the +// int32, int64, uint32, uint64, bool, and enum +// protocol buffer types. +func (p *Buffer) EncodeVarint(x uint64) error { + for x >= 1<<7 { + p.buf = append(p.buf, uint8(x&0x7f|0x80)) + x >>= 7 + } + p.buf = append(p.buf, uint8(x)) + return nil +} + +// SizeVarint returns the varint encoding size of an integer. +func SizeVarint(x uint64) int { + return sizeVarint(x) +} + +func sizeVarint(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} + +// EncodeFixed64 writes a 64-bit integer to the Buffer. +// This is the format for the +// fixed64, sfixed64, and double protocol buffer types. +func (p *Buffer) EncodeFixed64(x uint64) error { + p.buf = append(p.buf, + uint8(x), + uint8(x>>8), + uint8(x>>16), + uint8(x>>24), + uint8(x>>32), + uint8(x>>40), + uint8(x>>48), + uint8(x>>56)) + return nil +} + +func sizeFixed64(x uint64) int { + return 8 +} + +// EncodeFixed32 writes a 32-bit integer to the Buffer. +// This is the format for the +// fixed32, sfixed32, and float protocol buffer types. +func (p *Buffer) EncodeFixed32(x uint64) error { + p.buf = append(p.buf, + uint8(x), + uint8(x>>8), + uint8(x>>16), + uint8(x>>24)) + return nil +} + +func sizeFixed32(x uint64) int { + return 4 +} + +// EncodeZigzag64 writes a zigzag-encoded 64-bit integer +// to the Buffer. +// This is the format used for the sint64 protocol buffer type. +func (p *Buffer) EncodeZigzag64(x uint64) error { + // use signed number to get arithmetic right shift. + return p.EncodeVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} + +func sizeZigzag64(x uint64) int { + return sizeVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} + +// EncodeZigzag32 writes a zigzag-encoded 32-bit integer +// to the Buffer. +// This is the format used for the sint32 protocol buffer type. +func (p *Buffer) EncodeZigzag32(x uint64) error { + // use signed number to get arithmetic right shift. + return p.EncodeVarint(uint64((uint32(x) << 1) ^ uint32((int32(x) >> 31)))) +} + +func sizeZigzag32(x uint64) int { + return sizeVarint(uint64((uint32(x) << 1) ^ uint32((int32(x) >> 31)))) +} + +// EncodeRawBytes writes a count-delimited byte buffer to the Buffer. +// This is the format used for the bytes protocol buffer +// type and for embedded messages. +func (p *Buffer) EncodeRawBytes(b []byte) error { + p.EncodeVarint(uint64(len(b))) + p.buf = append(p.buf, b...) + return nil +} + +func sizeRawBytes(b []byte) int { + return sizeVarint(uint64(len(b))) + + len(b) +} + +// EncodeStringBytes writes an encoded string to the Buffer. +// This is the format used for the proto2 string type. +func (p *Buffer) EncodeStringBytes(s string) error { + p.EncodeVarint(uint64(len(s))) + p.buf = append(p.buf, s...) + return nil +} + +func sizeStringBytes(s string) int { + return sizeVarint(uint64(len(s))) + + len(s) +} + +// Marshaler is the interface representing objects that can marshal themselves. +type Marshaler interface { + Marshal() ([]byte, error) +} + +// Marshal takes the protocol buffer +// and encodes it into the wire format, returning the data. +func Marshal(pb Message) ([]byte, error) { + // Can the object marshal itself? + if m, ok := pb.(Marshaler); ok { + return m.Marshal() + } + p := NewBuffer(nil) + err := p.Marshal(pb) + var state errorState + if err != nil && !state.shouldContinue(err, nil) { + return nil, err + } + if p.buf == nil && err == nil { + // Return a non-nil slice on success. + return []byte{}, nil + } + return p.buf, err +} + +// EncodeMessage writes the protocol buffer to the Buffer, +// prefixed by a varint-encoded length. +func (p *Buffer) EncodeMessage(pb Message) error { + t, base, err := getbase(pb) + if structPointer_IsNil(base) { + return ErrNil + } + if err == nil { + var state errorState + err = p.enc_len_struct(GetProperties(t.Elem()), base, &state) + } + return err +} + +// Marshal takes the protocol buffer +// and encodes it into the wire format, writing the result to the +// Buffer. +func (p *Buffer) Marshal(pb Message) error { + // Can the object marshal itself? + if m, ok := pb.(Marshaler); ok { + data, err := m.Marshal() + if err != nil { + return err + } + p.buf = append(p.buf, data...) + return nil + } + + t, base, err := getbase(pb) + if structPointer_IsNil(base) { + return ErrNil + } + if err == nil { + err = p.enc_struct(GetProperties(t.Elem()), base) + } + + if collectStats { + stats.Encode++ + } + + return err +} + +// Size returns the encoded size of a protocol buffer. +func Size(pb Message) (n int) { + // Can the object marshal itself? If so, Size is slow. + // TODO: add Size to Marshaler, or add a Sizer interface. + if m, ok := pb.(Marshaler); ok { + b, _ := m.Marshal() + return len(b) + } + + t, base, err := getbase(pb) + if structPointer_IsNil(base) { + return 0 + } + if err == nil { + n = size_struct(GetProperties(t.Elem()), base) + } + + if collectStats { + stats.Size++ + } + + return +} + +// Individual type encoders. + +// Encode a bool. +func (o *Buffer) enc_bool(p *Properties, base structPointer) error { + v := *structPointer_Bool(base, p.field) + if v == nil { + return ErrNil + } + x := 0 + if *v { + x = 1 + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func (o *Buffer) enc_proto3_bool(p *Properties, base structPointer) error { + v := *structPointer_BoolVal(base, p.field) + if !v { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, 1) + return nil +} + +func size_bool(p *Properties, base structPointer) int { + v := *structPointer_Bool(base, p.field) + if v == nil { + return 0 + } + return len(p.tagcode) + 1 // each bool takes exactly one byte +} + +func size_proto3_bool(p *Properties, base structPointer) int { + v := *structPointer_BoolVal(base, p.field) + if !v && !p.oneof { + return 0 + } + return len(p.tagcode) + 1 // each bool takes exactly one byte +} + +// Encode an int32. +func (o *Buffer) enc_int32(p *Properties, base structPointer) error { + v := structPointer_Word32(base, p.field) + if word32_IsNil(v) { + return ErrNil + } + x := int32(word32_Get(v)) // permit sign extension to use full 64-bit range + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func (o *Buffer) enc_proto3_int32(p *Properties, base structPointer) error { + v := structPointer_Word32Val(base, p.field) + x := int32(word32Val_Get(v)) // permit sign extension to use full 64-bit range + if x == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func size_int32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32(base, p.field) + if word32_IsNil(v) { + return 0 + } + x := int32(word32_Get(v)) // permit sign extension to use full 64-bit range + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +func size_proto3_int32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32Val(base, p.field) + x := int32(word32Val_Get(v)) // permit sign extension to use full 64-bit range + if x == 0 && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +// Encode a uint32. +// Exactly the same as int32, except for no sign extension. +func (o *Buffer) enc_uint32(p *Properties, base structPointer) error { + v := structPointer_Word32(base, p.field) + if word32_IsNil(v) { + return ErrNil + } + x := word32_Get(v) + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func (o *Buffer) enc_proto3_uint32(p *Properties, base structPointer) error { + v := structPointer_Word32Val(base, p.field) + x := word32Val_Get(v) + if x == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func size_uint32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32(base, p.field) + if word32_IsNil(v) { + return 0 + } + x := word32_Get(v) + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +func size_proto3_uint32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32Val(base, p.field) + x := word32Val_Get(v) + if x == 0 && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +// Encode an int64. +func (o *Buffer) enc_int64(p *Properties, base structPointer) error { + v := structPointer_Word64(base, p.field) + if word64_IsNil(v) { + return ErrNil + } + x := word64_Get(v) + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, x) + return nil +} + +func (o *Buffer) enc_proto3_int64(p *Properties, base structPointer) error { + v := structPointer_Word64Val(base, p.field) + x := word64Val_Get(v) + if x == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, x) + return nil +} + +func size_int64(p *Properties, base structPointer) (n int) { + v := structPointer_Word64(base, p.field) + if word64_IsNil(v) { + return 0 + } + x := word64_Get(v) + n += len(p.tagcode) + n += p.valSize(x) + return +} + +func size_proto3_int64(p *Properties, base structPointer) (n int) { + v := structPointer_Word64Val(base, p.field) + x := word64Val_Get(v) + if x == 0 && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += p.valSize(x) + return +} + +// Encode a string. +func (o *Buffer) enc_string(p *Properties, base structPointer) error { + v := *structPointer_String(base, p.field) + if v == nil { + return ErrNil + } + x := *v + o.buf = append(o.buf, p.tagcode...) + o.EncodeStringBytes(x) + return nil +} + +func (o *Buffer) enc_proto3_string(p *Properties, base structPointer) error { + v := *structPointer_StringVal(base, p.field) + if v == "" { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeStringBytes(v) + return nil +} + +func size_string(p *Properties, base structPointer) (n int) { + v := *structPointer_String(base, p.field) + if v == nil { + return 0 + } + x := *v + n += len(p.tagcode) + n += sizeStringBytes(x) + return +} + +func size_proto3_string(p *Properties, base structPointer) (n int) { + v := *structPointer_StringVal(base, p.field) + if v == "" && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += sizeStringBytes(v) + return +} + +// All protocol buffer fields are nillable, but be careful. +func isNil(v reflect.Value) bool { + switch v.Kind() { + case reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice: + return v.IsNil() + } + return false +} + +// Encode a message struct. +func (o *Buffer) enc_struct_message(p *Properties, base structPointer) error { + var state errorState + structp := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(structp) { + return ErrNil + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, err := m.Marshal() + if err != nil && !state.shouldContinue(err, nil) { + return err + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(data) + return state.err + } + + o.buf = append(o.buf, p.tagcode...) + return o.enc_len_struct(p.sprop, structp, &state) +} + +func size_struct_message(p *Properties, base structPointer) int { + structp := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(structp) { + return 0 + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, _ := m.Marshal() + n0 := len(p.tagcode) + n1 := sizeRawBytes(data) + return n0 + n1 + } + + n0 := len(p.tagcode) + n1 := size_struct(p.sprop, structp) + n2 := sizeVarint(uint64(n1)) // size of encoded length + return n0 + n1 + n2 +} + +// Encode a group struct. +func (o *Buffer) enc_struct_group(p *Properties, base structPointer) error { + var state errorState + b := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(b) { + return ErrNil + } + + o.EncodeVarint(uint64((p.Tag << 3) | WireStartGroup)) + err := o.enc_struct(p.sprop, b) + if err != nil && !state.shouldContinue(err, nil) { + return err + } + o.EncodeVarint(uint64((p.Tag << 3) | WireEndGroup)) + return state.err +} + +func size_struct_group(p *Properties, base structPointer) (n int) { + b := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(b) { + return 0 + } + + n += sizeVarint(uint64((p.Tag << 3) | WireStartGroup)) + n += size_struct(p.sprop, b) + n += sizeVarint(uint64((p.Tag << 3) | WireEndGroup)) + return +} + +// Encode a slice of bools ([]bool). +func (o *Buffer) enc_slice_bool(p *Properties, base structPointer) error { + s := *structPointer_BoolSlice(base, p.field) + l := len(s) + if l == 0 { + return ErrNil + } + for _, x := range s { + o.buf = append(o.buf, p.tagcode...) + v := uint64(0) + if x { + v = 1 + } + p.valEnc(o, v) + } + return nil +} + +func size_slice_bool(p *Properties, base structPointer) int { + s := *structPointer_BoolSlice(base, p.field) + l := len(s) + if l == 0 { + return 0 + } + return l * (len(p.tagcode) + 1) // each bool takes exactly one byte +} + +// Encode a slice of bools ([]bool) in packed format. +func (o *Buffer) enc_slice_packed_bool(p *Properties, base structPointer) error { + s := *structPointer_BoolSlice(base, p.field) + l := len(s) + if l == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeVarint(uint64(l)) // each bool takes exactly one byte + for _, x := range s { + v := uint64(0) + if x { + v = 1 + } + p.valEnc(o, v) + } + return nil +} + +func size_slice_packed_bool(p *Properties, base structPointer) (n int) { + s := *structPointer_BoolSlice(base, p.field) + l := len(s) + if l == 0 { + return 0 + } + n += len(p.tagcode) + n += sizeVarint(uint64(l)) + n += l // each bool takes exactly one byte + return +} + +// Encode a slice of bytes ([]byte). +func (o *Buffer) enc_slice_byte(p *Properties, base structPointer) error { + s := *structPointer_Bytes(base, p.field) + if s == nil { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(s) + return nil +} + +func (o *Buffer) enc_proto3_slice_byte(p *Properties, base structPointer) error { + s := *structPointer_Bytes(base, p.field) + if len(s) == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(s) + return nil +} + +func size_slice_byte(p *Properties, base structPointer) (n int) { + s := *structPointer_Bytes(base, p.field) + if s == nil && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += sizeRawBytes(s) + return +} + +func size_proto3_slice_byte(p *Properties, base structPointer) (n int) { + s := *structPointer_Bytes(base, p.field) + if len(s) == 0 && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += sizeRawBytes(s) + return +} + +// Encode a slice of int32s ([]int32). +func (o *Buffer) enc_slice_int32(p *Properties, base structPointer) error { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + x := int32(s.Index(i)) // permit sign extension to use full 64-bit range + p.valEnc(o, uint64(x)) + } + return nil +} + +func size_slice_int32(p *Properties, base structPointer) (n int) { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + for i := 0; i < l; i++ { + n += len(p.tagcode) + x := int32(s.Index(i)) // permit sign extension to use full 64-bit range + n += p.valSize(uint64(x)) + } + return +} + +// Encode a slice of int32s ([]int32) in packed format. +func (o *Buffer) enc_slice_packed_int32(p *Properties, base structPointer) error { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + // TODO: Reuse a Buffer. + buf := NewBuffer(nil) + for i := 0; i < l; i++ { + x := int32(s.Index(i)) // permit sign extension to use full 64-bit range + p.valEnc(buf, uint64(x)) + } + + o.buf = append(o.buf, p.tagcode...) + o.EncodeVarint(uint64(len(buf.buf))) + o.buf = append(o.buf, buf.buf...) + return nil +} + +func size_slice_packed_int32(p *Properties, base structPointer) (n int) { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + var bufSize int + for i := 0; i < l; i++ { + x := int32(s.Index(i)) // permit sign extension to use full 64-bit range + bufSize += p.valSize(uint64(x)) + } + + n += len(p.tagcode) + n += sizeVarint(uint64(bufSize)) + n += bufSize + return +} + +// Encode a slice of uint32s ([]uint32). +// Exactly the same as int32, except for no sign extension. +func (o *Buffer) enc_slice_uint32(p *Properties, base structPointer) error { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + x := s.Index(i) + p.valEnc(o, uint64(x)) + } + return nil +} + +func size_slice_uint32(p *Properties, base structPointer) (n int) { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + for i := 0; i < l; i++ { + n += len(p.tagcode) + x := s.Index(i) + n += p.valSize(uint64(x)) + } + return +} + +// Encode a slice of uint32s ([]uint32) in packed format. +// Exactly the same as int32, except for no sign extension. +func (o *Buffer) enc_slice_packed_uint32(p *Properties, base structPointer) error { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + // TODO: Reuse a Buffer. + buf := NewBuffer(nil) + for i := 0; i < l; i++ { + p.valEnc(buf, uint64(s.Index(i))) + } + + o.buf = append(o.buf, p.tagcode...) + o.EncodeVarint(uint64(len(buf.buf))) + o.buf = append(o.buf, buf.buf...) + return nil +} + +func size_slice_packed_uint32(p *Properties, base structPointer) (n int) { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + var bufSize int + for i := 0; i < l; i++ { + bufSize += p.valSize(uint64(s.Index(i))) + } + + n += len(p.tagcode) + n += sizeVarint(uint64(bufSize)) + n += bufSize + return +} + +// Encode a slice of int64s ([]int64). +func (o *Buffer) enc_slice_int64(p *Properties, base structPointer) error { + s := structPointer_Word64Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, s.Index(i)) + } + return nil +} + +func size_slice_int64(p *Properties, base structPointer) (n int) { + s := structPointer_Word64Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + for i := 0; i < l; i++ { + n += len(p.tagcode) + n += p.valSize(s.Index(i)) + } + return +} + +// Encode a slice of int64s ([]int64) in packed format. +func (o *Buffer) enc_slice_packed_int64(p *Properties, base structPointer) error { + s := structPointer_Word64Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + // TODO: Reuse a Buffer. + buf := NewBuffer(nil) + for i := 0; i < l; i++ { + p.valEnc(buf, s.Index(i)) + } + + o.buf = append(o.buf, p.tagcode...) + o.EncodeVarint(uint64(len(buf.buf))) + o.buf = append(o.buf, buf.buf...) + return nil +} + +func size_slice_packed_int64(p *Properties, base structPointer) (n int) { + s := structPointer_Word64Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + var bufSize int + for i := 0; i < l; i++ { + bufSize += p.valSize(s.Index(i)) + } + + n += len(p.tagcode) + n += sizeVarint(uint64(bufSize)) + n += bufSize + return +} + +// Encode a slice of slice of bytes ([][]byte). +func (o *Buffer) enc_slice_slice_byte(p *Properties, base structPointer) error { + ss := *structPointer_BytesSlice(base, p.field) + l := len(ss) + if l == 0 { + return ErrNil + } + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(ss[i]) + } + return nil +} + +func size_slice_slice_byte(p *Properties, base structPointer) (n int) { + ss := *structPointer_BytesSlice(base, p.field) + l := len(ss) + if l == 0 { + return 0 + } + n += l * len(p.tagcode) + for i := 0; i < l; i++ { + n += sizeRawBytes(ss[i]) + } + return +} + +// Encode a slice of strings ([]string). +func (o *Buffer) enc_slice_string(p *Properties, base structPointer) error { + ss := *structPointer_StringSlice(base, p.field) + l := len(ss) + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + o.EncodeStringBytes(ss[i]) + } + return nil +} + +func size_slice_string(p *Properties, base structPointer) (n int) { + ss := *structPointer_StringSlice(base, p.field) + l := len(ss) + n += l * len(p.tagcode) + for i := 0; i < l; i++ { + n += sizeStringBytes(ss[i]) + } + return +} + +// Encode a slice of message structs ([]*struct). +func (o *Buffer) enc_slice_struct_message(p *Properties, base structPointer) error { + var state errorState + s := structPointer_StructPointerSlice(base, p.field) + l := s.Len() + + for i := 0; i < l; i++ { + structp := s.Index(i) + if structPointer_IsNil(structp) { + return errRepeatedHasNil + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, err := m.Marshal() + if err != nil && !state.shouldContinue(err, nil) { + return err + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(data) + continue + } + + o.buf = append(o.buf, p.tagcode...) + err := o.enc_len_struct(p.sprop, structp, &state) + if err != nil && !state.shouldContinue(err, nil) { + if err == ErrNil { + return errRepeatedHasNil + } + return err + } + } + return state.err +} + +func size_slice_struct_message(p *Properties, base structPointer) (n int) { + s := structPointer_StructPointerSlice(base, p.field) + l := s.Len() + n += l * len(p.tagcode) + for i := 0; i < l; i++ { + structp := s.Index(i) + if structPointer_IsNil(structp) { + return // return the size up to this point + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, _ := m.Marshal() + n += len(p.tagcode) + n += sizeRawBytes(data) + continue + } + + n0 := size_struct(p.sprop, structp) + n1 := sizeVarint(uint64(n0)) // size of encoded length + n += n0 + n1 + } + return +} + +// Encode a slice of group structs ([]*struct). +func (o *Buffer) enc_slice_struct_group(p *Properties, base structPointer) error { + var state errorState + s := structPointer_StructPointerSlice(base, p.field) + l := s.Len() + + for i := 0; i < l; i++ { + b := s.Index(i) + if structPointer_IsNil(b) { + return errRepeatedHasNil + } + + o.EncodeVarint(uint64((p.Tag << 3) | WireStartGroup)) + + err := o.enc_struct(p.sprop, b) + + if err != nil && !state.shouldContinue(err, nil) { + if err == ErrNil { + return errRepeatedHasNil + } + return err + } + + o.EncodeVarint(uint64((p.Tag << 3) | WireEndGroup)) + } + return state.err +} + +func size_slice_struct_group(p *Properties, base structPointer) (n int) { + s := structPointer_StructPointerSlice(base, p.field) + l := s.Len() + + n += l * sizeVarint(uint64((p.Tag<<3)|WireStartGroup)) + n += l * sizeVarint(uint64((p.Tag<<3)|WireEndGroup)) + for i := 0; i < l; i++ { + b := s.Index(i) + if structPointer_IsNil(b) { + return // return size up to this point + } + + n += size_struct(p.sprop, b) + } + return +} + +// Encode an extension map. +func (o *Buffer) enc_map(p *Properties, base structPointer) error { + v := *structPointer_ExtMap(base, p.field) + if err := encodeExtensionMap(v); err != nil { + return err + } + // Fast-path for common cases: zero or one extensions. + if len(v) <= 1 { + for _, e := range v { + o.buf = append(o.buf, e.enc...) + } + return nil + } + + // Sort keys to provide a deterministic encoding. + keys := make([]int, 0, len(v)) + for k := range v { + keys = append(keys, int(k)) + } + sort.Ints(keys) + + for _, k := range keys { + o.buf = append(o.buf, v[int32(k)].enc...) + } + return nil +} + +func size_map(p *Properties, base structPointer) int { + v := *structPointer_ExtMap(base, p.field) + return sizeExtensionMap(v) +} + +// Encode a map field. +func (o *Buffer) enc_new_map(p *Properties, base structPointer) error { + var state errorState // XXX: or do we need to plumb this through? + + /* + A map defined as + map map_field = N; + is encoded in the same way as + message MapFieldEntry { + key_type key = 1; + value_type value = 2; + } + repeated MapFieldEntry map_field = N; + */ + + v := structPointer_NewAt(base, p.field, p.mtype).Elem() // map[K]V + if v.Len() == 0 { + return nil + } + + keycopy, valcopy, keybase, valbase := mapEncodeScratch(p.mtype) + + enc := func() error { + if err := p.mkeyprop.enc(o, p.mkeyprop, keybase); err != nil { + return err + } + if err := p.mvalprop.enc(o, p.mvalprop, valbase); err != nil { + return err + } + return nil + } + + // Don't sort map keys. It is not required by the spec, and C++ doesn't do it. + for _, key := range v.MapKeys() { + val := v.MapIndex(key) + + // The only illegal map entry values are nil message pointers. + if val.Kind() == reflect.Ptr && val.IsNil() { + return errors.New("proto: map has nil element") + } + + keycopy.Set(key) + valcopy.Set(val) + + o.buf = append(o.buf, p.tagcode...) + if err := o.enc_len_thing(enc, &state); err != nil { + return err + } + } + return nil +} + +func size_new_map(p *Properties, base structPointer) int { + v := structPointer_NewAt(base, p.field, p.mtype).Elem() // map[K]V + + keycopy, valcopy, keybase, valbase := mapEncodeScratch(p.mtype) + + n := 0 + for _, key := range v.MapKeys() { + val := v.MapIndex(key) + keycopy.Set(key) + valcopy.Set(val) + + // Tag codes for key and val are the responsibility of the sub-sizer. + keysize := p.mkeyprop.size(p.mkeyprop, keybase) + valsize := p.mvalprop.size(p.mvalprop, valbase) + entry := keysize + valsize + // Add on tag code and length of map entry itself. + n += len(p.tagcode) + sizeVarint(uint64(entry)) + entry + } + return n +} + +// mapEncodeScratch returns a new reflect.Value matching the map's value type, +// and a structPointer suitable for passing to an encoder or sizer. +func mapEncodeScratch(mapType reflect.Type) (keycopy, valcopy reflect.Value, keybase, valbase structPointer) { + // Prepare addressable doubly-indirect placeholders for the key and value types. + // This is needed because the element-type encoders expect **T, but the map iteration produces T. + + keycopy = reflect.New(mapType.Key()).Elem() // addressable K + keyptr := reflect.New(reflect.PtrTo(keycopy.Type())).Elem() // addressable *K + keyptr.Set(keycopy.Addr()) // + keybase = toStructPointer(keyptr.Addr()) // **K + + // Value types are more varied and require special handling. + switch mapType.Elem().Kind() { + case reflect.Slice: + // []byte + var dummy []byte + valcopy = reflect.ValueOf(&dummy).Elem() // addressable []byte + valbase = toStructPointer(valcopy.Addr()) + case reflect.Ptr: + // message; the generated field type is map[K]*Msg (so V is *Msg), + // so we only need one level of indirection. + valcopy = reflect.New(mapType.Elem()).Elem() // addressable V + valbase = toStructPointer(valcopy.Addr()) + default: + // everything else + valcopy = reflect.New(mapType.Elem()).Elem() // addressable V + valptr := reflect.New(reflect.PtrTo(valcopy.Type())).Elem() // addressable *V + valptr.Set(valcopy.Addr()) // + valbase = toStructPointer(valptr.Addr()) // **V + } + return +} + +// Encode a struct. +func (o *Buffer) enc_struct(prop *StructProperties, base structPointer) error { + var state errorState + // Encode fields in tag order so that decoders may use optimizations + // that depend on the ordering. + // https://developers.google.com/protocol-buffers/docs/encoding#order + for _, i := range prop.order { + p := prop.Prop[i] + if p.enc != nil { + err := p.enc(o, p, base) + if err != nil { + if err == ErrNil { + if p.Required && state.err == nil { + state.err = &RequiredNotSetError{p.Name} + } + } else if err == errRepeatedHasNil { + // Give more context to nil values in repeated fields. + return errors.New("repeated field " + p.OrigName + " has nil element") + } else if !state.shouldContinue(err, p) { + return err + } + } + } + } + + // Do oneof fields. + if prop.oneofMarshaler != nil { + m := structPointer_Interface(base, prop.stype).(Message) + if err := prop.oneofMarshaler(m, o); err != nil { + return err + } + } + + // Add unrecognized fields at the end. + if prop.unrecField.IsValid() { + v := *structPointer_Bytes(base, prop.unrecField) + if len(v) > 0 { + o.buf = append(o.buf, v...) + } + } + + return state.err +} + +func size_struct(prop *StructProperties, base structPointer) (n int) { + for _, i := range prop.order { + p := prop.Prop[i] + if p.size != nil { + n += p.size(p, base) + } + } + + // Add unrecognized fields at the end. + if prop.unrecField.IsValid() { + v := *structPointer_Bytes(base, prop.unrecField) + n += len(v) + } + + // Factor in any oneof fields. + if prop.oneofSizer != nil { + m := structPointer_Interface(base, prop.stype).(Message) + n += prop.oneofSizer(m) + } + + return +} + +var zeroes [20]byte // longer than any conceivable sizeVarint + +// Encode a struct, preceded by its encoded length (as a varint). +func (o *Buffer) enc_len_struct(prop *StructProperties, base structPointer, state *errorState) error { + return o.enc_len_thing(func() error { return o.enc_struct(prop, base) }, state) +} + +// Encode something, preceded by its encoded length (as a varint). +func (o *Buffer) enc_len_thing(enc func() error, state *errorState) error { + iLen := len(o.buf) + o.buf = append(o.buf, 0, 0, 0, 0) // reserve four bytes for length + iMsg := len(o.buf) + err := enc() + if err != nil && !state.shouldContinue(err, nil) { + return err + } + lMsg := len(o.buf) - iMsg + lLen := sizeVarint(uint64(lMsg)) + switch x := lLen - (iMsg - iLen); { + case x > 0: // actual length is x bytes larger than the space we reserved + // Move msg x bytes right. + o.buf = append(o.buf, zeroes[:x]...) + copy(o.buf[iMsg+x:], o.buf[iMsg:iMsg+lMsg]) + case x < 0: // actual length is x bytes smaller than the space we reserved + // Move msg x bytes left. + copy(o.buf[iMsg+x:], o.buf[iMsg:iMsg+lMsg]) + o.buf = o.buf[:len(o.buf)+x] // x is negative + } + // Encode the length in the reserved space. + o.buf = o.buf[:iLen] + o.EncodeVarint(uint64(lMsg)) + o.buf = o.buf[:len(o.buf)+lMsg] + return state.err +} + +// errorState maintains the first error that occurs and updates that error +// with additional context. +type errorState struct { + err error +} + +// shouldContinue reports whether encoding should continue upon encountering the +// given error. If the error is RequiredNotSetError, shouldContinue returns true +// and, if this is the first appearance of that error, remembers it for future +// reporting. +// +// If prop is not nil, it may update any error with additional context about the +// field with the error. +func (s *errorState) shouldContinue(err error, prop *Properties) bool { + // Ignore unset required fields. + reqNotSet, ok := err.(*RequiredNotSetError) + if !ok { + return false + } + if s.err == nil { + if prop != nil { + err = &RequiredNotSetError{prop.Name + "." + reqNotSet.field} + } + s.err = err + } + return true +} diff --git a/vendor/github.com/golang/protobuf/proto/equal.go b/vendor/github.com/golang/protobuf/proto/equal.go new file mode 100644 index 0000000000..f5db1def3c --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/equal.go @@ -0,0 +1,276 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2011 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Protocol buffer comparison. + +package proto + +import ( + "bytes" + "log" + "reflect" + "strings" +) + +/* +Equal returns true iff protocol buffers a and b are equal. +The arguments must both be pointers to protocol buffer structs. + +Equality is defined in this way: + - Two messages are equal iff they are the same type, + corresponding fields are equal, unknown field sets + are equal, and extensions sets are equal. + - Two set scalar fields are equal iff their values are equal. + If the fields are of a floating-point type, remember that + NaN != x for all x, including NaN. If the message is defined + in a proto3 .proto file, fields are not "set"; specifically, + zero length proto3 "bytes" fields are equal (nil == {}). + - Two repeated fields are equal iff their lengths are the same, + and their corresponding elements are equal (a "bytes" field, + although represented by []byte, is not a repeated field) + - Two unset fields are equal. + - Two unknown field sets are equal if their current + encoded state is equal. + - Two extension sets are equal iff they have corresponding + elements that are pairwise equal. + - Every other combination of things are not equal. + +The return value is undefined if a and b are not protocol buffers. +*/ +func Equal(a, b Message) bool { + if a == nil || b == nil { + return a == b + } + v1, v2 := reflect.ValueOf(a), reflect.ValueOf(b) + if v1.Type() != v2.Type() { + return false + } + if v1.Kind() == reflect.Ptr { + if v1.IsNil() { + return v2.IsNil() + } + if v2.IsNil() { + return false + } + v1, v2 = v1.Elem(), v2.Elem() + } + if v1.Kind() != reflect.Struct { + return false + } + return equalStruct(v1, v2) +} + +// v1 and v2 are known to have the same type. +func equalStruct(v1, v2 reflect.Value) bool { + sprop := GetProperties(v1.Type()) + for i := 0; i < v1.NumField(); i++ { + f := v1.Type().Field(i) + if strings.HasPrefix(f.Name, "XXX_") { + continue + } + f1, f2 := v1.Field(i), v2.Field(i) + if f.Type.Kind() == reflect.Ptr { + if n1, n2 := f1.IsNil(), f2.IsNil(); n1 && n2 { + // both unset + continue + } else if n1 != n2 { + // set/unset mismatch + return false + } + b1, ok := f1.Interface().(raw) + if ok { + b2 := f2.Interface().(raw) + // RawMessage + if !bytes.Equal(b1.Bytes(), b2.Bytes()) { + return false + } + continue + } + f1, f2 = f1.Elem(), f2.Elem() + } + if !equalAny(f1, f2, sprop.Prop[i]) { + return false + } + } + + if em1 := v1.FieldByName("XXX_extensions"); em1.IsValid() { + em2 := v2.FieldByName("XXX_extensions") + if !equalExtensions(v1.Type(), em1.Interface().(map[int32]Extension), em2.Interface().(map[int32]Extension)) { + return false + } + } + + uf := v1.FieldByName("XXX_unrecognized") + if !uf.IsValid() { + return true + } + + u1 := uf.Bytes() + u2 := v2.FieldByName("XXX_unrecognized").Bytes() + if !bytes.Equal(u1, u2) { + return false + } + + return true +} + +// v1 and v2 are known to have the same type. +// prop may be nil. +func equalAny(v1, v2 reflect.Value, prop *Properties) bool { + if v1.Type() == protoMessageType { + m1, _ := v1.Interface().(Message) + m2, _ := v2.Interface().(Message) + return Equal(m1, m2) + } + switch v1.Kind() { + case reflect.Bool: + return v1.Bool() == v2.Bool() + case reflect.Float32, reflect.Float64: + return v1.Float() == v2.Float() + case reflect.Int32, reflect.Int64: + return v1.Int() == v2.Int() + case reflect.Interface: + // Probably a oneof field; compare the inner values. + n1, n2 := v1.IsNil(), v2.IsNil() + if n1 || n2 { + return n1 == n2 + } + e1, e2 := v1.Elem(), v2.Elem() + if e1.Type() != e2.Type() { + return false + } + return equalAny(e1, e2, nil) + case reflect.Map: + if v1.Len() != v2.Len() { + return false + } + for _, key := range v1.MapKeys() { + val2 := v2.MapIndex(key) + if !val2.IsValid() { + // This key was not found in the second map. + return false + } + if !equalAny(v1.MapIndex(key), val2, nil) { + return false + } + } + return true + case reflect.Ptr: + return equalAny(v1.Elem(), v2.Elem(), prop) + case reflect.Slice: + if v1.Type().Elem().Kind() == reflect.Uint8 { + // short circuit: []byte + + // Edge case: if this is in a proto3 message, a zero length + // bytes field is considered the zero value. + if prop != nil && prop.proto3 && v1.Len() == 0 && v2.Len() == 0 { + return true + } + if v1.IsNil() != v2.IsNil() { + return false + } + return bytes.Equal(v1.Interface().([]byte), v2.Interface().([]byte)) + } + + if v1.Len() != v2.Len() { + return false + } + for i := 0; i < v1.Len(); i++ { + if !equalAny(v1.Index(i), v2.Index(i), prop) { + return false + } + } + return true + case reflect.String: + return v1.Interface().(string) == v2.Interface().(string) + case reflect.Struct: + return equalStruct(v1, v2) + case reflect.Uint32, reflect.Uint64: + return v1.Uint() == v2.Uint() + } + + // unknown type, so not a protocol buffer + log.Printf("proto: don't know how to compare %v", v1) + return false +} + +// base is the struct type that the extensions are based on. +// em1 and em2 are extension maps. +func equalExtensions(base reflect.Type, em1, em2 map[int32]Extension) bool { + if len(em1) != len(em2) { + return false + } + + for extNum, e1 := range em1 { + e2, ok := em2[extNum] + if !ok { + return false + } + + m1, m2 := e1.value, e2.value + + if m1 != nil && m2 != nil { + // Both are unencoded. + if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) { + return false + } + continue + } + + // At least one is encoded. To do a semantically correct comparison + // we need to unmarshal them first. + var desc *ExtensionDesc + if m := extensionMaps[base]; m != nil { + desc = m[extNum] + } + if desc == nil { + log.Printf("proto: don't know how to compare extension %d of %v", extNum, base) + continue + } + var err error + if m1 == nil { + m1, err = decodeExtension(e1.enc, desc) + } + if m2 == nil && err == nil { + m2, err = decodeExtension(e2.enc, desc) + } + if err != nil { + // The encoded form is invalid. + log.Printf("proto: badly encoded extension %d of %v: %v", extNum, base, err) + return false + } + if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) { + return false + } + } + + return true +} diff --git a/vendor/github.com/golang/protobuf/proto/extensions.go b/vendor/github.com/golang/protobuf/proto/extensions.go new file mode 100644 index 0000000000..054f4f1df7 --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/extensions.go @@ -0,0 +1,399 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +/* + * Types and routines for supporting protocol buffer extensions. + */ + +import ( + "errors" + "fmt" + "reflect" + "strconv" + "sync" +) + +// ErrMissingExtension is the error returned by GetExtension if the named extension is not in the message. +var ErrMissingExtension = errors.New("proto: missing extension") + +// ExtensionRange represents a range of message extensions for a protocol buffer. +// Used in code generated by the protocol compiler. +type ExtensionRange struct { + Start, End int32 // both inclusive +} + +// extendableProto is an interface implemented by any protocol buffer that may be extended. +type extendableProto interface { + Message + ExtensionRangeArray() []ExtensionRange + ExtensionMap() map[int32]Extension +} + +var extendableProtoType = reflect.TypeOf((*extendableProto)(nil)).Elem() + +// ExtensionDesc represents an extension specification. +// Used in generated code from the protocol compiler. +type ExtensionDesc struct { + ExtendedType Message // nil pointer to the type that is being extended + ExtensionType interface{} // nil pointer to the extension type + Field int32 // field number + Name string // fully-qualified name of extension, for text formatting + Tag string // protobuf tag style +} + +func (ed *ExtensionDesc) repeated() bool { + t := reflect.TypeOf(ed.ExtensionType) + return t.Kind() == reflect.Slice && t.Elem().Kind() != reflect.Uint8 +} + +// Extension represents an extension in a message. +type Extension struct { + // When an extension is stored in a message using SetExtension + // only desc and value are set. When the message is marshaled + // enc will be set to the encoded form of the message. + // + // When a message is unmarshaled and contains extensions, each + // extension will have only enc set. When such an extension is + // accessed using GetExtension (or GetExtensions) desc and value + // will be set. + desc *ExtensionDesc + value interface{} + enc []byte +} + +// SetRawExtension is for testing only. +func SetRawExtension(base extendableProto, id int32, b []byte) { + base.ExtensionMap()[id] = Extension{enc: b} +} + +// isExtensionField returns true iff the given field number is in an extension range. +func isExtensionField(pb extendableProto, field int32) bool { + for _, er := range pb.ExtensionRangeArray() { + if er.Start <= field && field <= er.End { + return true + } + } + return false +} + +// checkExtensionTypes checks that the given extension is valid for pb. +func checkExtensionTypes(pb extendableProto, extension *ExtensionDesc) error { + // Check the extended type. + if a, b := reflect.TypeOf(pb), reflect.TypeOf(extension.ExtendedType); a != b { + return errors.New("proto: bad extended type; " + b.String() + " does not extend " + a.String()) + } + // Check the range. + if !isExtensionField(pb, extension.Field) { + return errors.New("proto: bad extension number; not in declared ranges") + } + return nil +} + +// extPropKey is sufficient to uniquely identify an extension. +type extPropKey struct { + base reflect.Type + field int32 +} + +var extProp = struct { + sync.RWMutex + m map[extPropKey]*Properties +}{ + m: make(map[extPropKey]*Properties), +} + +func extensionProperties(ed *ExtensionDesc) *Properties { + key := extPropKey{base: reflect.TypeOf(ed.ExtendedType), field: ed.Field} + + extProp.RLock() + if prop, ok := extProp.m[key]; ok { + extProp.RUnlock() + return prop + } + extProp.RUnlock() + + extProp.Lock() + defer extProp.Unlock() + // Check again. + if prop, ok := extProp.m[key]; ok { + return prop + } + + prop := new(Properties) + prop.Init(reflect.TypeOf(ed.ExtensionType), "unknown_name", ed.Tag, nil) + extProp.m[key] = prop + return prop +} + +// encodeExtensionMap encodes any unmarshaled (unencoded) extensions in m. +func encodeExtensionMap(m map[int32]Extension) error { + for k, e := range m { + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + et := reflect.TypeOf(e.desc.ExtensionType) + props := extensionProperties(e.desc) + + p := NewBuffer(nil) + // If e.value has type T, the encoder expects a *struct{ X T }. + // Pass a *T with a zero field and hope it all works out. + x := reflect.New(et) + x.Elem().Set(reflect.ValueOf(e.value)) + if err := props.enc(p, props, toStructPointer(x)); err != nil { + return err + } + e.enc = p.buf + m[k] = e + } + return nil +} + +func sizeExtensionMap(m map[int32]Extension) (n int) { + for _, e := range m { + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + n += len(e.enc) + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + et := reflect.TypeOf(e.desc.ExtensionType) + props := extensionProperties(e.desc) + + // If e.value has type T, the encoder expects a *struct{ X T }. + // Pass a *T with a zero field and hope it all works out. + x := reflect.New(et) + x.Elem().Set(reflect.ValueOf(e.value)) + n += props.size(props, toStructPointer(x)) + } + return +} + +// HasExtension returns whether the given extension is present in pb. +func HasExtension(pb extendableProto, extension *ExtensionDesc) bool { + // TODO: Check types, field numbers, etc.? + _, ok := pb.ExtensionMap()[extension.Field] + return ok +} + +// ClearExtension removes the given extension from pb. +func ClearExtension(pb extendableProto, extension *ExtensionDesc) { + // TODO: Check types, field numbers, etc.? + delete(pb.ExtensionMap(), extension.Field) +} + +// GetExtension parses and returns the given extension of pb. +// If the extension is not present and has no default value it returns ErrMissingExtension. +func GetExtension(pb extendableProto, extension *ExtensionDesc) (interface{}, error) { + if err := checkExtensionTypes(pb, extension); err != nil { + return nil, err + } + + emap := pb.ExtensionMap() + e, ok := emap[extension.Field] + if !ok { + // defaultExtensionValue returns the default value or + // ErrMissingExtension if there is no default. + return defaultExtensionValue(extension) + } + + if e.value != nil { + // Already decoded. Check the descriptor, though. + if e.desc != extension { + // This shouldn't happen. If it does, it means that + // GetExtension was called twice with two different + // descriptors with the same field number. + return nil, errors.New("proto: descriptor conflict") + } + return e.value, nil + } + + v, err := decodeExtension(e.enc, extension) + if err != nil { + return nil, err + } + + // Remember the decoded version and drop the encoded version. + // That way it is safe to mutate what we return. + e.value = v + e.desc = extension + e.enc = nil + emap[extension.Field] = e + return e.value, nil +} + +// defaultExtensionValue returns the default value for extension. +// If no default for an extension is defined ErrMissingExtension is returned. +func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) { + t := reflect.TypeOf(extension.ExtensionType) + props := extensionProperties(extension) + + sf, _, err := fieldDefault(t, props) + if err != nil { + return nil, err + } + + if sf == nil || sf.value == nil { + // There is no default value. + return nil, ErrMissingExtension + } + + if t.Kind() != reflect.Ptr { + // We do not need to return a Ptr, we can directly return sf.value. + return sf.value, nil + } + + // We need to return an interface{} that is a pointer to sf.value. + value := reflect.New(t).Elem() + value.Set(reflect.New(value.Type().Elem())) + if sf.kind == reflect.Int32 { + // We may have an int32 or an enum, but the underlying data is int32. + // Since we can't set an int32 into a non int32 reflect.value directly + // set it as a int32. + value.Elem().SetInt(int64(sf.value.(int32))) + } else { + value.Elem().Set(reflect.ValueOf(sf.value)) + } + return value.Interface(), nil +} + +// decodeExtension decodes an extension encoded in b. +func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) { + o := NewBuffer(b) + + t := reflect.TypeOf(extension.ExtensionType) + + props := extensionProperties(extension) + + // t is a pointer to a struct, pointer to basic type or a slice. + // Allocate a "field" to store the pointer/slice itself; the + // pointer/slice will be stored here. We pass + // the address of this field to props.dec. + // This passes a zero field and a *t and lets props.dec + // interpret it as a *struct{ x t }. + value := reflect.New(t).Elem() + + for { + // Discard wire type and field number varint. It isn't needed. + if _, err := o.DecodeVarint(); err != nil { + return nil, err + } + + if err := props.dec(o, props, toStructPointer(value.Addr())); err != nil { + return nil, err + } + + if o.index >= len(o.buf) { + break + } + } + return value.Interface(), nil +} + +// GetExtensions returns a slice of the extensions present in pb that are also listed in es. +// The returned slice has the same length as es; missing extensions will appear as nil elements. +func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, err error) { + epb, ok := pb.(extendableProto) + if !ok { + err = errors.New("proto: not an extendable proto") + return + } + extensions = make([]interface{}, len(es)) + for i, e := range es { + extensions[i], err = GetExtension(epb, e) + if err == ErrMissingExtension { + err = nil + } + if err != nil { + return + } + } + return +} + +// SetExtension sets the specified extension of pb to the specified value. +func SetExtension(pb extendableProto, extension *ExtensionDesc, value interface{}) error { + if err := checkExtensionTypes(pb, extension); err != nil { + return err + } + typ := reflect.TypeOf(extension.ExtensionType) + if typ != reflect.TypeOf(value) { + return errors.New("proto: bad extension value type") + } + // nil extension values need to be caught early, because the + // encoder can't distinguish an ErrNil due to a nil extension + // from an ErrNil due to a missing field. Extensions are + // always optional, so the encoder would just swallow the error + // and drop all the extensions from the encoded message. + if reflect.ValueOf(value).IsNil() { + return fmt.Errorf("proto: SetExtension called with nil value of type %T", value) + } + + pb.ExtensionMap()[extension.Field] = Extension{desc: extension, value: value} + return nil +} + +// A global registry of extensions. +// The generated code will register the generated descriptors by calling RegisterExtension. + +var extensionMaps = make(map[reflect.Type]map[int32]*ExtensionDesc) + +// RegisterExtension is called from the generated code. +func RegisterExtension(desc *ExtensionDesc) { + st := reflect.TypeOf(desc.ExtendedType).Elem() + m := extensionMaps[st] + if m == nil { + m = make(map[int32]*ExtensionDesc) + extensionMaps[st] = m + } + if _, ok := m[desc.Field]; ok { + panic("proto: duplicate extension registered: " + st.String() + " " + strconv.Itoa(int(desc.Field))) + } + m[desc.Field] = desc +} + +// RegisteredExtensions returns a map of the registered extensions of a +// protocol buffer struct, indexed by the extension number. +// The argument pb should be a nil pointer to the struct type. +func RegisteredExtensions(pb Message) map[int32]*ExtensionDesc { + return extensionMaps[reflect.TypeOf(pb).Elem()] +} diff --git a/vendor/github.com/golang/protobuf/proto/lib.go b/vendor/github.com/golang/protobuf/proto/lib.go new file mode 100644 index 0000000000..0de8f8dffd --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/lib.go @@ -0,0 +1,894 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +/* +Package proto converts data structures to and from the wire format of +protocol buffers. It works in concert with the Go source code generated +for .proto files by the protocol compiler. + +A summary of the properties of the protocol buffer interface +for a protocol buffer variable v: + + - Names are turned from camel_case to CamelCase for export. + - There are no methods on v to set fields; just treat + them as structure fields. + - There are getters that return a field's value if set, + and return the field's default value if unset. + The getters work even if the receiver is a nil message. + - The zero value for a struct is its correct initialization state. + All desired fields must be set before marshaling. + - A Reset() method will restore a protobuf struct to its zero state. + - Non-repeated fields are pointers to the values; nil means unset. + That is, optional or required field int32 f becomes F *int32. + - Repeated fields are slices. + - Helper functions are available to aid the setting of fields. + msg.Foo = proto.String("hello") // set field + - Constants are defined to hold the default values of all fields that + have them. They have the form Default_StructName_FieldName. + Because the getter methods handle defaulted values, + direct use of these constants should be rare. + - Enums are given type names and maps from names to values. + Enum values are prefixed by the enclosing message's name, or by the + enum's type name if it is a top-level enum. Enum types have a String + method, and a Enum method to assist in message construction. + - Nested messages, groups and enums have type names prefixed with the name of + the surrounding message type. + - Extensions are given descriptor names that start with E_, + followed by an underscore-delimited list of the nested messages + that contain it (if any) followed by the CamelCased name of the + extension field itself. HasExtension, ClearExtension, GetExtension + and SetExtension are functions for manipulating extensions. + - Oneof field sets are given a single field in their message, + with distinguished wrapper types for each possible field value. + - Marshal and Unmarshal are functions to encode and decode the wire format. + +When the .proto file specifies `syntax="proto3"`, there are some differences: + + - Non-repeated fields of non-message type are values instead of pointers. + - Getters are only generated for message and oneof fields. + - Enum types do not get an Enum method. + +The simplest way to describe this is to see an example. +Given file test.proto, containing + + package example; + + enum FOO { X = 17; } + + message Test { + required string label = 1; + optional int32 type = 2 [default=77]; + repeated int64 reps = 3; + optional group OptionalGroup = 4 { + required string RequiredField = 5; + } + oneof union { + int32 number = 6; + string name = 7; + } + } + +The resulting file, test.pb.go, is: + + package example + + import proto "github.com/golang/protobuf/proto" + import math "math" + + type FOO int32 + const ( + FOO_X FOO = 17 + ) + var FOO_name = map[int32]string{ + 17: "X", + } + var FOO_value = map[string]int32{ + "X": 17, + } + + func (x FOO) Enum() *FOO { + p := new(FOO) + *p = x + return p + } + func (x FOO) String() string { + return proto.EnumName(FOO_name, int32(x)) + } + func (x *FOO) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(FOO_value, data) + if err != nil { + return err + } + *x = FOO(value) + return nil + } + + type Test struct { + Label *string `protobuf:"bytes,1,req,name=label" json:"label,omitempty"` + Type *int32 `protobuf:"varint,2,opt,name=type,def=77" json:"type,omitempty"` + Reps []int64 `protobuf:"varint,3,rep,name=reps" json:"reps,omitempty"` + Optionalgroup *Test_OptionalGroup `protobuf:"group,4,opt,name=OptionalGroup" json:"optionalgroup,omitempty"` + // Types that are valid to be assigned to Union: + // *Test_Number + // *Test_Name + Union isTest_Union `protobuf_oneof:"union"` + XXX_unrecognized []byte `json:"-"` + } + func (m *Test) Reset() { *m = Test{} } + func (m *Test) String() string { return proto.CompactTextString(m) } + func (*Test) ProtoMessage() {} + + type isTest_Union interface { + isTest_Union() + } + + type Test_Number struct { + Number int32 `protobuf:"varint,6,opt,name=number"` + } + type Test_Name struct { + Name string `protobuf:"bytes,7,opt,name=name"` + } + + func (*Test_Number) isTest_Union() {} + func (*Test_Name) isTest_Union() {} + + func (m *Test) GetUnion() isTest_Union { + if m != nil { + return m.Union + } + return nil + } + const Default_Test_Type int32 = 77 + + func (m *Test) GetLabel() string { + if m != nil && m.Label != nil { + return *m.Label + } + return "" + } + + func (m *Test) GetType() int32 { + if m != nil && m.Type != nil { + return *m.Type + } + return Default_Test_Type + } + + func (m *Test) GetOptionalgroup() *Test_OptionalGroup { + if m != nil { + return m.Optionalgroup + } + return nil + } + + type Test_OptionalGroup struct { + RequiredField *string `protobuf:"bytes,5,req" json:"RequiredField,omitempty"` + } + func (m *Test_OptionalGroup) Reset() { *m = Test_OptionalGroup{} } + func (m *Test_OptionalGroup) String() string { return proto.CompactTextString(m) } + + func (m *Test_OptionalGroup) GetRequiredField() string { + if m != nil && m.RequiredField != nil { + return *m.RequiredField + } + return "" + } + + func (m *Test) GetNumber() int32 { + if x, ok := m.GetUnion().(*Test_Number); ok { + return x.Number + } + return 0 + } + + func (m *Test) GetName() string { + if x, ok := m.GetUnion().(*Test_Name); ok { + return x.Name + } + return "" + } + + func init() { + proto.RegisterEnum("example.FOO", FOO_name, FOO_value) + } + +To create and play with a Test object: + + package main + + import ( + "log" + + "github.com/golang/protobuf/proto" + pb "./example.pb" + ) + + func main() { + test := &pb.Test{ + Label: proto.String("hello"), + Type: proto.Int32(17), + Reps: []int64{1, 2, 3}, + Optionalgroup: &pb.Test_OptionalGroup{ + RequiredField: proto.String("good bye"), + }, + Union: &pb.Test_Name{"fred"}, + } + data, err := proto.Marshal(test) + if err != nil { + log.Fatal("marshaling error: ", err) + } + newTest := &pb.Test{} + err = proto.Unmarshal(data, newTest) + if err != nil { + log.Fatal("unmarshaling error: ", err) + } + // Now test and newTest contain the same data. + if test.GetLabel() != newTest.GetLabel() { + log.Fatalf("data mismatch %q != %q", test.GetLabel(), newTest.GetLabel()) + } + // Use a type switch to determine which oneof was set. + switch u := test.Union.(type) { + case *pb.Test_Number: // u.Number contains the number. + case *pb.Test_Name: // u.Name contains the string. + } + // etc. + } +*/ +package proto + +import ( + "encoding/json" + "fmt" + "log" + "reflect" + "sort" + "strconv" + "sync" +) + +// Message is implemented by generated protocol buffer messages. +type Message interface { + Reset() + String() string + ProtoMessage() +} + +// Stats records allocation details about the protocol buffer encoders +// and decoders. Useful for tuning the library itself. +type Stats struct { + Emalloc uint64 // mallocs in encode + Dmalloc uint64 // mallocs in decode + Encode uint64 // number of encodes + Decode uint64 // number of decodes + Chit uint64 // number of cache hits + Cmiss uint64 // number of cache misses + Size uint64 // number of sizes +} + +// Set to true to enable stats collection. +const collectStats = false + +var stats Stats + +// GetStats returns a copy of the global Stats structure. +func GetStats() Stats { return stats } + +// A Buffer is a buffer manager for marshaling and unmarshaling +// protocol buffers. It may be reused between invocations to +// reduce memory usage. It is not necessary to use a Buffer; +// the global functions Marshal and Unmarshal create a +// temporary Buffer and are fine for most applications. +type Buffer struct { + buf []byte // encode/decode byte stream + index int // write point + + // pools of basic types to amortize allocation. + bools []bool + uint32s []uint32 + uint64s []uint64 + + // extra pools, only used with pointer_reflect.go + int32s []int32 + int64s []int64 + float32s []float32 + float64s []float64 +} + +// NewBuffer allocates a new Buffer and initializes its internal data to +// the contents of the argument slice. +func NewBuffer(e []byte) *Buffer { + return &Buffer{buf: e} +} + +// Reset resets the Buffer, ready for marshaling a new protocol buffer. +func (p *Buffer) Reset() { + p.buf = p.buf[0:0] // for reading/writing + p.index = 0 // for reading +} + +// SetBuf replaces the internal buffer with the slice, +// ready for unmarshaling the contents of the slice. +func (p *Buffer) SetBuf(s []byte) { + p.buf = s + p.index = 0 +} + +// Bytes returns the contents of the Buffer. +func (p *Buffer) Bytes() []byte { return p.buf } + +/* + * Helper routines for simplifying the creation of optional fields of basic type. + */ + +// Bool is a helper routine that allocates a new bool value +// to store v and returns a pointer to it. +func Bool(v bool) *bool { + return &v +} + +// Int32 is a helper routine that allocates a new int32 value +// to store v and returns a pointer to it. +func Int32(v int32) *int32 { + return &v +} + +// Int is a helper routine that allocates a new int32 value +// to store v and returns a pointer to it, but unlike Int32 +// its argument value is an int. +func Int(v int) *int32 { + p := new(int32) + *p = int32(v) + return p +} + +// Int64 is a helper routine that allocates a new int64 value +// to store v and returns a pointer to it. +func Int64(v int64) *int64 { + return &v +} + +// Float32 is a helper routine that allocates a new float32 value +// to store v and returns a pointer to it. +func Float32(v float32) *float32 { + return &v +} + +// Float64 is a helper routine that allocates a new float64 value +// to store v and returns a pointer to it. +func Float64(v float64) *float64 { + return &v +} + +// Uint32 is a helper routine that allocates a new uint32 value +// to store v and returns a pointer to it. +func Uint32(v uint32) *uint32 { + return &v +} + +// Uint64 is a helper routine that allocates a new uint64 value +// to store v and returns a pointer to it. +func Uint64(v uint64) *uint64 { + return &v +} + +// String is a helper routine that allocates a new string value +// to store v and returns a pointer to it. +func String(v string) *string { + return &v +} + +// EnumName is a helper function to simplify printing protocol buffer enums +// by name. Given an enum map and a value, it returns a useful string. +func EnumName(m map[int32]string, v int32) string { + s, ok := m[v] + if ok { + return s + } + return strconv.Itoa(int(v)) +} + +// UnmarshalJSONEnum is a helper function to simplify recovering enum int values +// from their JSON-encoded representation. Given a map from the enum's symbolic +// names to its int values, and a byte buffer containing the JSON-encoded +// value, it returns an int32 that can be cast to the enum type by the caller. +// +// The function can deal with both JSON representations, numeric and symbolic. +func UnmarshalJSONEnum(m map[string]int32, data []byte, enumName string) (int32, error) { + if data[0] == '"' { + // New style: enums are strings. + var repr string + if err := json.Unmarshal(data, &repr); err != nil { + return -1, err + } + val, ok := m[repr] + if !ok { + return 0, fmt.Errorf("unrecognized enum %s value %q", enumName, repr) + } + return val, nil + } + // Old style: enums are ints. + var val int32 + if err := json.Unmarshal(data, &val); err != nil { + return 0, fmt.Errorf("cannot unmarshal %#q into enum %s", data, enumName) + } + return val, nil +} + +// DebugPrint dumps the encoded data in b in a debugging format with a header +// including the string s. Used in testing but made available for general debugging. +func (p *Buffer) DebugPrint(s string, b []byte) { + var u uint64 + + obuf := p.buf + index := p.index + p.buf = b + p.index = 0 + depth := 0 + + fmt.Printf("\n--- %s ---\n", s) + +out: + for { + for i := 0; i < depth; i++ { + fmt.Print(" ") + } + + index := p.index + if index == len(p.buf) { + break + } + + op, err := p.DecodeVarint() + if err != nil { + fmt.Printf("%3d: fetching op err %v\n", index, err) + break out + } + tag := op >> 3 + wire := op & 7 + + switch wire { + default: + fmt.Printf("%3d: t=%3d unknown wire=%d\n", + index, tag, wire) + break out + + case WireBytes: + var r []byte + + r, err = p.DecodeRawBytes(false) + if err != nil { + break out + } + fmt.Printf("%3d: t=%3d bytes [%d]", index, tag, len(r)) + if len(r) <= 6 { + for i := 0; i < len(r); i++ { + fmt.Printf(" %.2x", r[i]) + } + } else { + for i := 0; i < 3; i++ { + fmt.Printf(" %.2x", r[i]) + } + fmt.Printf(" ..") + for i := len(r) - 3; i < len(r); i++ { + fmt.Printf(" %.2x", r[i]) + } + } + fmt.Printf("\n") + + case WireFixed32: + u, err = p.DecodeFixed32() + if err != nil { + fmt.Printf("%3d: t=%3d fix32 err %v\n", index, tag, err) + break out + } + fmt.Printf("%3d: t=%3d fix32 %d\n", index, tag, u) + + case WireFixed64: + u, err = p.DecodeFixed64() + if err != nil { + fmt.Printf("%3d: t=%3d fix64 err %v\n", index, tag, err) + break out + } + fmt.Printf("%3d: t=%3d fix64 %d\n", index, tag, u) + + case WireVarint: + u, err = p.DecodeVarint() + if err != nil { + fmt.Printf("%3d: t=%3d varint err %v\n", index, tag, err) + break out + } + fmt.Printf("%3d: t=%3d varint %d\n", index, tag, u) + + case WireStartGroup: + fmt.Printf("%3d: t=%3d start\n", index, tag) + depth++ + + case WireEndGroup: + depth-- + fmt.Printf("%3d: t=%3d end\n", index, tag) + } + } + + if depth != 0 { + fmt.Printf("%3d: start-end not balanced %d\n", p.index, depth) + } + fmt.Printf("\n") + + p.buf = obuf + p.index = index +} + +// SetDefaults sets unset protocol buffer fields to their default values. +// It only modifies fields that are both unset and have defined defaults. +// It recursively sets default values in any non-nil sub-messages. +func SetDefaults(pb Message) { + setDefaults(reflect.ValueOf(pb), true, false) +} + +// v is a pointer to a struct. +func setDefaults(v reflect.Value, recur, zeros bool) { + v = v.Elem() + + defaultMu.RLock() + dm, ok := defaults[v.Type()] + defaultMu.RUnlock() + if !ok { + dm = buildDefaultMessage(v.Type()) + defaultMu.Lock() + defaults[v.Type()] = dm + defaultMu.Unlock() + } + + for _, sf := range dm.scalars { + f := v.Field(sf.index) + if !f.IsNil() { + // field already set + continue + } + dv := sf.value + if dv == nil && !zeros { + // no explicit default, and don't want to set zeros + continue + } + fptr := f.Addr().Interface() // **T + // TODO: Consider batching the allocations we do here. + switch sf.kind { + case reflect.Bool: + b := new(bool) + if dv != nil { + *b = dv.(bool) + } + *(fptr.(**bool)) = b + case reflect.Float32: + f := new(float32) + if dv != nil { + *f = dv.(float32) + } + *(fptr.(**float32)) = f + case reflect.Float64: + f := new(float64) + if dv != nil { + *f = dv.(float64) + } + *(fptr.(**float64)) = f + case reflect.Int32: + // might be an enum + if ft := f.Type(); ft != int32PtrType { + // enum + f.Set(reflect.New(ft.Elem())) + if dv != nil { + f.Elem().SetInt(int64(dv.(int32))) + } + } else { + // int32 field + i := new(int32) + if dv != nil { + *i = dv.(int32) + } + *(fptr.(**int32)) = i + } + case reflect.Int64: + i := new(int64) + if dv != nil { + *i = dv.(int64) + } + *(fptr.(**int64)) = i + case reflect.String: + s := new(string) + if dv != nil { + *s = dv.(string) + } + *(fptr.(**string)) = s + case reflect.Uint8: + // exceptional case: []byte + var b []byte + if dv != nil { + db := dv.([]byte) + b = make([]byte, len(db)) + copy(b, db) + } else { + b = []byte{} + } + *(fptr.(*[]byte)) = b + case reflect.Uint32: + u := new(uint32) + if dv != nil { + *u = dv.(uint32) + } + *(fptr.(**uint32)) = u + case reflect.Uint64: + u := new(uint64) + if dv != nil { + *u = dv.(uint64) + } + *(fptr.(**uint64)) = u + default: + log.Printf("proto: can't set default for field %v (sf.kind=%v)", f, sf.kind) + } + } + + for _, ni := range dm.nested { + f := v.Field(ni) + // f is *T or []*T or map[T]*T + switch f.Kind() { + case reflect.Ptr: + if f.IsNil() { + continue + } + setDefaults(f, recur, zeros) + + case reflect.Slice: + for i := 0; i < f.Len(); i++ { + e := f.Index(i) + if e.IsNil() { + continue + } + setDefaults(e, recur, zeros) + } + + case reflect.Map: + for _, k := range f.MapKeys() { + e := f.MapIndex(k) + if e.IsNil() { + continue + } + setDefaults(e, recur, zeros) + } + } + } +} + +var ( + // defaults maps a protocol buffer struct type to a slice of the fields, + // with its scalar fields set to their proto-declared non-zero default values. + defaultMu sync.RWMutex + defaults = make(map[reflect.Type]defaultMessage) + + int32PtrType = reflect.TypeOf((*int32)(nil)) +) + +// defaultMessage represents information about the default values of a message. +type defaultMessage struct { + scalars []scalarField + nested []int // struct field index of nested messages +} + +type scalarField struct { + index int // struct field index + kind reflect.Kind // element type (the T in *T or []T) + value interface{} // the proto-declared default value, or nil +} + +// t is a struct type. +func buildDefaultMessage(t reflect.Type) (dm defaultMessage) { + sprop := GetProperties(t) + for _, prop := range sprop.Prop { + fi, ok := sprop.decoderTags.get(prop.Tag) + if !ok { + // XXX_unrecognized + continue + } + ft := t.Field(fi).Type + + sf, nested, err := fieldDefault(ft, prop) + switch { + case err != nil: + log.Print(err) + case nested: + dm.nested = append(dm.nested, fi) + case sf != nil: + sf.index = fi + dm.scalars = append(dm.scalars, *sf) + } + } + + return dm +} + +// fieldDefault returns the scalarField for field type ft. +// sf will be nil if the field can not have a default. +// nestedMessage will be true if this is a nested message. +// Note that sf.index is not set on return. +func fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMessage bool, err error) { + var canHaveDefault bool + switch ft.Kind() { + case reflect.Ptr: + if ft.Elem().Kind() == reflect.Struct { + nestedMessage = true + } else { + canHaveDefault = true // proto2 scalar field + } + + case reflect.Slice: + switch ft.Elem().Kind() { + case reflect.Ptr: + nestedMessage = true // repeated message + case reflect.Uint8: + canHaveDefault = true // bytes field + } + + case reflect.Map: + if ft.Elem().Kind() == reflect.Ptr { + nestedMessage = true // map with message values + } + } + + if !canHaveDefault { + if nestedMessage { + return nil, true, nil + } + return nil, false, nil + } + + // We now know that ft is a pointer or slice. + sf = &scalarField{kind: ft.Elem().Kind()} + + // scalar fields without defaults + if !prop.HasDefault { + return sf, false, nil + } + + // a scalar field: either *T or []byte + switch ft.Elem().Kind() { + case reflect.Bool: + x, err := strconv.ParseBool(prop.Default) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default bool %q: %v", prop.Default, err) + } + sf.value = x + case reflect.Float32: + x, err := strconv.ParseFloat(prop.Default, 32) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default float32 %q: %v", prop.Default, err) + } + sf.value = float32(x) + case reflect.Float64: + x, err := strconv.ParseFloat(prop.Default, 64) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default float64 %q: %v", prop.Default, err) + } + sf.value = x + case reflect.Int32: + x, err := strconv.ParseInt(prop.Default, 10, 32) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default int32 %q: %v", prop.Default, err) + } + sf.value = int32(x) + case reflect.Int64: + x, err := strconv.ParseInt(prop.Default, 10, 64) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default int64 %q: %v", prop.Default, err) + } + sf.value = x + case reflect.String: + sf.value = prop.Default + case reflect.Uint8: + // []byte (not *uint8) + sf.value = []byte(prop.Default) + case reflect.Uint32: + x, err := strconv.ParseUint(prop.Default, 10, 32) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default uint32 %q: %v", prop.Default, err) + } + sf.value = uint32(x) + case reflect.Uint64: + x, err := strconv.ParseUint(prop.Default, 10, 64) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default uint64 %q: %v", prop.Default, err) + } + sf.value = x + default: + return nil, false, fmt.Errorf("proto: unhandled def kind %v", ft.Elem().Kind()) + } + + return sf, false, nil +} + +// Map fields may have key types of non-float scalars, strings and enums. +// The easiest way to sort them in some deterministic order is to use fmt. +// If this turns out to be inefficient we can always consider other options, +// such as doing a Schwartzian transform. + +func mapKeys(vs []reflect.Value) sort.Interface { + s := mapKeySorter{ + vs: vs, + // default Less function: textual comparison + less: func(a, b reflect.Value) bool { + return fmt.Sprint(a.Interface()) < fmt.Sprint(b.Interface()) + }, + } + + // Type specialization per https://developers.google.com/protocol-buffers/docs/proto#maps; + // numeric keys are sorted numerically. + if len(vs) == 0 { + return s + } + switch vs[0].Kind() { + case reflect.Int32, reflect.Int64: + s.less = func(a, b reflect.Value) bool { return a.Int() < b.Int() } + case reflect.Uint32, reflect.Uint64: + s.less = func(a, b reflect.Value) bool { return a.Uint() < b.Uint() } + } + + return s +} + +type mapKeySorter struct { + vs []reflect.Value + less func(a, b reflect.Value) bool +} + +func (s mapKeySorter) Len() int { return len(s.vs) } +func (s mapKeySorter) Swap(i, j int) { s.vs[i], s.vs[j] = s.vs[j], s.vs[i] } +func (s mapKeySorter) Less(i, j int) bool { + return s.less(s.vs[i], s.vs[j]) +} + +// isProto3Zero reports whether v is a zero proto3 value. +func isProto3Zero(v reflect.Value) bool { + switch v.Kind() { + case reflect.Bool: + return !v.Bool() + case reflect.Int32, reflect.Int64: + return v.Int() == 0 + case reflect.Uint32, reflect.Uint64: + return v.Uint() == 0 + case reflect.Float32, reflect.Float64: + return v.Float() == 0 + case reflect.String: + return v.String() == "" + } + return false +} + +// ProtoPackageIsVersion1 is referenced from generated protocol buffer files +// to assert that that code is compatible with this version of the proto package. +const ProtoPackageIsVersion1 = true diff --git a/vendor/github.com/golang/protobuf/proto/message_set.go b/vendor/github.com/golang/protobuf/proto/message_set.go new file mode 100644 index 0000000000..e25e01e637 --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/message_set.go @@ -0,0 +1,280 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +/* + * Support for message sets. + */ + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "reflect" + "sort" +) + +// errNoMessageTypeID occurs when a protocol buffer does not have a message type ID. +// A message type ID is required for storing a protocol buffer in a message set. +var errNoMessageTypeID = errors.New("proto does not have a message type ID") + +// The first two types (_MessageSet_Item and messageSet) +// model what the protocol compiler produces for the following protocol message: +// message MessageSet { +// repeated group Item = 1 { +// required int32 type_id = 2; +// required string message = 3; +// }; +// } +// That is the MessageSet wire format. We can't use a proto to generate these +// because that would introduce a circular dependency between it and this package. + +type _MessageSet_Item struct { + TypeId *int32 `protobuf:"varint,2,req,name=type_id"` + Message []byte `protobuf:"bytes,3,req,name=message"` +} + +type messageSet struct { + Item []*_MessageSet_Item `protobuf:"group,1,rep"` + XXX_unrecognized []byte + // TODO: caching? +} + +// Make sure messageSet is a Message. +var _ Message = (*messageSet)(nil) + +// messageTypeIder is an interface satisfied by a protocol buffer type +// that may be stored in a MessageSet. +type messageTypeIder interface { + MessageTypeId() int32 +} + +func (ms *messageSet) find(pb Message) *_MessageSet_Item { + mti, ok := pb.(messageTypeIder) + if !ok { + return nil + } + id := mti.MessageTypeId() + for _, item := range ms.Item { + if *item.TypeId == id { + return item + } + } + return nil +} + +func (ms *messageSet) Has(pb Message) bool { + if ms.find(pb) != nil { + return true + } + return false +} + +func (ms *messageSet) Unmarshal(pb Message) error { + if item := ms.find(pb); item != nil { + return Unmarshal(item.Message, pb) + } + if _, ok := pb.(messageTypeIder); !ok { + return errNoMessageTypeID + } + return nil // TODO: return error instead? +} + +func (ms *messageSet) Marshal(pb Message) error { + msg, err := Marshal(pb) + if err != nil { + return err + } + if item := ms.find(pb); item != nil { + // reuse existing item + item.Message = msg + return nil + } + + mti, ok := pb.(messageTypeIder) + if !ok { + return errNoMessageTypeID + } + + mtid := mti.MessageTypeId() + ms.Item = append(ms.Item, &_MessageSet_Item{ + TypeId: &mtid, + Message: msg, + }) + return nil +} + +func (ms *messageSet) Reset() { *ms = messageSet{} } +func (ms *messageSet) String() string { return CompactTextString(ms) } +func (*messageSet) ProtoMessage() {} + +// Support for the message_set_wire_format message option. + +func skipVarint(buf []byte) []byte { + i := 0 + for ; buf[i]&0x80 != 0; i++ { + } + return buf[i+1:] +} + +// MarshalMessageSet encodes the extension map represented by m in the message set wire format. +// It is called by generated Marshal methods on protocol buffer messages with the message_set_wire_format option. +func MarshalMessageSet(m map[int32]Extension) ([]byte, error) { + if err := encodeExtensionMap(m); err != nil { + return nil, err + } + + // Sort extension IDs to provide a deterministic encoding. + // See also enc_map in encode.go. + ids := make([]int, 0, len(m)) + for id := range m { + ids = append(ids, int(id)) + } + sort.Ints(ids) + + ms := &messageSet{Item: make([]*_MessageSet_Item, 0, len(m))} + for _, id := range ids { + e := m[int32(id)] + // Remove the wire type and field number varint, as well as the length varint. + msg := skipVarint(skipVarint(e.enc)) + + ms.Item = append(ms.Item, &_MessageSet_Item{ + TypeId: Int32(int32(id)), + Message: msg, + }) + } + return Marshal(ms) +} + +// UnmarshalMessageSet decodes the extension map encoded in buf in the message set wire format. +// It is called by generated Unmarshal methods on protocol buffer messages with the message_set_wire_format option. +func UnmarshalMessageSet(buf []byte, m map[int32]Extension) error { + ms := new(messageSet) + if err := Unmarshal(buf, ms); err != nil { + return err + } + for _, item := range ms.Item { + id := *item.TypeId + msg := item.Message + + // Restore wire type and field number varint, plus length varint. + // Be careful to preserve duplicate items. + b := EncodeVarint(uint64(id)<<3 | WireBytes) + if ext, ok := m[id]; ok { + // Existing data; rip off the tag and length varint + // so we join the new data correctly. + // We can assume that ext.enc is set because we are unmarshaling. + o := ext.enc[len(b):] // skip wire type and field number + _, n := DecodeVarint(o) // calculate length of length varint + o = o[n:] // skip length varint + msg = append(o, msg...) // join old data and new data + } + b = append(b, EncodeVarint(uint64(len(msg)))...) + b = append(b, msg...) + + m[id] = Extension{enc: b} + } + return nil +} + +// MarshalMessageSetJSON encodes the extension map represented by m in JSON format. +// It is called by generated MarshalJSON methods on protocol buffer messages with the message_set_wire_format option. +func MarshalMessageSetJSON(m map[int32]Extension) ([]byte, error) { + var b bytes.Buffer + b.WriteByte('{') + + // Process the map in key order for deterministic output. + ids := make([]int32, 0, len(m)) + for id := range m { + ids = append(ids, id) + } + sort.Sort(int32Slice(ids)) // int32Slice defined in text.go + + for i, id := range ids { + ext := m[id] + if i > 0 { + b.WriteByte(',') + } + + msd, ok := messageSetMap[id] + if !ok { + // Unknown type; we can't render it, so skip it. + continue + } + fmt.Fprintf(&b, `"[%s]":`, msd.name) + + x := ext.value + if x == nil { + x = reflect.New(msd.t.Elem()).Interface() + if err := Unmarshal(ext.enc, x.(Message)); err != nil { + return nil, err + } + } + d, err := json.Marshal(x) + if err != nil { + return nil, err + } + b.Write(d) + } + b.WriteByte('}') + return b.Bytes(), nil +} + +// UnmarshalMessageSetJSON decodes the extension map encoded in buf in JSON format. +// It is called by generated UnmarshalJSON methods on protocol buffer messages with the message_set_wire_format option. +func UnmarshalMessageSetJSON(buf []byte, m map[int32]Extension) error { + // Common-case fast path. + if len(buf) == 0 || bytes.Equal(buf, []byte("{}")) { + return nil + } + + // This is fairly tricky, and it's not clear that it is needed. + return errors.New("TODO: UnmarshalMessageSetJSON not yet implemented") +} + +// A global registry of types that can be used in a MessageSet. + +var messageSetMap = make(map[int32]messageSetDesc) + +type messageSetDesc struct { + t reflect.Type // pointer to struct + name string +} + +// RegisterMessageSetType is called from the generated code. +func RegisterMessageSetType(m Message, fieldNum int32, name string) { + messageSetMap[fieldNum] = messageSetDesc{ + t: reflect.TypeOf(m), + name: name, + } +} diff --git a/vendor/github.com/golang/protobuf/proto/pointer_reflect.go b/vendor/github.com/golang/protobuf/proto/pointer_reflect.go new file mode 100644 index 0000000000..749919d250 --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/pointer_reflect.go @@ -0,0 +1,479 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2012 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// +build appengine + +// This file contains an implementation of proto field accesses using package reflect. +// It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can +// be used on App Engine. + +package proto + +import ( + "math" + "reflect" +) + +// A structPointer is a pointer to a struct. +type structPointer struct { + v reflect.Value +} + +// toStructPointer returns a structPointer equivalent to the given reflect value. +// The reflect value must itself be a pointer to a struct. +func toStructPointer(v reflect.Value) structPointer { + return structPointer{v} +} + +// IsNil reports whether p is nil. +func structPointer_IsNil(p structPointer) bool { + return p.v.IsNil() +} + +// Interface returns the struct pointer as an interface value. +func structPointer_Interface(p structPointer, _ reflect.Type) interface{} { + return p.v.Interface() +} + +// A field identifies a field in a struct, accessible from a structPointer. +// In this implementation, a field is identified by the sequence of field indices +// passed to reflect's FieldByIndex. +type field []int + +// toField returns a field equivalent to the given reflect field. +func toField(f *reflect.StructField) field { + return f.Index +} + +// invalidField is an invalid field identifier. +var invalidField = field(nil) + +// IsValid reports whether the field identifier is valid. +func (f field) IsValid() bool { return f != nil } + +// field returns the given field in the struct as a reflect value. +func structPointer_field(p structPointer, f field) reflect.Value { + // Special case: an extension map entry with a value of type T + // passes a *T to the struct-handling code with a zero field, + // expecting that it will be treated as equivalent to *struct{ X T }, + // which has the same memory layout. We have to handle that case + // specially, because reflect will panic if we call FieldByIndex on a + // non-struct. + if f == nil { + return p.v.Elem() + } + + return p.v.Elem().FieldByIndex(f) +} + +// ifield returns the given field in the struct as an interface value. +func structPointer_ifield(p structPointer, f field) interface{} { + return structPointer_field(p, f).Addr().Interface() +} + +// Bytes returns the address of a []byte field in the struct. +func structPointer_Bytes(p structPointer, f field) *[]byte { + return structPointer_ifield(p, f).(*[]byte) +} + +// BytesSlice returns the address of a [][]byte field in the struct. +func structPointer_BytesSlice(p structPointer, f field) *[][]byte { + return structPointer_ifield(p, f).(*[][]byte) +} + +// Bool returns the address of a *bool field in the struct. +func structPointer_Bool(p structPointer, f field) **bool { + return structPointer_ifield(p, f).(**bool) +} + +// BoolVal returns the address of a bool field in the struct. +func structPointer_BoolVal(p structPointer, f field) *bool { + return structPointer_ifield(p, f).(*bool) +} + +// BoolSlice returns the address of a []bool field in the struct. +func structPointer_BoolSlice(p structPointer, f field) *[]bool { + return structPointer_ifield(p, f).(*[]bool) +} + +// String returns the address of a *string field in the struct. +func structPointer_String(p structPointer, f field) **string { + return structPointer_ifield(p, f).(**string) +} + +// StringVal returns the address of a string field in the struct. +func structPointer_StringVal(p structPointer, f field) *string { + return structPointer_ifield(p, f).(*string) +} + +// StringSlice returns the address of a []string field in the struct. +func structPointer_StringSlice(p structPointer, f field) *[]string { + return structPointer_ifield(p, f).(*[]string) +} + +// ExtMap returns the address of an extension map field in the struct. +func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension { + return structPointer_ifield(p, f).(*map[int32]Extension) +} + +// NewAt returns the reflect.Value for a pointer to a field in the struct. +func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value { + return structPointer_field(p, f).Addr() +} + +// SetStructPointer writes a *struct field in the struct. +func structPointer_SetStructPointer(p structPointer, f field, q structPointer) { + structPointer_field(p, f).Set(q.v) +} + +// GetStructPointer reads a *struct field in the struct. +func structPointer_GetStructPointer(p structPointer, f field) structPointer { + return structPointer{structPointer_field(p, f)} +} + +// StructPointerSlice the address of a []*struct field in the struct. +func structPointer_StructPointerSlice(p structPointer, f field) structPointerSlice { + return structPointerSlice{structPointer_field(p, f)} +} + +// A structPointerSlice represents the address of a slice of pointers to structs +// (themselves messages or groups). That is, v.Type() is *[]*struct{...}. +type structPointerSlice struct { + v reflect.Value +} + +func (p structPointerSlice) Len() int { return p.v.Len() } +func (p structPointerSlice) Index(i int) structPointer { return structPointer{p.v.Index(i)} } +func (p structPointerSlice) Append(q structPointer) { + p.v.Set(reflect.Append(p.v, q.v)) +} + +var ( + int32Type = reflect.TypeOf(int32(0)) + uint32Type = reflect.TypeOf(uint32(0)) + float32Type = reflect.TypeOf(float32(0)) + int64Type = reflect.TypeOf(int64(0)) + uint64Type = reflect.TypeOf(uint64(0)) + float64Type = reflect.TypeOf(float64(0)) +) + +// A word32 represents a field of type *int32, *uint32, *float32, or *enum. +// That is, v.Type() is *int32, *uint32, *float32, or *enum and v is assignable. +type word32 struct { + v reflect.Value +} + +// IsNil reports whether p is nil. +func word32_IsNil(p word32) bool { + return p.v.IsNil() +} + +// Set sets p to point at a newly allocated word with bits set to x. +func word32_Set(p word32, o *Buffer, x uint32) { + t := p.v.Type().Elem() + switch t { + case int32Type: + if len(o.int32s) == 0 { + o.int32s = make([]int32, uint32PoolSize) + } + o.int32s[0] = int32(x) + p.v.Set(reflect.ValueOf(&o.int32s[0])) + o.int32s = o.int32s[1:] + return + case uint32Type: + if len(o.uint32s) == 0 { + o.uint32s = make([]uint32, uint32PoolSize) + } + o.uint32s[0] = x + p.v.Set(reflect.ValueOf(&o.uint32s[0])) + o.uint32s = o.uint32s[1:] + return + case float32Type: + if len(o.float32s) == 0 { + o.float32s = make([]float32, uint32PoolSize) + } + o.float32s[0] = math.Float32frombits(x) + p.v.Set(reflect.ValueOf(&o.float32s[0])) + o.float32s = o.float32s[1:] + return + } + + // must be enum + p.v.Set(reflect.New(t)) + p.v.Elem().SetInt(int64(int32(x))) +} + +// Get gets the bits pointed at by p, as a uint32. +func word32_Get(p word32) uint32 { + elem := p.v.Elem() + switch elem.Kind() { + case reflect.Int32: + return uint32(elem.Int()) + case reflect.Uint32: + return uint32(elem.Uint()) + case reflect.Float32: + return math.Float32bits(float32(elem.Float())) + } + panic("unreachable") +} + +// Word32 returns a reference to a *int32, *uint32, *float32, or *enum field in the struct. +func structPointer_Word32(p structPointer, f field) word32 { + return word32{structPointer_field(p, f)} +} + +// A word32Val represents a field of type int32, uint32, float32, or enum. +// That is, v.Type() is int32, uint32, float32, or enum and v is assignable. +type word32Val struct { + v reflect.Value +} + +// Set sets *p to x. +func word32Val_Set(p word32Val, x uint32) { + switch p.v.Type() { + case int32Type: + p.v.SetInt(int64(x)) + return + case uint32Type: + p.v.SetUint(uint64(x)) + return + case float32Type: + p.v.SetFloat(float64(math.Float32frombits(x))) + return + } + + // must be enum + p.v.SetInt(int64(int32(x))) +} + +// Get gets the bits pointed at by p, as a uint32. +func word32Val_Get(p word32Val) uint32 { + elem := p.v + switch elem.Kind() { + case reflect.Int32: + return uint32(elem.Int()) + case reflect.Uint32: + return uint32(elem.Uint()) + case reflect.Float32: + return math.Float32bits(float32(elem.Float())) + } + panic("unreachable") +} + +// Word32Val returns a reference to a int32, uint32, float32, or enum field in the struct. +func structPointer_Word32Val(p structPointer, f field) word32Val { + return word32Val{structPointer_field(p, f)} +} + +// A word32Slice is a slice of 32-bit values. +// That is, v.Type() is []int32, []uint32, []float32, or []enum. +type word32Slice struct { + v reflect.Value +} + +func (p word32Slice) Append(x uint32) { + n, m := p.v.Len(), p.v.Cap() + if n < m { + p.v.SetLen(n + 1) + } else { + t := p.v.Type().Elem() + p.v.Set(reflect.Append(p.v, reflect.Zero(t))) + } + elem := p.v.Index(n) + switch elem.Kind() { + case reflect.Int32: + elem.SetInt(int64(int32(x))) + case reflect.Uint32: + elem.SetUint(uint64(x)) + case reflect.Float32: + elem.SetFloat(float64(math.Float32frombits(x))) + } +} + +func (p word32Slice) Len() int { + return p.v.Len() +} + +func (p word32Slice) Index(i int) uint32 { + elem := p.v.Index(i) + switch elem.Kind() { + case reflect.Int32: + return uint32(elem.Int()) + case reflect.Uint32: + return uint32(elem.Uint()) + case reflect.Float32: + return math.Float32bits(float32(elem.Float())) + } + panic("unreachable") +} + +// Word32Slice returns a reference to a []int32, []uint32, []float32, or []enum field in the struct. +func structPointer_Word32Slice(p structPointer, f field) word32Slice { + return word32Slice{structPointer_field(p, f)} +} + +// word64 is like word32 but for 64-bit values. +type word64 struct { + v reflect.Value +} + +func word64_Set(p word64, o *Buffer, x uint64) { + t := p.v.Type().Elem() + switch t { + case int64Type: + if len(o.int64s) == 0 { + o.int64s = make([]int64, uint64PoolSize) + } + o.int64s[0] = int64(x) + p.v.Set(reflect.ValueOf(&o.int64s[0])) + o.int64s = o.int64s[1:] + return + case uint64Type: + if len(o.uint64s) == 0 { + o.uint64s = make([]uint64, uint64PoolSize) + } + o.uint64s[0] = x + p.v.Set(reflect.ValueOf(&o.uint64s[0])) + o.uint64s = o.uint64s[1:] + return + case float64Type: + if len(o.float64s) == 0 { + o.float64s = make([]float64, uint64PoolSize) + } + o.float64s[0] = math.Float64frombits(x) + p.v.Set(reflect.ValueOf(&o.float64s[0])) + o.float64s = o.float64s[1:] + return + } + panic("unreachable") +} + +func word64_IsNil(p word64) bool { + return p.v.IsNil() +} + +func word64_Get(p word64) uint64 { + elem := p.v.Elem() + switch elem.Kind() { + case reflect.Int64: + return uint64(elem.Int()) + case reflect.Uint64: + return elem.Uint() + case reflect.Float64: + return math.Float64bits(elem.Float()) + } + panic("unreachable") +} + +func structPointer_Word64(p structPointer, f field) word64 { + return word64{structPointer_field(p, f)} +} + +// word64Val is like word32Val but for 64-bit values. +type word64Val struct { + v reflect.Value +} + +func word64Val_Set(p word64Val, o *Buffer, x uint64) { + switch p.v.Type() { + case int64Type: + p.v.SetInt(int64(x)) + return + case uint64Type: + p.v.SetUint(x) + return + case float64Type: + p.v.SetFloat(math.Float64frombits(x)) + return + } + panic("unreachable") +} + +func word64Val_Get(p word64Val) uint64 { + elem := p.v + switch elem.Kind() { + case reflect.Int64: + return uint64(elem.Int()) + case reflect.Uint64: + return elem.Uint() + case reflect.Float64: + return math.Float64bits(elem.Float()) + } + panic("unreachable") +} + +func structPointer_Word64Val(p structPointer, f field) word64Val { + return word64Val{structPointer_field(p, f)} +} + +type word64Slice struct { + v reflect.Value +} + +func (p word64Slice) Append(x uint64) { + n, m := p.v.Len(), p.v.Cap() + if n < m { + p.v.SetLen(n + 1) + } else { + t := p.v.Type().Elem() + p.v.Set(reflect.Append(p.v, reflect.Zero(t))) + } + elem := p.v.Index(n) + switch elem.Kind() { + case reflect.Int64: + elem.SetInt(int64(int64(x))) + case reflect.Uint64: + elem.SetUint(uint64(x)) + case reflect.Float64: + elem.SetFloat(float64(math.Float64frombits(x))) + } +} + +func (p word64Slice) Len() int { + return p.v.Len() +} + +func (p word64Slice) Index(i int) uint64 { + elem := p.v.Index(i) + switch elem.Kind() { + case reflect.Int64: + return uint64(elem.Int()) + case reflect.Uint64: + return uint64(elem.Uint()) + case reflect.Float64: + return math.Float64bits(float64(elem.Float())) + } + panic("unreachable") +} + +func structPointer_Word64Slice(p structPointer, f field) word64Slice { + return word64Slice{structPointer_field(p, f)} +} diff --git a/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go b/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go new file mode 100644 index 0000000000..e9be0fe92e --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go @@ -0,0 +1,266 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2012 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// +build !appengine + +// This file contains the implementation of the proto field accesses using package unsafe. + +package proto + +import ( + "reflect" + "unsafe" +) + +// NOTE: These type_Foo functions would more idiomatically be methods, +// but Go does not allow methods on pointer types, and we must preserve +// some pointer type for the garbage collector. We use these +// funcs with clunky names as our poor approximation to methods. +// +// An alternative would be +// type structPointer struct { p unsafe.Pointer } +// but that does not registerize as well. + +// A structPointer is a pointer to a struct. +type structPointer unsafe.Pointer + +// toStructPointer returns a structPointer equivalent to the given reflect value. +func toStructPointer(v reflect.Value) structPointer { + return structPointer(unsafe.Pointer(v.Pointer())) +} + +// IsNil reports whether p is nil. +func structPointer_IsNil(p structPointer) bool { + return p == nil +} + +// Interface returns the struct pointer, assumed to have element type t, +// as an interface value. +func structPointer_Interface(p structPointer, t reflect.Type) interface{} { + return reflect.NewAt(t, unsafe.Pointer(p)).Interface() +} + +// A field identifies a field in a struct, accessible from a structPointer. +// In this implementation, a field is identified by its byte offset from the start of the struct. +type field uintptr + +// toField returns a field equivalent to the given reflect field. +func toField(f *reflect.StructField) field { + return field(f.Offset) +} + +// invalidField is an invalid field identifier. +const invalidField = ^field(0) + +// IsValid reports whether the field identifier is valid. +func (f field) IsValid() bool { + return f != ^field(0) +} + +// Bytes returns the address of a []byte field in the struct. +func structPointer_Bytes(p structPointer, f field) *[]byte { + return (*[]byte)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// BytesSlice returns the address of a [][]byte field in the struct. +func structPointer_BytesSlice(p structPointer, f field) *[][]byte { + return (*[][]byte)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// Bool returns the address of a *bool field in the struct. +func structPointer_Bool(p structPointer, f field) **bool { + return (**bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// BoolVal returns the address of a bool field in the struct. +func structPointer_BoolVal(p structPointer, f field) *bool { + return (*bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// BoolSlice returns the address of a []bool field in the struct. +func structPointer_BoolSlice(p structPointer, f field) *[]bool { + return (*[]bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// String returns the address of a *string field in the struct. +func structPointer_String(p structPointer, f field) **string { + return (**string)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// StringVal returns the address of a string field in the struct. +func structPointer_StringVal(p structPointer, f field) *string { + return (*string)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// StringSlice returns the address of a []string field in the struct. +func structPointer_StringSlice(p structPointer, f field) *[]string { + return (*[]string)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// ExtMap returns the address of an extension map field in the struct. +func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension { + return (*map[int32]Extension)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// NewAt returns the reflect.Value for a pointer to a field in the struct. +func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value { + return reflect.NewAt(typ, unsafe.Pointer(uintptr(p)+uintptr(f))) +} + +// SetStructPointer writes a *struct field in the struct. +func structPointer_SetStructPointer(p structPointer, f field, q structPointer) { + *(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))) = q +} + +// GetStructPointer reads a *struct field in the struct. +func structPointer_GetStructPointer(p structPointer, f field) structPointer { + return *(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// StructPointerSlice the address of a []*struct field in the struct. +func structPointer_StructPointerSlice(p structPointer, f field) *structPointerSlice { + return (*structPointerSlice)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// A structPointerSlice represents a slice of pointers to structs (themselves submessages or groups). +type structPointerSlice []structPointer + +func (v *structPointerSlice) Len() int { return len(*v) } +func (v *structPointerSlice) Index(i int) structPointer { return (*v)[i] } +func (v *structPointerSlice) Append(p structPointer) { *v = append(*v, p) } + +// A word32 is the address of a "pointer to 32-bit value" field. +type word32 **uint32 + +// IsNil reports whether *v is nil. +func word32_IsNil(p word32) bool { + return *p == nil +} + +// Set sets *v to point at a newly allocated word set to x. +func word32_Set(p word32, o *Buffer, x uint32) { + if len(o.uint32s) == 0 { + o.uint32s = make([]uint32, uint32PoolSize) + } + o.uint32s[0] = x + *p = &o.uint32s[0] + o.uint32s = o.uint32s[1:] +} + +// Get gets the value pointed at by *v. +func word32_Get(p word32) uint32 { + return **p +} + +// Word32 returns the address of a *int32, *uint32, *float32, or *enum field in the struct. +func structPointer_Word32(p structPointer, f field) word32 { + return word32((**uint32)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +} + +// A word32Val is the address of a 32-bit value field. +type word32Val *uint32 + +// Set sets *p to x. +func word32Val_Set(p word32Val, x uint32) { + *p = x +} + +// Get gets the value pointed at by p. +func word32Val_Get(p word32Val) uint32 { + return *p +} + +// Word32Val returns the address of a *int32, *uint32, *float32, or *enum field in the struct. +func structPointer_Word32Val(p structPointer, f field) word32Val { + return word32Val((*uint32)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +} + +// A word32Slice is a slice of 32-bit values. +type word32Slice []uint32 + +func (v *word32Slice) Append(x uint32) { *v = append(*v, x) } +func (v *word32Slice) Len() int { return len(*v) } +func (v *word32Slice) Index(i int) uint32 { return (*v)[i] } + +// Word32Slice returns the address of a []int32, []uint32, []float32, or []enum field in the struct. +func structPointer_Word32Slice(p structPointer, f field) *word32Slice { + return (*word32Slice)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// word64 is like word32 but for 64-bit values. +type word64 **uint64 + +func word64_Set(p word64, o *Buffer, x uint64) { + if len(o.uint64s) == 0 { + o.uint64s = make([]uint64, uint64PoolSize) + } + o.uint64s[0] = x + *p = &o.uint64s[0] + o.uint64s = o.uint64s[1:] +} + +func word64_IsNil(p word64) bool { + return *p == nil +} + +func word64_Get(p word64) uint64 { + return **p +} + +func structPointer_Word64(p structPointer, f field) word64 { + return word64((**uint64)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +} + +// word64Val is like word32Val but for 64-bit values. +type word64Val *uint64 + +func word64Val_Set(p word64Val, o *Buffer, x uint64) { + *p = x +} + +func word64Val_Get(p word64Val) uint64 { + return *p +} + +func structPointer_Word64Val(p structPointer, f field) word64Val { + return word64Val((*uint64)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +} + +// word64Slice is like word32Slice but for 64-bit values. +type word64Slice []uint64 + +func (v *word64Slice) Append(x uint64) { *v = append(*v, x) } +func (v *word64Slice) Len() int { return len(*v) } +func (v *word64Slice) Index(i int) uint64 { return (*v)[i] } + +func structPointer_Word64Slice(p structPointer, f field) *word64Slice { + return (*word64Slice)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} diff --git a/vendor/github.com/golang/protobuf/proto/properties.go b/vendor/github.com/golang/protobuf/proto/properties.go new file mode 100644 index 0000000000..4fe2ec22e8 --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/properties.go @@ -0,0 +1,846 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +/* + * Routines for encoding data into the wire format for protocol buffers. + */ + +import ( + "fmt" + "log" + "os" + "reflect" + "sort" + "strconv" + "strings" + "sync" +) + +const debug bool = false + +// Constants that identify the encoding of a value on the wire. +const ( + WireVarint = 0 + WireFixed64 = 1 + WireBytes = 2 + WireStartGroup = 3 + WireEndGroup = 4 + WireFixed32 = 5 +) + +const startSize = 10 // initial slice/string sizes + +// Encoders are defined in encode.go +// An encoder outputs the full representation of a field, including its +// tag and encoder type. +type encoder func(p *Buffer, prop *Properties, base structPointer) error + +// A valueEncoder encodes a single integer in a particular encoding. +type valueEncoder func(o *Buffer, x uint64) error + +// Sizers are defined in encode.go +// A sizer returns the encoded size of a field, including its tag and encoder +// type. +type sizer func(prop *Properties, base structPointer) int + +// A valueSizer returns the encoded size of a single integer in a particular +// encoding. +type valueSizer func(x uint64) int + +// Decoders are defined in decode.go +// A decoder creates a value from its wire representation. +// Unrecognized subelements are saved in unrec. +type decoder func(p *Buffer, prop *Properties, base structPointer) error + +// A valueDecoder decodes a single integer in a particular encoding. +type valueDecoder func(o *Buffer) (x uint64, err error) + +// A oneofMarshaler does the marshaling for all oneof fields in a message. +type oneofMarshaler func(Message, *Buffer) error + +// A oneofUnmarshaler does the unmarshaling for a oneof field in a message. +type oneofUnmarshaler func(Message, int, int, *Buffer) (bool, error) + +// A oneofSizer does the sizing for all oneof fields in a message. +type oneofSizer func(Message) int + +// tagMap is an optimization over map[int]int for typical protocol buffer +// use-cases. Encoded protocol buffers are often in tag order with small tag +// numbers. +type tagMap struct { + fastTags []int + slowTags map[int]int +} + +// tagMapFastLimit is the upper bound on the tag number that will be stored in +// the tagMap slice rather than its map. +const tagMapFastLimit = 1024 + +func (p *tagMap) get(t int) (int, bool) { + if t > 0 && t < tagMapFastLimit { + if t >= len(p.fastTags) { + return 0, false + } + fi := p.fastTags[t] + return fi, fi >= 0 + } + fi, ok := p.slowTags[t] + return fi, ok +} + +func (p *tagMap) put(t int, fi int) { + if t > 0 && t < tagMapFastLimit { + for len(p.fastTags) < t+1 { + p.fastTags = append(p.fastTags, -1) + } + p.fastTags[t] = fi + return + } + if p.slowTags == nil { + p.slowTags = make(map[int]int) + } + p.slowTags[t] = fi +} + +// StructProperties represents properties for all the fields of a struct. +// decoderTags and decoderOrigNames should only be used by the decoder. +type StructProperties struct { + Prop []*Properties // properties for each field + reqCount int // required count + decoderTags tagMap // map from proto tag to struct field number + decoderOrigNames map[string]int // map from original name to struct field number + order []int // list of struct field numbers in tag order + unrecField field // field id of the XXX_unrecognized []byte field + extendable bool // is this an extendable proto + + oneofMarshaler oneofMarshaler + oneofUnmarshaler oneofUnmarshaler + oneofSizer oneofSizer + stype reflect.Type + + // OneofTypes contains information about the oneof fields in this message. + // It is keyed by the original name of a field. + OneofTypes map[string]*OneofProperties +} + +// OneofProperties represents information about a specific field in a oneof. +type OneofProperties struct { + Type reflect.Type // pointer to generated struct type for this oneof field + Field int // struct field number of the containing oneof in the message + Prop *Properties +} + +// Implement the sorting interface so we can sort the fields in tag order, as recommended by the spec. +// See encode.go, (*Buffer).enc_struct. + +func (sp *StructProperties) Len() int { return len(sp.order) } +func (sp *StructProperties) Less(i, j int) bool { + return sp.Prop[sp.order[i]].Tag < sp.Prop[sp.order[j]].Tag +} +func (sp *StructProperties) Swap(i, j int) { sp.order[i], sp.order[j] = sp.order[j], sp.order[i] } + +// Properties represents the protocol-specific behavior of a single struct field. +type Properties struct { + Name string // name of the field, for error messages + OrigName string // original name before protocol compiler (always set) + JSONName string // name to use for JSON; determined by protoc + Wire string + WireType int + Tag int + Required bool + Optional bool + Repeated bool + Packed bool // relevant for repeated primitives only + Enum string // set for enum types only + proto3 bool // whether this is known to be a proto3 field; set for []byte only + oneof bool // whether this is a oneof field + + Default string // default value + HasDefault bool // whether an explicit default was provided + def_uint64 uint64 + + enc encoder + valEnc valueEncoder // set for bool and numeric types only + field field + tagcode []byte // encoding of EncodeVarint((Tag<<3)|WireType) + tagbuf [8]byte + stype reflect.Type // set for struct types only + sprop *StructProperties // set for struct types only + isMarshaler bool + isUnmarshaler bool + + mtype reflect.Type // set for map types only + mkeyprop *Properties // set for map types only + mvalprop *Properties // set for map types only + + size sizer + valSize valueSizer // set for bool and numeric types only + + dec decoder + valDec valueDecoder // set for bool and numeric types only + + // If this is a packable field, this will be the decoder for the packed version of the field. + packedDec decoder +} + +// String formats the properties in the protobuf struct field tag style. +func (p *Properties) String() string { + s := p.Wire + s = "," + s += strconv.Itoa(p.Tag) + if p.Required { + s += ",req" + } + if p.Optional { + s += ",opt" + } + if p.Repeated { + s += ",rep" + } + if p.Packed { + s += ",packed" + } + s += ",name=" + p.OrigName + if p.JSONName != p.OrigName { + s += ",json=" + p.JSONName + } + if p.proto3 { + s += ",proto3" + } + if p.oneof { + s += ",oneof" + } + if len(p.Enum) > 0 { + s += ",enum=" + p.Enum + } + if p.HasDefault { + s += ",def=" + p.Default + } + return s +} + +// Parse populates p by parsing a string in the protobuf struct field tag style. +func (p *Properties) Parse(s string) { + // "bytes,49,opt,name=foo,def=hello!" + fields := strings.Split(s, ",") // breaks def=, but handled below. + if len(fields) < 2 { + fmt.Fprintf(os.Stderr, "proto: tag has too few fields: %q\n", s) + return + } + + p.Wire = fields[0] + switch p.Wire { + case "varint": + p.WireType = WireVarint + p.valEnc = (*Buffer).EncodeVarint + p.valDec = (*Buffer).DecodeVarint + p.valSize = sizeVarint + case "fixed32": + p.WireType = WireFixed32 + p.valEnc = (*Buffer).EncodeFixed32 + p.valDec = (*Buffer).DecodeFixed32 + p.valSize = sizeFixed32 + case "fixed64": + p.WireType = WireFixed64 + p.valEnc = (*Buffer).EncodeFixed64 + p.valDec = (*Buffer).DecodeFixed64 + p.valSize = sizeFixed64 + case "zigzag32": + p.WireType = WireVarint + p.valEnc = (*Buffer).EncodeZigzag32 + p.valDec = (*Buffer).DecodeZigzag32 + p.valSize = sizeZigzag32 + case "zigzag64": + p.WireType = WireVarint + p.valEnc = (*Buffer).EncodeZigzag64 + p.valDec = (*Buffer).DecodeZigzag64 + p.valSize = sizeZigzag64 + case "bytes", "group": + p.WireType = WireBytes + // no numeric converter for non-numeric types + default: + fmt.Fprintf(os.Stderr, "proto: tag has unknown wire type: %q\n", s) + return + } + + var err error + p.Tag, err = strconv.Atoi(fields[1]) + if err != nil { + return + } + + for i := 2; i < len(fields); i++ { + f := fields[i] + switch { + case f == "req": + p.Required = true + case f == "opt": + p.Optional = true + case f == "rep": + p.Repeated = true + case f == "packed": + p.Packed = true + case strings.HasPrefix(f, "name="): + p.OrigName = f[5:] + case strings.HasPrefix(f, "json="): + p.JSONName = f[5:] + case strings.HasPrefix(f, "enum="): + p.Enum = f[5:] + case f == "proto3": + p.proto3 = true + case f == "oneof": + p.oneof = true + case strings.HasPrefix(f, "def="): + p.HasDefault = true + p.Default = f[4:] // rest of string + if i+1 < len(fields) { + // Commas aren't escaped, and def is always last. + p.Default += "," + strings.Join(fields[i+1:], ",") + break + } + } + } +} + +func logNoSliceEnc(t1, t2 reflect.Type) { + fmt.Fprintf(os.Stderr, "proto: no slice oenc for %T = []%T\n", t1, t2) +} + +var protoMessageType = reflect.TypeOf((*Message)(nil)).Elem() + +// Initialize the fields for encoding and decoding. +func (p *Properties) setEncAndDec(typ reflect.Type, f *reflect.StructField, lockGetProp bool) { + p.enc = nil + p.dec = nil + p.size = nil + + switch t1 := typ; t1.Kind() { + default: + fmt.Fprintf(os.Stderr, "proto: no coders for %v\n", t1) + + // proto3 scalar types + + case reflect.Bool: + p.enc = (*Buffer).enc_proto3_bool + p.dec = (*Buffer).dec_proto3_bool + p.size = size_proto3_bool + case reflect.Int32: + p.enc = (*Buffer).enc_proto3_int32 + p.dec = (*Buffer).dec_proto3_int32 + p.size = size_proto3_int32 + case reflect.Uint32: + p.enc = (*Buffer).enc_proto3_uint32 + p.dec = (*Buffer).dec_proto3_int32 // can reuse + p.size = size_proto3_uint32 + case reflect.Int64, reflect.Uint64: + p.enc = (*Buffer).enc_proto3_int64 + p.dec = (*Buffer).dec_proto3_int64 + p.size = size_proto3_int64 + case reflect.Float32: + p.enc = (*Buffer).enc_proto3_uint32 // can just treat them as bits + p.dec = (*Buffer).dec_proto3_int32 + p.size = size_proto3_uint32 + case reflect.Float64: + p.enc = (*Buffer).enc_proto3_int64 // can just treat them as bits + p.dec = (*Buffer).dec_proto3_int64 + p.size = size_proto3_int64 + case reflect.String: + p.enc = (*Buffer).enc_proto3_string + p.dec = (*Buffer).dec_proto3_string + p.size = size_proto3_string + + case reflect.Ptr: + switch t2 := t1.Elem(); t2.Kind() { + default: + fmt.Fprintf(os.Stderr, "proto: no encoder function for %v -> %v\n", t1, t2) + break + case reflect.Bool: + p.enc = (*Buffer).enc_bool + p.dec = (*Buffer).dec_bool + p.size = size_bool + case reflect.Int32: + p.enc = (*Buffer).enc_int32 + p.dec = (*Buffer).dec_int32 + p.size = size_int32 + case reflect.Uint32: + p.enc = (*Buffer).enc_uint32 + p.dec = (*Buffer).dec_int32 // can reuse + p.size = size_uint32 + case reflect.Int64, reflect.Uint64: + p.enc = (*Buffer).enc_int64 + p.dec = (*Buffer).dec_int64 + p.size = size_int64 + case reflect.Float32: + p.enc = (*Buffer).enc_uint32 // can just treat them as bits + p.dec = (*Buffer).dec_int32 + p.size = size_uint32 + case reflect.Float64: + p.enc = (*Buffer).enc_int64 // can just treat them as bits + p.dec = (*Buffer).dec_int64 + p.size = size_int64 + case reflect.String: + p.enc = (*Buffer).enc_string + p.dec = (*Buffer).dec_string + p.size = size_string + case reflect.Struct: + p.stype = t1.Elem() + p.isMarshaler = isMarshaler(t1) + p.isUnmarshaler = isUnmarshaler(t1) + if p.Wire == "bytes" { + p.enc = (*Buffer).enc_struct_message + p.dec = (*Buffer).dec_struct_message + p.size = size_struct_message + } else { + p.enc = (*Buffer).enc_struct_group + p.dec = (*Buffer).dec_struct_group + p.size = size_struct_group + } + } + + case reflect.Slice: + switch t2 := t1.Elem(); t2.Kind() { + default: + logNoSliceEnc(t1, t2) + break + case reflect.Bool: + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_bool + p.size = size_slice_packed_bool + } else { + p.enc = (*Buffer).enc_slice_bool + p.size = size_slice_bool + } + p.dec = (*Buffer).dec_slice_bool + p.packedDec = (*Buffer).dec_slice_packed_bool + case reflect.Int32: + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_int32 + p.size = size_slice_packed_int32 + } else { + p.enc = (*Buffer).enc_slice_int32 + p.size = size_slice_int32 + } + p.dec = (*Buffer).dec_slice_int32 + p.packedDec = (*Buffer).dec_slice_packed_int32 + case reflect.Uint32: + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_uint32 + p.size = size_slice_packed_uint32 + } else { + p.enc = (*Buffer).enc_slice_uint32 + p.size = size_slice_uint32 + } + p.dec = (*Buffer).dec_slice_int32 + p.packedDec = (*Buffer).dec_slice_packed_int32 + case reflect.Int64, reflect.Uint64: + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_int64 + p.size = size_slice_packed_int64 + } else { + p.enc = (*Buffer).enc_slice_int64 + p.size = size_slice_int64 + } + p.dec = (*Buffer).dec_slice_int64 + p.packedDec = (*Buffer).dec_slice_packed_int64 + case reflect.Uint8: + p.enc = (*Buffer).enc_slice_byte + p.dec = (*Buffer).dec_slice_byte + p.size = size_slice_byte + // This is a []byte, which is either a bytes field, + // or the value of a map field. In the latter case, + // we always encode an empty []byte, so we should not + // use the proto3 enc/size funcs. + // f == nil iff this is the key/value of a map field. + if p.proto3 && f != nil { + p.enc = (*Buffer).enc_proto3_slice_byte + p.size = size_proto3_slice_byte + } + case reflect.Float32, reflect.Float64: + switch t2.Bits() { + case 32: + // can just treat them as bits + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_uint32 + p.size = size_slice_packed_uint32 + } else { + p.enc = (*Buffer).enc_slice_uint32 + p.size = size_slice_uint32 + } + p.dec = (*Buffer).dec_slice_int32 + p.packedDec = (*Buffer).dec_slice_packed_int32 + case 64: + // can just treat them as bits + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_int64 + p.size = size_slice_packed_int64 + } else { + p.enc = (*Buffer).enc_slice_int64 + p.size = size_slice_int64 + } + p.dec = (*Buffer).dec_slice_int64 + p.packedDec = (*Buffer).dec_slice_packed_int64 + default: + logNoSliceEnc(t1, t2) + break + } + case reflect.String: + p.enc = (*Buffer).enc_slice_string + p.dec = (*Buffer).dec_slice_string + p.size = size_slice_string + case reflect.Ptr: + switch t3 := t2.Elem(); t3.Kind() { + default: + fmt.Fprintf(os.Stderr, "proto: no ptr oenc for %T -> %T -> %T\n", t1, t2, t3) + break + case reflect.Struct: + p.stype = t2.Elem() + p.isMarshaler = isMarshaler(t2) + p.isUnmarshaler = isUnmarshaler(t2) + if p.Wire == "bytes" { + p.enc = (*Buffer).enc_slice_struct_message + p.dec = (*Buffer).dec_slice_struct_message + p.size = size_slice_struct_message + } else { + p.enc = (*Buffer).enc_slice_struct_group + p.dec = (*Buffer).dec_slice_struct_group + p.size = size_slice_struct_group + } + } + case reflect.Slice: + switch t2.Elem().Kind() { + default: + fmt.Fprintf(os.Stderr, "proto: no slice elem oenc for %T -> %T -> %T\n", t1, t2, t2.Elem()) + break + case reflect.Uint8: + p.enc = (*Buffer).enc_slice_slice_byte + p.dec = (*Buffer).dec_slice_slice_byte + p.size = size_slice_slice_byte + } + } + + case reflect.Map: + p.enc = (*Buffer).enc_new_map + p.dec = (*Buffer).dec_new_map + p.size = size_new_map + + p.mtype = t1 + p.mkeyprop = &Properties{} + p.mkeyprop.init(reflect.PtrTo(p.mtype.Key()), "Key", f.Tag.Get("protobuf_key"), nil, lockGetProp) + p.mvalprop = &Properties{} + vtype := p.mtype.Elem() + if vtype.Kind() != reflect.Ptr && vtype.Kind() != reflect.Slice { + // The value type is not a message (*T) or bytes ([]byte), + // so we need encoders for the pointer to this type. + vtype = reflect.PtrTo(vtype) + } + p.mvalprop.init(vtype, "Value", f.Tag.Get("protobuf_val"), nil, lockGetProp) + } + + // precalculate tag code + wire := p.WireType + if p.Packed { + wire = WireBytes + } + x := uint32(p.Tag)<<3 | uint32(wire) + i := 0 + for i = 0; x > 127; i++ { + p.tagbuf[i] = 0x80 | uint8(x&0x7F) + x >>= 7 + } + p.tagbuf[i] = uint8(x) + p.tagcode = p.tagbuf[0 : i+1] + + if p.stype != nil { + if lockGetProp { + p.sprop = GetProperties(p.stype) + } else { + p.sprop = getPropertiesLocked(p.stype) + } + } +} + +var ( + marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem() + unmarshalerType = reflect.TypeOf((*Unmarshaler)(nil)).Elem() +) + +// isMarshaler reports whether type t implements Marshaler. +func isMarshaler(t reflect.Type) bool { + // We're checking for (likely) pointer-receiver methods + // so if t is not a pointer, something is very wrong. + // The calls above only invoke isMarshaler on pointer types. + if t.Kind() != reflect.Ptr { + panic("proto: misuse of isMarshaler") + } + return t.Implements(marshalerType) +} + +// isUnmarshaler reports whether type t implements Unmarshaler. +func isUnmarshaler(t reflect.Type) bool { + // We're checking for (likely) pointer-receiver methods + // so if t is not a pointer, something is very wrong. + // The calls above only invoke isUnmarshaler on pointer types. + if t.Kind() != reflect.Ptr { + panic("proto: misuse of isUnmarshaler") + } + return t.Implements(unmarshalerType) +} + +// Init populates the properties from a protocol buffer struct tag. +func (p *Properties) Init(typ reflect.Type, name, tag string, f *reflect.StructField) { + p.init(typ, name, tag, f, true) +} + +func (p *Properties) init(typ reflect.Type, name, tag string, f *reflect.StructField, lockGetProp bool) { + // "bytes,49,opt,def=hello!" + p.Name = name + p.OrigName = name + if f != nil { + p.field = toField(f) + } + if tag == "" { + return + } + p.Parse(tag) + p.setEncAndDec(typ, f, lockGetProp) +} + +var ( + propertiesMu sync.RWMutex + propertiesMap = make(map[reflect.Type]*StructProperties) +) + +// GetProperties returns the list of properties for the type represented by t. +// t must represent a generated struct type of a protocol message. +func GetProperties(t reflect.Type) *StructProperties { + if t.Kind() != reflect.Struct { + panic("proto: type must have kind struct") + } + + // Most calls to GetProperties in a long-running program will be + // retrieving details for types we have seen before. + propertiesMu.RLock() + sprop, ok := propertiesMap[t] + propertiesMu.RUnlock() + if ok { + if collectStats { + stats.Chit++ + } + return sprop + } + + propertiesMu.Lock() + sprop = getPropertiesLocked(t) + propertiesMu.Unlock() + return sprop +} + +// getPropertiesLocked requires that propertiesMu is held. +func getPropertiesLocked(t reflect.Type) *StructProperties { + if prop, ok := propertiesMap[t]; ok { + if collectStats { + stats.Chit++ + } + return prop + } + if collectStats { + stats.Cmiss++ + } + + prop := new(StructProperties) + // in case of recursive protos, fill this in now. + propertiesMap[t] = prop + + // build properties + prop.extendable = reflect.PtrTo(t).Implements(extendableProtoType) + prop.unrecField = invalidField + prop.Prop = make([]*Properties, t.NumField()) + prop.order = make([]int, t.NumField()) + + for i := 0; i < t.NumField(); i++ { + f := t.Field(i) + p := new(Properties) + name := f.Name + p.init(f.Type, name, f.Tag.Get("protobuf"), &f, false) + + if f.Name == "XXX_extensions" { // special case + p.enc = (*Buffer).enc_map + p.dec = nil // not needed + p.size = size_map + } + if f.Name == "XXX_unrecognized" { // special case + prop.unrecField = toField(&f) + } + oneof := f.Tag.Get("protobuf_oneof") != "" // special case + prop.Prop[i] = p + prop.order[i] = i + if debug { + print(i, " ", f.Name, " ", t.String(), " ") + if p.Tag > 0 { + print(p.String()) + } + print("\n") + } + if p.enc == nil && !strings.HasPrefix(f.Name, "XXX_") && !oneof { + fmt.Fprintln(os.Stderr, "proto: no encoder for", f.Name, f.Type.String(), "[GetProperties]") + } + } + + // Re-order prop.order. + sort.Sort(prop) + + type oneofMessage interface { + XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{}) + } + if om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); ok { + var oots []interface{} + prop.oneofMarshaler, prop.oneofUnmarshaler, prop.oneofSizer, oots = om.XXX_OneofFuncs() + prop.stype = t + + // Interpret oneof metadata. + prop.OneofTypes = make(map[string]*OneofProperties) + for _, oot := range oots { + oop := &OneofProperties{ + Type: reflect.ValueOf(oot).Type(), // *T + Prop: new(Properties), + } + sft := oop.Type.Elem().Field(0) + oop.Prop.Name = sft.Name + oop.Prop.Parse(sft.Tag.Get("protobuf")) + // There will be exactly one interface field that + // this new value is assignable to. + for i := 0; i < t.NumField(); i++ { + f := t.Field(i) + if f.Type.Kind() != reflect.Interface { + continue + } + if !oop.Type.AssignableTo(f.Type) { + continue + } + oop.Field = i + break + } + prop.OneofTypes[oop.Prop.OrigName] = oop + } + } + + // build required counts + // build tags + reqCount := 0 + prop.decoderOrigNames = make(map[string]int) + for i, p := range prop.Prop { + if strings.HasPrefix(p.Name, "XXX_") { + // Internal fields should not appear in tags/origNames maps. + // They are handled specially when encoding and decoding. + continue + } + if p.Required { + reqCount++ + } + prop.decoderTags.put(p.Tag, i) + prop.decoderOrigNames[p.OrigName] = i + } + prop.reqCount = reqCount + + return prop +} + +// Return the Properties object for the x[0]'th field of the structure. +func propByIndex(t reflect.Type, x []int) *Properties { + if len(x) != 1 { + fmt.Fprintf(os.Stderr, "proto: field index dimension %d (not 1) for type %s\n", len(x), t) + return nil + } + prop := GetProperties(t) + return prop.Prop[x[0]] +} + +// Get the address and type of a pointer to a struct from an interface. +func getbase(pb Message) (t reflect.Type, b structPointer, err error) { + if pb == nil { + err = ErrNil + return + } + // get the reflect type of the pointer to the struct. + t = reflect.TypeOf(pb) + // get the address of the struct. + value := reflect.ValueOf(pb) + b = toStructPointer(value) + return +} + +// A global registry of enum types. +// The generated code will register the generated maps by calling RegisterEnum. + +var enumValueMaps = make(map[string]map[string]int32) + +// RegisterEnum is called from the generated code to install the enum descriptor +// maps into the global table to aid parsing text format protocol buffers. +func RegisterEnum(typeName string, unusedNameMap map[int32]string, valueMap map[string]int32) { + if _, ok := enumValueMaps[typeName]; ok { + panic("proto: duplicate enum registered: " + typeName) + } + enumValueMaps[typeName] = valueMap +} + +// EnumValueMap returns the mapping from names to integers of the +// enum type enumType, or a nil if not found. +func EnumValueMap(enumType string) map[string]int32 { + return enumValueMaps[enumType] +} + +// A registry of all linked message types. +// The string is a fully-qualified proto name ("pkg.Message"). +var ( + protoTypes = make(map[string]reflect.Type) + revProtoTypes = make(map[reflect.Type]string) +) + +// RegisterType is called from generated code and maps from the fully qualified +// proto name to the type (pointer to struct) of the protocol buffer. +func RegisterType(x Message, name string) { + if _, ok := protoTypes[name]; ok { + // TODO: Some day, make this a panic. + log.Printf("proto: duplicate proto type registered: %s", name) + return + } + t := reflect.TypeOf(x) + protoTypes[name] = t + revProtoTypes[t] = name +} + +// MessageName returns the fully-qualified proto name for the given message type. +func MessageName(x Message) string { return revProtoTypes[reflect.TypeOf(x)] } + +// MessageType returns the message type (pointer to struct) for a named message. +func MessageType(name string) reflect.Type { return protoTypes[name] } diff --git a/vendor/github.com/golang/protobuf/proto/text.go b/vendor/github.com/golang/protobuf/proto/text.go new file mode 100644 index 0000000000..1cbaf86d39 --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/text.go @@ -0,0 +1,762 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +// Functions for writing the text protocol buffer format. + +import ( + "bufio" + "bytes" + "encoding" + "errors" + "fmt" + "io" + "log" + "math" + "reflect" + "sort" + "strings" +) + +var ( + newline = []byte("\n") + spaces = []byte(" ") + gtNewline = []byte(">\n") + endBraceNewline = []byte("}\n") + backslashN = []byte{'\\', 'n'} + backslashR = []byte{'\\', 'r'} + backslashT = []byte{'\\', 't'} + backslashDQ = []byte{'\\', '"'} + backslashBS = []byte{'\\', '\\'} + posInf = []byte("inf") + negInf = []byte("-inf") + nan = []byte("nan") +) + +type writer interface { + io.Writer + WriteByte(byte) error +} + +// textWriter is an io.Writer that tracks its indentation level. +type textWriter struct { + ind int + complete bool // if the current position is a complete line + compact bool // whether to write out as a one-liner + w writer +} + +func (w *textWriter) WriteString(s string) (n int, err error) { + if !strings.Contains(s, "\n") { + if !w.compact && w.complete { + w.writeIndent() + } + w.complete = false + return io.WriteString(w.w, s) + } + // WriteString is typically called without newlines, so this + // codepath and its copy are rare. We copy to avoid + // duplicating all of Write's logic here. + return w.Write([]byte(s)) +} + +func (w *textWriter) Write(p []byte) (n int, err error) { + newlines := bytes.Count(p, newline) + if newlines == 0 { + if !w.compact && w.complete { + w.writeIndent() + } + n, err = w.w.Write(p) + w.complete = false + return n, err + } + + frags := bytes.SplitN(p, newline, newlines+1) + if w.compact { + for i, frag := range frags { + if i > 0 { + if err := w.w.WriteByte(' '); err != nil { + return n, err + } + n++ + } + nn, err := w.w.Write(frag) + n += nn + if err != nil { + return n, err + } + } + return n, nil + } + + for i, frag := range frags { + if w.complete { + w.writeIndent() + } + nn, err := w.w.Write(frag) + n += nn + if err != nil { + return n, err + } + if i+1 < len(frags) { + if err := w.w.WriteByte('\n'); err != nil { + return n, err + } + n++ + } + } + w.complete = len(frags[len(frags)-1]) == 0 + return n, nil +} + +func (w *textWriter) WriteByte(c byte) error { + if w.compact && c == '\n' { + c = ' ' + } + if !w.compact && w.complete { + w.writeIndent() + } + err := w.w.WriteByte(c) + w.complete = c == '\n' + return err +} + +func (w *textWriter) indent() { w.ind++ } + +func (w *textWriter) unindent() { + if w.ind == 0 { + log.Printf("proto: textWriter unindented too far") + return + } + w.ind-- +} + +func writeName(w *textWriter, props *Properties) error { + if _, err := w.WriteString(props.OrigName); err != nil { + return err + } + if props.Wire != "group" { + return w.WriteByte(':') + } + return nil +} + +// raw is the interface satisfied by RawMessage. +type raw interface { + Bytes() []byte +} + +func writeStruct(w *textWriter, sv reflect.Value) error { + st := sv.Type() + sprops := GetProperties(st) + for i := 0; i < sv.NumField(); i++ { + fv := sv.Field(i) + props := sprops.Prop[i] + name := st.Field(i).Name + + if strings.HasPrefix(name, "XXX_") { + // There are two XXX_ fields: + // XXX_unrecognized []byte + // XXX_extensions map[int32]proto.Extension + // The first is handled here; + // the second is handled at the bottom of this function. + if name == "XXX_unrecognized" && !fv.IsNil() { + if err := writeUnknownStruct(w, fv.Interface().([]byte)); err != nil { + return err + } + } + continue + } + if fv.Kind() == reflect.Ptr && fv.IsNil() { + // Field not filled in. This could be an optional field or + // a required field that wasn't filled in. Either way, there + // isn't anything we can show for it. + continue + } + if fv.Kind() == reflect.Slice && fv.IsNil() { + // Repeated field that is empty, or a bytes field that is unused. + continue + } + + if props.Repeated && fv.Kind() == reflect.Slice { + // Repeated field. + for j := 0; j < fv.Len(); j++ { + if err := writeName(w, props); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + v := fv.Index(j) + if v.Kind() == reflect.Ptr && v.IsNil() { + // A nil message in a repeated field is not valid, + // but we can handle that more gracefully than panicking. + if _, err := w.Write([]byte("\n")); err != nil { + return err + } + continue + } + if err := writeAny(w, v, props); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + } + continue + } + if fv.Kind() == reflect.Map { + // Map fields are rendered as a repeated struct with key/value fields. + keys := fv.MapKeys() + sort.Sort(mapKeys(keys)) + for _, key := range keys { + val := fv.MapIndex(key) + if err := writeName(w, props); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + // open struct + if err := w.WriteByte('<'); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte('\n'); err != nil { + return err + } + } + w.indent() + // key + if _, err := w.WriteString("key:"); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + if err := writeAny(w, key, props.mkeyprop); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + // nil values aren't legal, but we can avoid panicking because of them. + if val.Kind() != reflect.Ptr || !val.IsNil() { + // value + if _, err := w.WriteString("value:"); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + if err := writeAny(w, val, props.mvalprop); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + } + // close struct + w.unindent() + if err := w.WriteByte('>'); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + } + continue + } + if props.proto3 && fv.Kind() == reflect.Slice && fv.Len() == 0 { + // empty bytes field + continue + } + if fv.Kind() != reflect.Ptr && fv.Kind() != reflect.Slice { + // proto3 non-repeated scalar field; skip if zero value + if isProto3Zero(fv) { + continue + } + } + + if fv.Kind() == reflect.Interface { + // Check if it is a oneof. + if st.Field(i).Tag.Get("protobuf_oneof") != "" { + // fv is nil, or holds a pointer to generated struct. + // That generated struct has exactly one field, + // which has a protobuf struct tag. + if fv.IsNil() { + continue + } + inner := fv.Elem().Elem() // interface -> *T -> T + tag := inner.Type().Field(0).Tag.Get("protobuf") + props = new(Properties) // Overwrite the outer props var, but not its pointee. + props.Parse(tag) + // Write the value in the oneof, not the oneof itself. + fv = inner.Field(0) + + // Special case to cope with malformed messages gracefully: + // If the value in the oneof is a nil pointer, don't panic + // in writeAny. + if fv.Kind() == reflect.Ptr && fv.IsNil() { + // Use errors.New so writeAny won't render quotes. + msg := errors.New("/* nil */") + fv = reflect.ValueOf(&msg).Elem() + } + } + } + + if err := writeName(w, props); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + if b, ok := fv.Interface().(raw); ok { + if err := writeRaw(w, b.Bytes()); err != nil { + return err + } + continue + } + + // Enums have a String method, so writeAny will work fine. + if err := writeAny(w, fv, props); err != nil { + return err + } + + if err := w.WriteByte('\n'); err != nil { + return err + } + } + + // Extensions (the XXX_extensions field). + pv := sv.Addr() + if pv.Type().Implements(extendableProtoType) { + if err := writeExtensions(w, pv); err != nil { + return err + } + } + + return nil +} + +// writeRaw writes an uninterpreted raw message. +func writeRaw(w *textWriter, b []byte) error { + if err := w.WriteByte('<'); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte('\n'); err != nil { + return err + } + } + w.indent() + if err := writeUnknownStruct(w, b); err != nil { + return err + } + w.unindent() + if err := w.WriteByte('>'); err != nil { + return err + } + return nil +} + +// writeAny writes an arbitrary field. +func writeAny(w *textWriter, v reflect.Value, props *Properties) error { + v = reflect.Indirect(v) + + // Floats have special cases. + if v.Kind() == reflect.Float32 || v.Kind() == reflect.Float64 { + x := v.Float() + var b []byte + switch { + case math.IsInf(x, 1): + b = posInf + case math.IsInf(x, -1): + b = negInf + case math.IsNaN(x): + b = nan + } + if b != nil { + _, err := w.Write(b) + return err + } + // Other values are handled below. + } + + // We don't attempt to serialise every possible value type; only those + // that can occur in protocol buffers. + switch v.Kind() { + case reflect.Slice: + // Should only be a []byte; repeated fields are handled in writeStruct. + if err := writeString(w, string(v.Interface().([]byte))); err != nil { + return err + } + case reflect.String: + if err := writeString(w, v.String()); err != nil { + return err + } + case reflect.Struct: + // Required/optional group/message. + var bra, ket byte = '<', '>' + if props != nil && props.Wire == "group" { + bra, ket = '{', '}' + } + if err := w.WriteByte(bra); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte('\n'); err != nil { + return err + } + } + w.indent() + if tm, ok := v.Interface().(encoding.TextMarshaler); ok { + text, err := tm.MarshalText() + if err != nil { + return err + } + if _, err = w.Write(text); err != nil { + return err + } + } else if err := writeStruct(w, v); err != nil { + return err + } + w.unindent() + if err := w.WriteByte(ket); err != nil { + return err + } + default: + _, err := fmt.Fprint(w, v.Interface()) + return err + } + return nil +} + +// equivalent to C's isprint. +func isprint(c byte) bool { + return c >= 0x20 && c < 0x7f +} + +// writeString writes a string in the protocol buffer text format. +// It is similar to strconv.Quote except we don't use Go escape sequences, +// we treat the string as a byte sequence, and we use octal escapes. +// These differences are to maintain interoperability with the other +// languages' implementations of the text format. +func writeString(w *textWriter, s string) error { + // use WriteByte here to get any needed indent + if err := w.WriteByte('"'); err != nil { + return err + } + // Loop over the bytes, not the runes. + for i := 0; i < len(s); i++ { + var err error + // Divergence from C++: we don't escape apostrophes. + // There's no need to escape them, and the C++ parser + // copes with a naked apostrophe. + switch c := s[i]; c { + case '\n': + _, err = w.w.Write(backslashN) + case '\r': + _, err = w.w.Write(backslashR) + case '\t': + _, err = w.w.Write(backslashT) + case '"': + _, err = w.w.Write(backslashDQ) + case '\\': + _, err = w.w.Write(backslashBS) + default: + if isprint(c) { + err = w.w.WriteByte(c) + } else { + _, err = fmt.Fprintf(w.w, "\\%03o", c) + } + } + if err != nil { + return err + } + } + return w.WriteByte('"') +} + +func writeUnknownStruct(w *textWriter, data []byte) (err error) { + if !w.compact { + if _, err := fmt.Fprintf(w, "/* %d unknown bytes */\n", len(data)); err != nil { + return err + } + } + b := NewBuffer(data) + for b.index < len(b.buf) { + x, err := b.DecodeVarint() + if err != nil { + _, err := fmt.Fprintf(w, "/* %v */\n", err) + return err + } + wire, tag := x&7, x>>3 + if wire == WireEndGroup { + w.unindent() + if _, err := w.Write(endBraceNewline); err != nil { + return err + } + continue + } + if _, err := fmt.Fprint(w, tag); err != nil { + return err + } + if wire != WireStartGroup { + if err := w.WriteByte(':'); err != nil { + return err + } + } + if !w.compact || wire == WireStartGroup { + if err := w.WriteByte(' '); err != nil { + return err + } + } + switch wire { + case WireBytes: + buf, e := b.DecodeRawBytes(false) + if e == nil { + _, err = fmt.Fprintf(w, "%q", buf) + } else { + _, err = fmt.Fprintf(w, "/* %v */", e) + } + case WireFixed32: + x, err = b.DecodeFixed32() + err = writeUnknownInt(w, x, err) + case WireFixed64: + x, err = b.DecodeFixed64() + err = writeUnknownInt(w, x, err) + case WireStartGroup: + err = w.WriteByte('{') + w.indent() + case WireVarint: + x, err = b.DecodeVarint() + err = writeUnknownInt(w, x, err) + default: + _, err = fmt.Fprintf(w, "/* unknown wire type %d */", wire) + } + if err != nil { + return err + } + if err = w.WriteByte('\n'); err != nil { + return err + } + } + return nil +} + +func writeUnknownInt(w *textWriter, x uint64, err error) error { + if err == nil { + _, err = fmt.Fprint(w, x) + } else { + _, err = fmt.Fprintf(w, "/* %v */", err) + } + return err +} + +type int32Slice []int32 + +func (s int32Slice) Len() int { return len(s) } +func (s int32Slice) Less(i, j int) bool { return s[i] < s[j] } +func (s int32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + +// writeExtensions writes all the extensions in pv. +// pv is assumed to be a pointer to a protocol message struct that is extendable. +func writeExtensions(w *textWriter, pv reflect.Value) error { + emap := extensionMaps[pv.Type().Elem()] + ep := pv.Interface().(extendableProto) + + // Order the extensions by ID. + // This isn't strictly necessary, but it will give us + // canonical output, which will also make testing easier. + m := ep.ExtensionMap() + ids := make([]int32, 0, len(m)) + for id := range m { + ids = append(ids, id) + } + sort.Sort(int32Slice(ids)) + + for _, extNum := range ids { + ext := m[extNum] + var desc *ExtensionDesc + if emap != nil { + desc = emap[extNum] + } + if desc == nil { + // Unknown extension. + if err := writeUnknownStruct(w, ext.enc); err != nil { + return err + } + continue + } + + pb, err := GetExtension(ep, desc) + if err != nil { + return fmt.Errorf("failed getting extension: %v", err) + } + + // Repeated extensions will appear as a slice. + if !desc.repeated() { + if err := writeExtension(w, desc.Name, pb); err != nil { + return err + } + } else { + v := reflect.ValueOf(pb) + for i := 0; i < v.Len(); i++ { + if err := writeExtension(w, desc.Name, v.Index(i).Interface()); err != nil { + return err + } + } + } + } + return nil +} + +func writeExtension(w *textWriter, name string, pb interface{}) error { + if _, err := fmt.Fprintf(w, "[%s]:", name); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + if err := writeAny(w, reflect.ValueOf(pb), nil); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + return nil +} + +func (w *textWriter) writeIndent() { + if !w.complete { + return + } + remain := w.ind * 2 + for remain > 0 { + n := remain + if n > len(spaces) { + n = len(spaces) + } + w.w.Write(spaces[:n]) + remain -= n + } + w.complete = false +} + +// TextMarshaler is a configurable text format marshaler. +type TextMarshaler struct { + Compact bool // use compact text format (one line). +} + +// Marshal writes a given protocol buffer in text format. +// The only errors returned are from w. +func (m *TextMarshaler) Marshal(w io.Writer, pb Message) error { + val := reflect.ValueOf(pb) + if pb == nil || val.IsNil() { + w.Write([]byte("")) + return nil + } + var bw *bufio.Writer + ww, ok := w.(writer) + if !ok { + bw = bufio.NewWriter(w) + ww = bw + } + aw := &textWriter{ + w: ww, + complete: true, + compact: m.Compact, + } + + if tm, ok := pb.(encoding.TextMarshaler); ok { + text, err := tm.MarshalText() + if err != nil { + return err + } + if _, err = aw.Write(text); err != nil { + return err + } + if bw != nil { + return bw.Flush() + } + return nil + } + // Dereference the received pointer so we don't have outer < and >. + v := reflect.Indirect(val) + if err := writeStruct(aw, v); err != nil { + return err + } + if bw != nil { + return bw.Flush() + } + return nil +} + +// Text is the same as Marshal, but returns the string directly. +func (m *TextMarshaler) Text(pb Message) string { + var buf bytes.Buffer + m.Marshal(&buf, pb) + return buf.String() +} + +var ( + defaultTextMarshaler = TextMarshaler{} + compactTextMarshaler = TextMarshaler{Compact: true} +) + +// TODO: consider removing some of the Marshal functions below. + +// MarshalText writes a given protocol buffer in text format. +// The only errors returned are from w. +func MarshalText(w io.Writer, pb Message) error { return defaultTextMarshaler.Marshal(w, pb) } + +// MarshalTextString is the same as MarshalText, but returns the string directly. +func MarshalTextString(pb Message) string { return defaultTextMarshaler.Text(pb) } + +// CompactText writes a given protocol buffer in compact text format (one line). +func CompactText(w io.Writer, pb Message) error { return compactTextMarshaler.Marshal(w, pb) } + +// CompactTextString is the same as CompactText, but returns the string directly. +func CompactTextString(pb Message) string { return compactTextMarshaler.Text(pb) } diff --git a/vendor/github.com/golang/protobuf/proto/text_parser.go b/vendor/github.com/golang/protobuf/proto/text_parser.go new file mode 100644 index 0000000000..451323262c --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/text_parser.go @@ -0,0 +1,806 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +// Functions for parsing the Text protocol buffer format. +// TODO: message sets. + +import ( + "encoding" + "errors" + "fmt" + "reflect" + "strconv" + "strings" + "unicode/utf8" +) + +type ParseError struct { + Message string + Line int // 1-based line number + Offset int // 0-based byte offset from start of input +} + +func (p *ParseError) Error() string { + if p.Line == 1 { + // show offset only for first line + return fmt.Sprintf("line 1.%d: %v", p.Offset, p.Message) + } + return fmt.Sprintf("line %d: %v", p.Line, p.Message) +} + +type token struct { + value string + err *ParseError + line int // line number + offset int // byte number from start of input, not start of line + unquoted string // the unquoted version of value, if it was a quoted string +} + +func (t *token) String() string { + if t.err == nil { + return fmt.Sprintf("%q (line=%d, offset=%d)", t.value, t.line, t.offset) + } + return fmt.Sprintf("parse error: %v", t.err) +} + +type textParser struct { + s string // remaining input + done bool // whether the parsing is finished (success or error) + backed bool // whether back() was called + offset, line int + cur token +} + +func newTextParser(s string) *textParser { + p := new(textParser) + p.s = s + p.line = 1 + p.cur.line = 1 + return p +} + +func (p *textParser) errorf(format string, a ...interface{}) *ParseError { + pe := &ParseError{fmt.Sprintf(format, a...), p.cur.line, p.cur.offset} + p.cur.err = pe + p.done = true + return pe +} + +// Numbers and identifiers are matched by [-+._A-Za-z0-9] +func isIdentOrNumberChar(c byte) bool { + switch { + case 'A' <= c && c <= 'Z', 'a' <= c && c <= 'z': + return true + case '0' <= c && c <= '9': + return true + } + switch c { + case '-', '+', '.', '_': + return true + } + return false +} + +func isWhitespace(c byte) bool { + switch c { + case ' ', '\t', '\n', '\r': + return true + } + return false +} + +func isQuote(c byte) bool { + switch c { + case '"', '\'': + return true + } + return false +} + +func (p *textParser) skipWhitespace() { + i := 0 + for i < len(p.s) && (isWhitespace(p.s[i]) || p.s[i] == '#') { + if p.s[i] == '#' { + // comment; skip to end of line or input + for i < len(p.s) && p.s[i] != '\n' { + i++ + } + if i == len(p.s) { + break + } + } + if p.s[i] == '\n' { + p.line++ + } + i++ + } + p.offset += i + p.s = p.s[i:len(p.s)] + if len(p.s) == 0 { + p.done = true + } +} + +func (p *textParser) advance() { + // Skip whitespace + p.skipWhitespace() + if p.done { + return + } + + // Start of non-whitespace + p.cur.err = nil + p.cur.offset, p.cur.line = p.offset, p.line + p.cur.unquoted = "" + switch p.s[0] { + case '<', '>', '{', '}', ':', '[', ']', ';', ',': + // Single symbol + p.cur.value, p.s = p.s[0:1], p.s[1:len(p.s)] + case '"', '\'': + // Quoted string + i := 1 + for i < len(p.s) && p.s[i] != p.s[0] && p.s[i] != '\n' { + if p.s[i] == '\\' && i+1 < len(p.s) { + // skip escaped char + i++ + } + i++ + } + if i >= len(p.s) || p.s[i] != p.s[0] { + p.errorf("unmatched quote") + return + } + unq, err := unquoteC(p.s[1:i], rune(p.s[0])) + if err != nil { + p.errorf("invalid quoted string %s: %v", p.s[0:i+1], err) + return + } + p.cur.value, p.s = p.s[0:i+1], p.s[i+1:len(p.s)] + p.cur.unquoted = unq + default: + i := 0 + for i < len(p.s) && isIdentOrNumberChar(p.s[i]) { + i++ + } + if i == 0 { + p.errorf("unexpected byte %#x", p.s[0]) + return + } + p.cur.value, p.s = p.s[0:i], p.s[i:len(p.s)] + } + p.offset += len(p.cur.value) +} + +var ( + errBadUTF8 = errors.New("proto: bad UTF-8") + errBadHex = errors.New("proto: bad hexadecimal") +) + +func unquoteC(s string, quote rune) (string, error) { + // This is based on C++'s tokenizer.cc. + // Despite its name, this is *not* parsing C syntax. + // For instance, "\0" is an invalid quoted string. + + // Avoid allocation in trivial cases. + simple := true + for _, r := range s { + if r == '\\' || r == quote { + simple = false + break + } + } + if simple { + return s, nil + } + + buf := make([]byte, 0, 3*len(s)/2) + for len(s) > 0 { + r, n := utf8.DecodeRuneInString(s) + if r == utf8.RuneError && n == 1 { + return "", errBadUTF8 + } + s = s[n:] + if r != '\\' { + if r < utf8.RuneSelf { + buf = append(buf, byte(r)) + } else { + buf = append(buf, string(r)...) + } + continue + } + + ch, tail, err := unescape(s) + if err != nil { + return "", err + } + buf = append(buf, ch...) + s = tail + } + return string(buf), nil +} + +func unescape(s string) (ch string, tail string, err error) { + r, n := utf8.DecodeRuneInString(s) + if r == utf8.RuneError && n == 1 { + return "", "", errBadUTF8 + } + s = s[n:] + switch r { + case 'a': + return "\a", s, nil + case 'b': + return "\b", s, nil + case 'f': + return "\f", s, nil + case 'n': + return "\n", s, nil + case 'r': + return "\r", s, nil + case 't': + return "\t", s, nil + case 'v': + return "\v", s, nil + case '?': + return "?", s, nil // trigraph workaround + case '\'', '"', '\\': + return string(r), s, nil + case '0', '1', '2', '3', '4', '5', '6', '7', 'x', 'X': + if len(s) < 2 { + return "", "", fmt.Errorf(`\%c requires 2 following digits`, r) + } + base := 8 + ss := s[:2] + s = s[2:] + if r == 'x' || r == 'X' { + base = 16 + } else { + ss = string(r) + ss + } + i, err := strconv.ParseUint(ss, base, 8) + if err != nil { + return "", "", err + } + return string([]byte{byte(i)}), s, nil + case 'u', 'U': + n := 4 + if r == 'U' { + n = 8 + } + if len(s) < n { + return "", "", fmt.Errorf(`\%c requires %d digits`, r, n) + } + + bs := make([]byte, n/2) + for i := 0; i < n; i += 2 { + a, ok1 := unhex(s[i]) + b, ok2 := unhex(s[i+1]) + if !ok1 || !ok2 { + return "", "", errBadHex + } + bs[i/2] = a<<4 | b + } + s = s[n:] + return string(bs), s, nil + } + return "", "", fmt.Errorf(`unknown escape \%c`, r) +} + +// Adapted from src/pkg/strconv/quote.go. +func unhex(b byte) (v byte, ok bool) { + switch { + case '0' <= b && b <= '9': + return b - '0', true + case 'a' <= b && b <= 'f': + return b - 'a' + 10, true + case 'A' <= b && b <= 'F': + return b - 'A' + 10, true + } + return 0, false +} + +// Back off the parser by one token. Can only be done between calls to next(). +// It makes the next advance() a no-op. +func (p *textParser) back() { p.backed = true } + +// Advances the parser and returns the new current token. +func (p *textParser) next() *token { + if p.backed || p.done { + p.backed = false + return &p.cur + } + p.advance() + if p.done { + p.cur.value = "" + } else if len(p.cur.value) > 0 && isQuote(p.cur.value[0]) { + // Look for multiple quoted strings separated by whitespace, + // and concatenate them. + cat := p.cur + for { + p.skipWhitespace() + if p.done || !isQuote(p.s[0]) { + break + } + p.advance() + if p.cur.err != nil { + return &p.cur + } + cat.value += " " + p.cur.value + cat.unquoted += p.cur.unquoted + } + p.done = false // parser may have seen EOF, but we want to return cat + p.cur = cat + } + return &p.cur +} + +func (p *textParser) consumeToken(s string) error { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value != s { + p.back() + return p.errorf("expected %q, found %q", s, tok.value) + } + return nil +} + +// Return a RequiredNotSetError indicating which required field was not set. +func (p *textParser) missingRequiredFieldError(sv reflect.Value) *RequiredNotSetError { + st := sv.Type() + sprops := GetProperties(st) + for i := 0; i < st.NumField(); i++ { + if !isNil(sv.Field(i)) { + continue + } + + props := sprops.Prop[i] + if props.Required { + return &RequiredNotSetError{fmt.Sprintf("%v.%v", st, props.OrigName)} + } + } + return &RequiredNotSetError{fmt.Sprintf("%v.", st)} // should not happen +} + +// Returns the index in the struct for the named field, as well as the parsed tag properties. +func structFieldByName(sprops *StructProperties, name string) (int, *Properties, bool) { + i, ok := sprops.decoderOrigNames[name] + if ok { + return i, sprops.Prop[i], true + } + return -1, nil, false +} + +// Consume a ':' from the input stream (if the next token is a colon), +// returning an error if a colon is needed but not present. +func (p *textParser) checkForColon(props *Properties, typ reflect.Type) *ParseError { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value != ":" { + // Colon is optional when the field is a group or message. + needColon := true + switch props.Wire { + case "group": + needColon = false + case "bytes": + // A "bytes" field is either a message, a string, or a repeated field; + // those three become *T, *string and []T respectively, so we can check for + // this field being a pointer to a non-string. + if typ.Kind() == reflect.Ptr { + // *T or *string + if typ.Elem().Kind() == reflect.String { + break + } + } else if typ.Kind() == reflect.Slice { + // []T or []*T + if typ.Elem().Kind() != reflect.Ptr { + break + } + } else if typ.Kind() == reflect.String { + // The proto3 exception is for a string field, + // which requires a colon. + break + } + needColon = false + } + if needColon { + return p.errorf("expected ':', found %q", tok.value) + } + p.back() + } + return nil +} + +func (p *textParser) readStruct(sv reflect.Value, terminator string) error { + st := sv.Type() + sprops := GetProperties(st) + reqCount := sprops.reqCount + var reqFieldErr error + fieldSet := make(map[string]bool) + // A struct is a sequence of "name: value", terminated by one of + // '>' or '}', or the end of the input. A name may also be + // "[extension]". + for { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value == terminator { + break + } + if tok.value == "[" { + // Looks like an extension. + // + // TODO: Check whether we need to handle + // namespace rooted names (e.g. ".something.Foo"). + tok = p.next() + if tok.err != nil { + return tok.err + } + var desc *ExtensionDesc + // This could be faster, but it's functional. + // TODO: Do something smarter than a linear scan. + for _, d := range RegisteredExtensions(reflect.New(st).Interface().(Message)) { + if d.Name == tok.value { + desc = d + break + } + } + if desc == nil { + return p.errorf("unrecognized extension %q", tok.value) + } + // Check the extension terminator. + tok = p.next() + if tok.err != nil { + return tok.err + } + if tok.value != "]" { + return p.errorf("unrecognized extension terminator %q", tok.value) + } + + props := &Properties{} + props.Parse(desc.Tag) + + typ := reflect.TypeOf(desc.ExtensionType) + if err := p.checkForColon(props, typ); err != nil { + return err + } + + rep := desc.repeated() + + // Read the extension structure, and set it in + // the value we're constructing. + var ext reflect.Value + if !rep { + ext = reflect.New(typ).Elem() + } else { + ext = reflect.New(typ.Elem()).Elem() + } + if err := p.readAny(ext, props); err != nil { + if _, ok := err.(*RequiredNotSetError); !ok { + return err + } + reqFieldErr = err + } + ep := sv.Addr().Interface().(extendableProto) + if !rep { + SetExtension(ep, desc, ext.Interface()) + } else { + old, err := GetExtension(ep, desc) + var sl reflect.Value + if err == nil { + sl = reflect.ValueOf(old) // existing slice + } else { + sl = reflect.MakeSlice(typ, 0, 1) + } + sl = reflect.Append(sl, ext) + SetExtension(ep, desc, sl.Interface()) + } + if err := p.consumeOptionalSeparator(); err != nil { + return err + } + continue + } + + // This is a normal, non-extension field. + name := tok.value + var dst reflect.Value + fi, props, ok := structFieldByName(sprops, name) + if ok { + dst = sv.Field(fi) + } else if oop, ok := sprops.OneofTypes[name]; ok { + // It is a oneof. + props = oop.Prop + nv := reflect.New(oop.Type.Elem()) + dst = nv.Elem().Field(0) + sv.Field(oop.Field).Set(nv) + } + if !dst.IsValid() { + return p.errorf("unknown field name %q in %v", name, st) + } + + if dst.Kind() == reflect.Map { + // Consume any colon. + if err := p.checkForColon(props, dst.Type()); err != nil { + return err + } + + // Construct the map if it doesn't already exist. + if dst.IsNil() { + dst.Set(reflect.MakeMap(dst.Type())) + } + key := reflect.New(dst.Type().Key()).Elem() + val := reflect.New(dst.Type().Elem()).Elem() + + // The map entry should be this sequence of tokens: + // < key : KEY value : VALUE > + // Technically the "key" and "value" could come in any order, + // but in practice they won't. + + tok := p.next() + var terminator string + switch tok.value { + case "<": + terminator = ">" + case "{": + terminator = "}" + default: + return p.errorf("expected '{' or '<', found %q", tok.value) + } + if err := p.consumeToken("key"); err != nil { + return err + } + if err := p.consumeToken(":"); err != nil { + return err + } + if err := p.readAny(key, props.mkeyprop); err != nil { + return err + } + if err := p.consumeOptionalSeparator(); err != nil { + return err + } + if err := p.consumeToken("value"); err != nil { + return err + } + if err := p.checkForColon(props.mvalprop, dst.Type().Elem()); err != nil { + return err + } + if err := p.readAny(val, props.mvalprop); err != nil { + return err + } + if err := p.consumeOptionalSeparator(); err != nil { + return err + } + if err := p.consumeToken(terminator); err != nil { + return err + } + + dst.SetMapIndex(key, val) + continue + } + + // Check that it's not already set if it's not a repeated field. + if !props.Repeated && fieldSet[name] { + return p.errorf("non-repeated field %q was repeated", name) + } + + if err := p.checkForColon(props, dst.Type()); err != nil { + return err + } + + // Parse into the field. + fieldSet[name] = true + if err := p.readAny(dst, props); err != nil { + if _, ok := err.(*RequiredNotSetError); !ok { + return err + } + reqFieldErr = err + } else if props.Required { + reqCount-- + } + + if err := p.consumeOptionalSeparator(); err != nil { + return err + } + + } + + if reqCount > 0 { + return p.missingRequiredFieldError(sv) + } + return reqFieldErr +} + +// consumeOptionalSeparator consumes an optional semicolon or comma. +// It is used in readStruct to provide backward compatibility. +func (p *textParser) consumeOptionalSeparator() error { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value != ";" && tok.value != "," { + p.back() + } + return nil +} + +func (p *textParser) readAny(v reflect.Value, props *Properties) error { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value == "" { + return p.errorf("unexpected EOF") + } + + switch fv := v; fv.Kind() { + case reflect.Slice: + at := v.Type() + if at.Elem().Kind() == reflect.Uint8 { + // Special case for []byte + if tok.value[0] != '"' && tok.value[0] != '\'' { + // Deliberately written out here, as the error after + // this switch statement would write "invalid []byte: ...", + // which is not as user-friendly. + return p.errorf("invalid string: %v", tok.value) + } + bytes := []byte(tok.unquoted) + fv.Set(reflect.ValueOf(bytes)) + return nil + } + // Repeated field. + if tok.value == "[" { + // Repeated field with list notation, like [1,2,3]. + for { + fv.Set(reflect.Append(fv, reflect.New(at.Elem()).Elem())) + err := p.readAny(fv.Index(fv.Len()-1), props) + if err != nil { + return err + } + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value == "]" { + break + } + if tok.value != "," { + return p.errorf("Expected ']' or ',' found %q", tok.value) + } + } + return nil + } + // One value of the repeated field. + p.back() + fv.Set(reflect.Append(fv, reflect.New(at.Elem()).Elem())) + return p.readAny(fv.Index(fv.Len()-1), props) + case reflect.Bool: + // Either "true", "false", 1 or 0. + switch tok.value { + case "true", "1": + fv.SetBool(true) + return nil + case "false", "0": + fv.SetBool(false) + return nil + } + case reflect.Float32, reflect.Float64: + v := tok.value + // Ignore 'f' for compatibility with output generated by C++, but don't + // remove 'f' when the value is "-inf" or "inf". + if strings.HasSuffix(v, "f") && tok.value != "-inf" && tok.value != "inf" { + v = v[:len(v)-1] + } + if f, err := strconv.ParseFloat(v, fv.Type().Bits()); err == nil { + fv.SetFloat(f) + return nil + } + case reflect.Int32: + if x, err := strconv.ParseInt(tok.value, 0, 32); err == nil { + fv.SetInt(x) + return nil + } + + if len(props.Enum) == 0 { + break + } + m, ok := enumValueMaps[props.Enum] + if !ok { + break + } + x, ok := m[tok.value] + if !ok { + break + } + fv.SetInt(int64(x)) + return nil + case reflect.Int64: + if x, err := strconv.ParseInt(tok.value, 0, 64); err == nil { + fv.SetInt(x) + return nil + } + + case reflect.Ptr: + // A basic field (indirected through pointer), or a repeated message/group + p.back() + fv.Set(reflect.New(fv.Type().Elem())) + return p.readAny(fv.Elem(), props) + case reflect.String: + if tok.value[0] == '"' || tok.value[0] == '\'' { + fv.SetString(tok.unquoted) + return nil + } + case reflect.Struct: + var terminator string + switch tok.value { + case "{": + terminator = "}" + case "<": + terminator = ">" + default: + return p.errorf("expected '{' or '<', found %q", tok.value) + } + // TODO: Handle nested messages which implement encoding.TextUnmarshaler. + return p.readStruct(fv, terminator) + case reflect.Uint32: + if x, err := strconv.ParseUint(tok.value, 0, 32); err == nil { + fv.SetUint(uint64(x)) + return nil + } + case reflect.Uint64: + if x, err := strconv.ParseUint(tok.value, 0, 64); err == nil { + fv.SetUint(x) + return nil + } + } + return p.errorf("invalid %v: %v", v.Type(), tok.value) +} + +// UnmarshalText reads a protocol buffer in Text format. UnmarshalText resets pb +// before starting to unmarshal, so any existing data in pb is always removed. +// If a required field is not set and no other error occurs, +// UnmarshalText returns *RequiredNotSetError. +func UnmarshalText(s string, pb Message) error { + if um, ok := pb.(encoding.TextUnmarshaler); ok { + err := um.UnmarshalText([]byte(s)) + return err + } + pb.Reset() + v := reflect.ValueOf(pb) + if pe := newTextParser(s).readStruct(v.Elem(), ""); pe != nil { + return pe + } + return nil +} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/apiversions/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/apiversions/doc.go deleted file mode 100644 index e3af39f513..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/apiversions/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package apiversions provides information and interaction with the different -// API versions for the OpenStack Block Storage service, code-named Cinder. -package apiversions diff --git a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/apiversions/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/apiversions/requests.go deleted file mode 100644 index bb2c259158..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/apiversions/requests.go +++ /dev/null @@ -1,21 +0,0 @@ -package apiversions - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// List lists all the Cinder API versions available to end-users. -func List(c *gophercloud.ServiceClient) pagination.Pager { - return pagination.NewPager(c, listURL(c), func(r pagination.PageResult) pagination.Page { - return APIVersionPage{pagination.SinglePageBase(r)} - }) -} - -// Get will retrieve the volume type with the provided ID. To extract the volume -// type from the result, call the Extract method on the GetResult. -func Get(client *gophercloud.ServiceClient, v string) GetResult { - var res GetResult - _, res.Err = client.Get(getURL(client, v), &res.Body, nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/apiversions/results.go b/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/apiversions/results.go deleted file mode 100644 index 7b0df115b5..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/apiversions/results.go +++ /dev/null @@ -1,58 +0,0 @@ -package apiversions - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" - - "github.com/mitchellh/mapstructure" -) - -// APIVersion represents an API version for Cinder. -type APIVersion struct { - ID string `json:"id" mapstructure:"id"` // unique identifier - Status string `json:"status" mapstructure:"status"` // current status - Updated string `json:"updated" mapstructure:"updated"` // date last updated -} - -// APIVersionPage is the page returned by a pager when traversing over a -// collection of API versions. -type APIVersionPage struct { - pagination.SinglePageBase -} - -// IsEmpty checks whether an APIVersionPage struct is empty. -func (r APIVersionPage) IsEmpty() (bool, error) { - is, err := ExtractAPIVersions(r) - if err != nil { - return true, err - } - return len(is) == 0, nil -} - -// ExtractAPIVersions takes a collection page, extracts all of the elements, -// and returns them a slice of APIVersion structs. It is effectively a cast. -func ExtractAPIVersions(page pagination.Page) ([]APIVersion, error) { - var resp struct { - Versions []APIVersion `mapstructure:"versions"` - } - - err := mapstructure.Decode(page.(APIVersionPage).Body, &resp) - - return resp.Versions, err -} - -// GetResult represents the result of a get operation. -type GetResult struct { - gophercloud.Result -} - -// Extract is a function that accepts a result and extracts an API version resource. -func (r GetResult) Extract() (*APIVersion, error) { - var resp struct { - Version *APIVersion `mapstructure:"version"` - } - - err := mapstructure.Decode(r.Body, &resp) - - return resp.Version, err -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/apiversions/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/apiversions/urls.go deleted file mode 100644 index 56f8260a25..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/apiversions/urls.go +++ /dev/null @@ -1,15 +0,0 @@ -package apiversions - -import ( - "strings" - - "github.com/rackspace/gophercloud" -) - -func getURL(c *gophercloud.ServiceClient, version string) string { - return c.ServiceURL(strings.TrimRight(version, "/") + "/") -} - -func listURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL("") -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/doc.go deleted file mode 100644 index 198f83077c..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -// Package snapshots provides information and interaction with snapshots in the -// OpenStack Block Storage service. A snapshot is a point in time copy of the -// data contained in an external storage volume, and can be controlled -// programmatically. -package snapshots diff --git a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/fixtures.go deleted file mode 100644 index d1461fb69d..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/fixtures.go +++ /dev/null @@ -1,114 +0,0 @@ -package snapshots - -import ( - "fmt" - "net/http" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -func MockListResponse(t *testing.T) { - th.Mux.HandleFunc("/snapshots", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` - { - "snapshots": [ - { - "id": "289da7f8-6440-407c-9fb4-7db01ec49164", - "display_name": "snapshot-001" - }, - { - "id": "96c3bda7-c82a-4f50-be73-ca7621794835", - "display_name": "snapshot-002" - } - ] - } - `) - }) -} - -func MockGetResponse(t *testing.T) { - th.Mux.HandleFunc("/snapshots/d32019d3-bc6e-4319-9c1d-6722fc136a22", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, ` -{ - "snapshot": { - "display_name": "snapshot-001", - "id": "d32019d3-bc6e-4319-9c1d-6722fc136a22" - } -} - `) - }) -} - -func MockCreateResponse(t *testing.T) { - th.Mux.HandleFunc("/snapshots", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Content-Type", "application/json") - th.TestHeader(t, r, "Accept", "application/json") - th.TestJSONRequest(t, r, ` -{ - "snapshot": { - "volume_id": "1234", - "display_name": "snapshot-001" - } -} - `) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusCreated) - - fmt.Fprintf(w, ` -{ - "snapshot": { - "volume_id": "1234", - "display_name": "snapshot-001", - "id": "d32019d3-bc6e-4319-9c1d-6722fc136a22" - } -} - `) - }) -} - -func MockUpdateMetadataResponse(t *testing.T) { - th.Mux.HandleFunc("/snapshots/123/metadata", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PUT") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Content-Type", "application/json") - th.TestJSONRequest(t, r, ` - { - "metadata": { - "key": "v1" - } - } - `) - - fmt.Fprintf(w, ` - { - "metadata": { - "key": "v1" - } - } - `) - }) -} - -func MockDeleteResponse(t *testing.T) { - th.Mux.HandleFunc("/snapshots/d32019d3-bc6e-4319-9c1d-6722fc136a22", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.WriteHeader(http.StatusNoContent) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/requests.go deleted file mode 100644 index d2f10aa6b5..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/requests.go +++ /dev/null @@ -1,173 +0,0 @@ -package snapshots - -import ( - "fmt" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// CreateOptsBuilder allows extensions to add additional parameters to the -// Create request. -type CreateOptsBuilder interface { - ToSnapshotCreateMap() (map[string]interface{}, error) -} - -// CreateOpts contains options for creating a Snapshot. This object is passed to -// the snapshots.Create function. For more information about these parameters, -// see the Snapshot object. -type CreateOpts struct { - // OPTIONAL - Description string - // OPTIONAL - Force bool - // OPTIONAL - Metadata map[string]interface{} - // OPTIONAL - Name string - // REQUIRED - VolumeID string -} - -// ToSnapshotCreateMap assembles a request body based on the contents of a -// CreateOpts. -func (opts CreateOpts) ToSnapshotCreateMap() (map[string]interface{}, error) { - s := make(map[string]interface{}) - - if opts.VolumeID == "" { - return nil, fmt.Errorf("Required CreateOpts field 'VolumeID' not set.") - } - s["volume_id"] = opts.VolumeID - - if opts.Description != "" { - s["display_description"] = opts.Description - } - if opts.Force == true { - s["force"] = opts.Force - } - if opts.Metadata != nil { - s["metadata"] = opts.Metadata - } - if opts.Name != "" { - s["display_name"] = opts.Name - } - - return map[string]interface{}{"snapshot": s}, nil -} - -// Create will create a new Snapshot based on the values in CreateOpts. To -// extract the Snapshot object from the response, call the Extract method on the -// CreateResult. -func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult { - var res CreateResult - - reqBody, err := opts.ToSnapshotCreateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = client.Post(createURL(client), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200, 201}, - }) - return res -} - -// Delete will delete the existing Snapshot with the provided ID. -func Delete(client *gophercloud.ServiceClient, id string) DeleteResult { - var res DeleteResult - _, res.Err = client.Delete(deleteURL(client, id), nil) - return res -} - -// Get retrieves the Snapshot with the provided ID. To extract the Snapshot -// object from the response, call the Extract method on the GetResult. -func Get(client *gophercloud.ServiceClient, id string) GetResult { - var res GetResult - _, res.Err = client.Get(getURL(client, id), &res.Body, nil) - return res -} - -// ListOptsBuilder allows extensions to add additional parameters to the List -// request. -type ListOptsBuilder interface { - ToSnapshotListQuery() (string, error) -} - -// ListOpts hold options for listing Snapshots. It is passed to the -// snapshots.List function. -type ListOpts struct { - Name string `q:"display_name"` - Status string `q:"status"` - VolumeID string `q:"volume_id"` -} - -// ToSnapshotListQuery formats a ListOpts into a query string. -func (opts ListOpts) ToSnapshotListQuery() (string, error) { - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return "", err - } - return q.String(), nil -} - -// List returns Snapshots optionally limited by the conditions provided in -// ListOpts. -func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { - url := listURL(client) - if opts != nil { - query, err := opts.ToSnapshotListQuery() - if err != nil { - return pagination.Pager{Err: err} - } - url += query - } - - createPage := func(r pagination.PageResult) pagination.Page { - return ListResult{pagination.SinglePageBase(r)} - } - return pagination.NewPager(client, url, createPage) -} - -// UpdateMetadataOptsBuilder allows extensions to add additional parameters to -// the Update request. -type UpdateMetadataOptsBuilder interface { - ToSnapshotUpdateMetadataMap() (map[string]interface{}, error) -} - -// UpdateMetadataOpts contain options for updating an existing Snapshot. This -// object is passed to the snapshots.Update function. For more information -// about the parameters, see the Snapshot object. -type UpdateMetadataOpts struct { - Metadata map[string]interface{} -} - -// ToSnapshotUpdateMetadataMap assembles a request body based on the contents of -// an UpdateMetadataOpts. -func (opts UpdateMetadataOpts) ToSnapshotUpdateMetadataMap() (map[string]interface{}, error) { - v := make(map[string]interface{}) - - if opts.Metadata != nil { - v["metadata"] = opts.Metadata - } - - return v, nil -} - -// UpdateMetadata will update the Snapshot with provided information. To -// extract the updated Snapshot from the response, call the ExtractMetadata -// method on the UpdateMetadataResult. -func UpdateMetadata(client *gophercloud.ServiceClient, id string, opts UpdateMetadataOptsBuilder) UpdateMetadataResult { - var res UpdateMetadataResult - - reqBody, err := opts.ToSnapshotUpdateMetadataMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = client.Put(updateMetadataURL(client, id), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/results.go b/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/results.go deleted file mode 100644 index e595798e4a..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/results.go +++ /dev/null @@ -1,123 +0,0 @@ -package snapshots - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" - - "github.com/mitchellh/mapstructure" -) - -// Snapshot contains all the information associated with an OpenStack Snapshot. -type Snapshot struct { - // Currect status of the Snapshot. - Status string `mapstructure:"status"` - - // Display name. - Name string `mapstructure:"display_name"` - - // Instances onto which the Snapshot is attached. - Attachments []string `mapstructure:"attachments"` - - // Logical group. - AvailabilityZone string `mapstructure:"availability_zone"` - - // Is the Snapshot bootable? - Bootable string `mapstructure:"bootable"` - - // Date created. - CreatedAt string `mapstructure:"created_at"` - - // Display description. - Description string `mapstructure:"display_discription"` - - // See VolumeType object for more information. - VolumeType string `mapstructure:"volume_type"` - - // ID of the Snapshot from which this Snapshot was created. - SnapshotID string `mapstructure:"snapshot_id"` - - // ID of the Volume from which this Snapshot was created. - VolumeID string `mapstructure:"volume_id"` - - // User-defined key-value pairs. - Metadata map[string]string `mapstructure:"metadata"` - - // Unique identifier. - ID string `mapstructure:"id"` - - // Size of the Snapshot, in GB. - Size int `mapstructure:"size"` -} - -// CreateResult contains the response body and error from a Create request. -type CreateResult struct { - commonResult -} - -// GetResult contains the response body and error from a Get request. -type GetResult struct { - commonResult -} - -// DeleteResult contains the response body and error from a Delete request. -type DeleteResult struct { - gophercloud.ErrResult -} - -// ListResult is a pagination.Pager that is returned from a call to the List function. -type ListResult struct { - pagination.SinglePageBase -} - -// IsEmpty returns true if a ListResult contains no Snapshots. -func (r ListResult) IsEmpty() (bool, error) { - volumes, err := ExtractSnapshots(r) - if err != nil { - return true, err - } - return len(volumes) == 0, nil -} - -// ExtractSnapshots extracts and returns Snapshots. It is used while iterating over a snapshots.List call. -func ExtractSnapshots(page pagination.Page) ([]Snapshot, error) { - var response struct { - Snapshots []Snapshot `json:"snapshots"` - } - - err := mapstructure.Decode(page.(ListResult).Body, &response) - return response.Snapshots, err -} - -// UpdateMetadataResult contains the response body and error from an UpdateMetadata request. -type UpdateMetadataResult struct { - commonResult -} - -// ExtractMetadata returns the metadata from a response from snapshots.UpdateMetadata. -func (r UpdateMetadataResult) ExtractMetadata() (map[string]interface{}, error) { - if r.Err != nil { - return nil, r.Err - } - - m := r.Body.(map[string]interface{})["metadata"] - return m.(map[string]interface{}), nil -} - -type commonResult struct { - gophercloud.Result -} - -// Extract will get the Snapshot object out of the commonResult object. -func (r commonResult) Extract() (*Snapshot, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Snapshot *Snapshot `json:"snapshot"` - } - - err := mapstructure.Decode(r.Body, &res) - - return res.Snapshot, err -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/urls.go deleted file mode 100644 index 4d635e8dd4..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/urls.go +++ /dev/null @@ -1,27 +0,0 @@ -package snapshots - -import "github.com/rackspace/gophercloud" - -func createURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL("snapshots") -} - -func deleteURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL("snapshots", id) -} - -func getURL(c *gophercloud.ServiceClient, id string) string { - return deleteURL(c, id) -} - -func listURL(c *gophercloud.ServiceClient) string { - return createURL(c) -} - -func metadataURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL("snapshots", id, "metadata") -} - -func updateMetadataURL(c *gophercloud.ServiceClient, id string) string { - return metadataURL(c, id) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/util.go b/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/util.go deleted file mode 100644 index 64cdc607ec..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots/util.go +++ /dev/null @@ -1,22 +0,0 @@ -package snapshots - -import ( - "github.com/rackspace/gophercloud" -) - -// WaitForStatus will continually poll the resource, checking for a particular -// status. It will do this for the amount of seconds defined. -func WaitForStatus(c *gophercloud.ServiceClient, id, status string, secs int) error { - return gophercloud.WaitFor(secs, func() (bool, error) { - current, err := Get(c, id).Extract() - if err != nil { - return false, err - } - - if current.Status == status { - return true, nil - } - - return false, nil - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/doc.go deleted file mode 100644 index 307b8b12d2..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -// Package volumes provides information and interaction with volumes in the -// OpenStack Block Storage service. A volume is a detachable block storage -// device, akin to a USB hard drive. It can only be attached to one instance at -// a time. -package volumes diff --git a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/fixtures.go deleted file mode 100644 index a1b8697c2a..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/fixtures.go +++ /dev/null @@ -1,113 +0,0 @@ -package volumes - -import ( - "fmt" - "net/http" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -func MockListResponse(t *testing.T) { - th.Mux.HandleFunc("/volumes", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` - { - "volumes": [ - { - "id": "289da7f8-6440-407c-9fb4-7db01ec49164", - "display_name": "vol-001" - }, - { - "id": "96c3bda7-c82a-4f50-be73-ca7621794835", - "display_name": "vol-002" - } - ] - } - `) - }) -} - -func MockGetResponse(t *testing.T) { - th.Mux.HandleFunc("/volumes/d32019d3-bc6e-4319-9c1d-6722fc136a22", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, ` -{ - "volume": { - "display_name": "vol-001", - "id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", - "attachments": [ - { - "device": "/dev/vde", - "server_id": "a740d24b-dc5b-4d59-ac75-53971c2920ba", - "id": "d6da11e5-2ed3-413e-88d8-b772ba62193d", - "volume_id": "d6da11e5-2ed3-413e-88d8-b772ba62193d" - } - ] - } -} - `) - }) -} - -func MockCreateResponse(t *testing.T) { - th.Mux.HandleFunc("/volumes", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Content-Type", "application/json") - th.TestHeader(t, r, "Accept", "application/json") - th.TestJSONRequest(t, r, ` -{ - "volume": { - "size": 75 - } -} - `) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusCreated) - - fmt.Fprintf(w, ` -{ - "volume": { - "size": 4, - "id": "d32019d3-bc6e-4319-9c1d-6722fc136a22" - } -} - `) - }) -} - -func MockDeleteResponse(t *testing.T) { - th.Mux.HandleFunc("/volumes/d32019d3-bc6e-4319-9c1d-6722fc136a22", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.WriteHeader(http.StatusNoContent) - }) -} - -func MockUpdateResponse(t *testing.T) { - th.Mux.HandleFunc("/volumes/d32019d3-bc6e-4319-9c1d-6722fc136a22", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PUT") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, ` - { - "volume": { - "display_name": "vol-002", - "id": "d32019d3-bc6e-4319-9c1d-6722fc136a22" - } - } - `) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/requests.go deleted file mode 100644 index 253aaf7c54..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/requests.go +++ /dev/null @@ -1,203 +0,0 @@ -package volumes - -import ( - "fmt" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// CreateOptsBuilder allows extensions to add additional parameters to the -// Create request. -type CreateOptsBuilder interface { - ToVolumeCreateMap() (map[string]interface{}, error) -} - -// CreateOpts contains options for creating a Volume. This object is passed to -// the volumes.Create function. For more information about these parameters, -// see the Volume object. -type CreateOpts struct { - // OPTIONAL - Availability string - // OPTIONAL - Description string - // OPTIONAL - Metadata map[string]string - // OPTIONAL - Name string - // REQUIRED - Size int - // OPTIONAL - SnapshotID, SourceVolID, ImageID string - // OPTIONAL - VolumeType string -} - -// ToVolumeCreateMap assembles a request body based on the contents of a -// CreateOpts. -func (opts CreateOpts) ToVolumeCreateMap() (map[string]interface{}, error) { - v := make(map[string]interface{}) - - if opts.Size == 0 { - return nil, fmt.Errorf("Required CreateOpts field 'Size' not set.") - } - v["size"] = opts.Size - - if opts.Availability != "" { - v["availability_zone"] = opts.Availability - } - if opts.Description != "" { - v["display_description"] = opts.Description - } - if opts.ImageID != "" { - v["imageRef"] = opts.ImageID - } - if opts.Metadata != nil { - v["metadata"] = opts.Metadata - } - if opts.Name != "" { - v["display_name"] = opts.Name - } - if opts.SourceVolID != "" { - v["source_volid"] = opts.SourceVolID - } - if opts.SnapshotID != "" { - v["snapshot_id"] = opts.SnapshotID - } - if opts.VolumeType != "" { - v["volume_type"] = opts.VolumeType - } - - return map[string]interface{}{"volume": v}, nil -} - -// Create will create a new Volume based on the values in CreateOpts. To extract -// the Volume object from the response, call the Extract method on the -// CreateResult. -func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult { - var res CreateResult - - reqBody, err := opts.ToVolumeCreateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = client.Post(createURL(client), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200, 201}, - }) - return res -} - -// Delete will delete the existing Volume with the provided ID. -func Delete(client *gophercloud.ServiceClient, id string) DeleteResult { - var res DeleteResult - _, res.Err = client.Delete(deleteURL(client, id), nil) - return res -} - -// Get retrieves the Volume with the provided ID. To extract the Volume object -// from the response, call the Extract method on the GetResult. -func Get(client *gophercloud.ServiceClient, id string) GetResult { - var res GetResult - _, res.Err = client.Get(getURL(client, id), &res.Body, nil) - return res -} - -// ListOptsBuilder allows extensions to add additional parameters to the List -// request. -type ListOptsBuilder interface { - ToVolumeListQuery() (string, error) -} - -// ListOpts holds options for listing Volumes. It is passed to the volumes.List -// function. -type ListOpts struct { - // admin-only option. Set it to true to see all tenant volumes. - AllTenants bool `q:"all_tenants"` - // List only volumes that contain Metadata. - Metadata map[string]string `q:"metadata"` - // List only volumes that have Name as the display name. - Name string `q:"name"` - // List only volumes that have a status of Status. - Status string `q:"status"` -} - -// ToVolumeListQuery formats a ListOpts into a query string. -func (opts ListOpts) ToVolumeListQuery() (string, error) { - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return "", err - } - return q.String(), nil -} - -// List returns Volumes optionally limited by the conditions provided in ListOpts. -func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { - url := listURL(client) - if opts != nil { - query, err := opts.ToVolumeListQuery() - if err != nil { - return pagination.Pager{Err: err} - } - url += query - } - createPage := func(r pagination.PageResult) pagination.Page { - return ListResult{pagination.SinglePageBase(r)} - } - - return pagination.NewPager(client, url, createPage) -} - -// UpdateOptsBuilder allows extensions to add additional parameters to the -// Update request. -type UpdateOptsBuilder interface { - ToVolumeUpdateMap() (map[string]interface{}, error) -} - -// UpdateOpts contain options for updating an existing Volume. This object is passed -// to the volumes.Update function. For more information about the parameters, see -// the Volume object. -type UpdateOpts struct { - // OPTIONAL - Name string - // OPTIONAL - Description string - // OPTIONAL - Metadata map[string]string -} - -// ToVolumeUpdateMap assembles a request body based on the contents of an -// UpdateOpts. -func (opts UpdateOpts) ToVolumeUpdateMap() (map[string]interface{}, error) { - v := make(map[string]interface{}) - - if opts.Description != "" { - v["display_description"] = opts.Description - } - if opts.Metadata != nil { - v["metadata"] = opts.Metadata - } - if opts.Name != "" { - v["display_name"] = opts.Name - } - - return map[string]interface{}{"volume": v}, nil -} - -// Update will update the Volume with provided information. To extract the updated -// Volume from the response, call the Extract method on the UpdateResult. -func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) UpdateResult { - var res UpdateResult - - reqBody, err := opts.ToVolumeUpdateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = client.Put(updateURL(client, id), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/results.go b/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/results.go deleted file mode 100644 index 2fd4ef14ea..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/results.go +++ /dev/null @@ -1,113 +0,0 @@ -package volumes - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" - - "github.com/mitchellh/mapstructure" -) - -// Volume contains all the information associated with an OpenStack Volume. -type Volume struct { - // Current status of the volume. - Status string `mapstructure:"status"` - - // Human-readable display name for the volume. - Name string `mapstructure:"display_name"` - - // Instances onto which the volume is attached. - Attachments []map[string]interface{} `mapstructure:"attachments"` - - // This parameter is no longer used. - AvailabilityZone string `mapstructure:"availability_zone"` - - // Indicates whether this is a bootable volume. - Bootable string `mapstructure:"bootable"` - - // The date when this volume was created. - CreatedAt string `mapstructure:"created_at"` - - // Human-readable description for the volume. - Description string `mapstructure:"display_description"` - - // The type of volume to create, either SATA or SSD. - VolumeType string `mapstructure:"volume_type"` - - // The ID of the snapshot from which the volume was created - SnapshotID string `mapstructure:"snapshot_id"` - - // The ID of another block storage volume from which the current volume was created - SourceVolID string `mapstructure:"source_volid"` - - // Arbitrary key-value pairs defined by the user. - Metadata map[string]string `mapstructure:"metadata"` - - // Unique identifier for the volume. - ID string `mapstructure:"id"` - - // Size of the volume in GB. - Size int `mapstructure:"size"` -} - -// CreateResult contains the response body and error from a Create request. -type CreateResult struct { - commonResult -} - -// GetResult contains the response body and error from a Get request. -type GetResult struct { - commonResult -} - -// DeleteResult contains the response body and error from a Delete request. -type DeleteResult struct { - gophercloud.ErrResult -} - -// ListResult is a pagination.pager that is returned from a call to the List function. -type ListResult struct { - pagination.SinglePageBase -} - -// IsEmpty returns true if a ListResult contains no Volumes. -func (r ListResult) IsEmpty() (bool, error) { - volumes, err := ExtractVolumes(r) - if err != nil { - return true, err - } - return len(volumes) == 0, nil -} - -// ExtractVolumes extracts and returns Volumes. It is used while iterating over a volumes.List call. -func ExtractVolumes(page pagination.Page) ([]Volume, error) { - var response struct { - Volumes []Volume `json:"volumes"` - } - - err := mapstructure.Decode(page.(ListResult).Body, &response) - return response.Volumes, err -} - -// UpdateResult contains the response body and error from an Update request. -type UpdateResult struct { - commonResult -} - -type commonResult struct { - gophercloud.Result -} - -// Extract will get the Volume object out of the commonResult object. -func (r commonResult) Extract() (*Volume, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Volume *Volume `json:"volume"` - } - - err := mapstructure.Decode(r.Body, &res) - - return res.Volume, err -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/urls.go deleted file mode 100644 index 29629a1af8..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/urls.go +++ /dev/null @@ -1,23 +0,0 @@ -package volumes - -import "github.com/rackspace/gophercloud" - -func createURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL("volumes") -} - -func listURL(c *gophercloud.ServiceClient) string { - return createURL(c) -} - -func deleteURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL("volumes", id) -} - -func getURL(c *gophercloud.ServiceClient, id string) string { - return deleteURL(c, id) -} - -func updateURL(c *gophercloud.ServiceClient, id string) string { - return deleteURL(c, id) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/util.go b/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/util.go deleted file mode 100644 index 1dda695ea0..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes/util.go +++ /dev/null @@ -1,22 +0,0 @@ -package volumes - -import ( - "github.com/rackspace/gophercloud" -) - -// WaitForStatus will continually poll the resource, checking for a particular -// status. It will do this for the amount of seconds defined. -func WaitForStatus(c *gophercloud.ServiceClient, id, status string, secs int) error { - return gophercloud.WaitFor(secs, func() (bool, error) { - current, err := Get(c, id).Extract() - if err != nil { - return false, err - } - - if current.Status == status { - return true, nil - } - - return false, nil - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes/doc.go deleted file mode 100644 index 793084f89b..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes/doc.go +++ /dev/null @@ -1,9 +0,0 @@ -// Package volumetypes provides information and interaction with volume types -// in the OpenStack Block Storage service. A volume type indicates the type of -// a block storage volume, such as SATA, SCSCI, SSD, etc. These can be -// customized or defined by the OpenStack admin. -// -// You can also define extra_specs associated with your volume types. For -// instance, you could have a VolumeType=SATA, with extra_specs (RPM=10000, -// RAID-Level=5) . Extra_specs are defined and customized by the admin. -package volumetypes diff --git a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes/fixtures.go deleted file mode 100644 index e3326eae14..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes/fixtures.go +++ /dev/null @@ -1,60 +0,0 @@ -package volumetypes - -import ( - "fmt" - "net/http" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -func MockListResponse(t *testing.T) { - th.Mux.HandleFunc("/types", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` - { - "volume_types": [ - { - "id": "289da7f8-6440-407c-9fb4-7db01ec49164", - "name": "vol-type-001", - "extra_specs": { - "capabilities": "gpu" - } - }, - { - "id": "96c3bda7-c82a-4f50-be73-ca7621794835", - "name": "vol-type-002", - "extra_specs": {} - } - ] - } - `) - }) -} - -func MockGetResponse(t *testing.T) { - th.Mux.HandleFunc("/types/d32019d3-bc6e-4319-9c1d-6722fc136a22", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, ` -{ - "volume_type": { - "name": "vol-type-001", - "id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", - "extra_specs": { - "serverNumber": "2" - } - } -} - `) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes/requests.go deleted file mode 100644 index 1673d13aaf..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes/requests.go +++ /dev/null @@ -1,76 +0,0 @@ -package volumetypes - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// CreateOptsBuilder allows extensions to add additional parameters to the -// Create request. -type CreateOptsBuilder interface { - ToVolumeTypeCreateMap() (map[string]interface{}, error) -} - -// CreateOpts are options for creating a volume type. -type CreateOpts struct { - // OPTIONAL. See VolumeType. - ExtraSpecs map[string]interface{} - // OPTIONAL. See VolumeType. - Name string -} - -// ToVolumeTypeCreateMap casts a CreateOpts struct to a map. -func (opts CreateOpts) ToVolumeTypeCreateMap() (map[string]interface{}, error) { - vt := make(map[string]interface{}) - - if opts.ExtraSpecs != nil { - vt["extra_specs"] = opts.ExtraSpecs - } - if opts.Name != "" { - vt["name"] = opts.Name - } - - return map[string]interface{}{"volume_type": vt}, nil -} - -// Create will create a new volume. To extract the created volume type object, -// call the Extract method on the CreateResult. -func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult { - var res CreateResult - - reqBody, err := opts.ToVolumeTypeCreateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = client.Post(createURL(client), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200, 201}, - }) - return res -} - -// Delete will delete the volume type with the provided ID. -func Delete(client *gophercloud.ServiceClient, id string) DeleteResult { - var res DeleteResult - _, res.Err = client.Delete(deleteURL(client, id), nil) - return res -} - -// Get will retrieve the volume type with the provided ID. To extract the volume -// type from the result, call the Extract method on the GetResult. -func Get(client *gophercloud.ServiceClient, id string) GetResult { - var res GetResult - _, err := client.Get(getURL(client, id), &res.Body, nil) - res.Err = err - return res -} - -// List returns all volume types. -func List(client *gophercloud.ServiceClient) pagination.Pager { - createPage := func(r pagination.PageResult) pagination.Page { - return ListResult{pagination.SinglePageBase(r)} - } - - return pagination.NewPager(client, listURL(client), createPage) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes/results.go b/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes/results.go deleted file mode 100644 index c049a045d8..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes/results.go +++ /dev/null @@ -1,72 +0,0 @@ -package volumetypes - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// VolumeType contains all information associated with an OpenStack Volume Type. -type VolumeType struct { - ExtraSpecs map[string]interface{} `json:"extra_specs" mapstructure:"extra_specs"` // user-defined metadata - ID string `json:"id" mapstructure:"id"` // unique identifier - Name string `json:"name" mapstructure:"name"` // display name -} - -// CreateResult contains the response body and error from a Create request. -type CreateResult struct { - commonResult -} - -// GetResult contains the response body and error from a Get request. -type GetResult struct { - commonResult -} - -// DeleteResult contains the response error from a Delete request. -type DeleteResult struct { - gophercloud.ErrResult -} - -// ListResult is a pagination.Pager that is returned from a call to the List function. -type ListResult struct { - pagination.SinglePageBase -} - -// IsEmpty returns true if a ListResult contains no Volume Types. -func (r ListResult) IsEmpty() (bool, error) { - volumeTypes, err := ExtractVolumeTypes(r) - if err != nil { - return true, err - } - return len(volumeTypes) == 0, nil -} - -// ExtractVolumeTypes extracts and returns Volume Types. -func ExtractVolumeTypes(page pagination.Page) ([]VolumeType, error) { - var response struct { - VolumeTypes []VolumeType `mapstructure:"volume_types"` - } - - err := mapstructure.Decode(page.(ListResult).Body, &response) - return response.VolumeTypes, err -} - -type commonResult struct { - gophercloud.Result -} - -// Extract will get the Volume Type object out of the commonResult object. -func (r commonResult) Extract() (*VolumeType, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - VolumeType *VolumeType `json:"volume_type" mapstructure:"volume_type"` - } - - err := mapstructure.Decode(r.Body, &res) - - return res.VolumeType, err -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes/urls.go deleted file mode 100644 index cf8367bfab..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes/urls.go +++ /dev/null @@ -1,19 +0,0 @@ -package volumetypes - -import "github.com/rackspace/gophercloud" - -func listURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL("types") -} - -func createURL(c *gophercloud.ServiceClient) string { - return listURL(c) -} - -func getURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL("types", id) -} - -func deleteURL(c *gophercloud.ServiceClient, id string) string { - return getURL(c, id) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/base/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/base/doc.go deleted file mode 100644 index f78d4f7355..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/base/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -// Package base provides information and interaction with the base API -// resource in the OpenStack CDN service. This API resource allows for -// retrieving the Home Document and pinging the root URL. -package base diff --git a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/base/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/base/fixtures.go deleted file mode 100644 index 19b5ece461..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/base/fixtures.go +++ /dev/null @@ -1,53 +0,0 @@ -package base - -import ( - "fmt" - "net/http" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -// HandleGetSuccessfully creates an HTTP handler at `/` on the test handler mux -// that responds with a `Get` response. -func HandleGetSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, ` - { - "resources": { - "rel/cdn": { - "href-template": "services{?marker,limit}", - "href-vars": { - "marker": "param/marker", - "limit": "param/limit" - }, - "hints": { - "allow": [ - "GET" - ], - "formats": { - "application/json": {} - } - } - } - } - } - `) - - }) -} - -// HandlePingSuccessfully creates an HTTP handler at `/ping` on the test handler -// mux that responds with a `Ping` response. -func HandlePingSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/ping", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.WriteHeader(http.StatusNoContent) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/base/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/base/requests.go deleted file mode 100644 index dd221bc983..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/base/requests.go +++ /dev/null @@ -1,21 +0,0 @@ -package base - -import "github.com/rackspace/gophercloud" - -// Get retrieves the home document, allowing the user to discover the -// entire API. -func Get(c *gophercloud.ServiceClient) GetResult { - var res GetResult - _, res.Err = c.Get(getURL(c), &res.Body, nil) - return res -} - -// Ping retrieves a ping to the server. -func Ping(c *gophercloud.ServiceClient) PingResult { - var res PingResult - _, res.Err = c.Get(pingURL(c), nil, &gophercloud.RequestOpts{ - OkCodes: []int{204}, - MoreHeaders: map[string]string{"Accept": ""}, - }) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/base/results.go b/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/base/results.go deleted file mode 100644 index bef1da8a17..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/base/results.go +++ /dev/null @@ -1,35 +0,0 @@ -package base - -import ( - "errors" - - "github.com/rackspace/gophercloud" -) - -// HomeDocument is a resource that contains all the resources for the CDN API. -type HomeDocument map[string]interface{} - -// GetResult represents the result of a Get operation. -type GetResult struct { - gophercloud.Result -} - -// Extract is a function that accepts a result and extracts a home document resource. -func (r GetResult) Extract() (*HomeDocument, error) { - if r.Err != nil { - return nil, r.Err - } - - submap, ok := r.Body.(map[string]interface{})["resources"] - if !ok { - return nil, errors.New("Unexpected HomeDocument structure") - } - casted := HomeDocument(submap.(map[string]interface{})) - - return &casted, nil -} - -// PingResult represents the result of a Ping operation. -type PingResult struct { - gophercloud.ErrResult -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/base/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/base/urls.go deleted file mode 100644 index a95e18bca9..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/base/urls.go +++ /dev/null @@ -1,11 +0,0 @@ -package base - -import "github.com/rackspace/gophercloud" - -func getURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL() -} - -func pingURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL("ping") -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/flavors/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/flavors/doc.go deleted file mode 100644 index d4066985cb..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/flavors/doc.go +++ /dev/null @@ -1,6 +0,0 @@ -// Package flavors provides information and interaction with the flavors API -// resource in the OpenStack CDN service. This API resource allows for -// listing flavors and retrieving a specific flavor. -// -// A flavor is a mapping configuration to a CDN provider. -package flavors diff --git a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/flavors/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/flavors/fixtures.go deleted file mode 100644 index d7ec1a00d5..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/flavors/fixtures.go +++ /dev/null @@ -1,82 +0,0 @@ -package flavors - -import ( - "fmt" - "net/http" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -// HandleListCDNFlavorsSuccessfully creates an HTTP handler at `/flavors` on the test handler mux -// that responds with a `List` response. -func HandleListCDNFlavorsSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/flavors", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, ` - { - "flavors": [ - { - "id": "europe", - "providers": [ - { - "provider": "Fastly", - "links": [ - { - "href": "http://www.fastly.com", - "rel": "provider_url" - } - ] - } - ], - "links": [ - { - "href": "https://www.poppycdn.io/v1.0/flavors/europe", - "rel": "self" - } - ] - } - ] - } - `) - }) -} - -// HandleGetCDNFlavorSuccessfully creates an HTTP handler at `/flavors/{id}` on the test handler mux -// that responds with a `Get` response. -func HandleGetCDNFlavorSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/flavors/asia", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, ` - { - "id" : "asia", - "providers" : [ - { - "provider" : "ChinaCache", - "links": [ - { - "href": "http://www.chinacache.com", - "rel": "provider_url" - } - ] - } - ], - "links": [ - { - "href": "https://www.poppycdn.io/v1.0/flavors/asia", - "rel": "self" - } - ] - } - `) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/flavors/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/flavors/requests.go deleted file mode 100644 index 8755a95b8f..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/flavors/requests.go +++ /dev/null @@ -1,22 +0,0 @@ -package flavors - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// List returns a single page of CDN flavors. -func List(c *gophercloud.ServiceClient) pagination.Pager { - url := listURL(c) - createPage := func(r pagination.PageResult) pagination.Page { - return FlavorPage{pagination.SinglePageBase(r)} - } - return pagination.NewPager(c, url, createPage) -} - -// Get retrieves a specific flavor based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) GetResult { - var res GetResult - _, res.Err = c.Get(getURL(c, id), &res.Body, nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/flavors/results.go b/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/flavors/results.go deleted file mode 100644 index 8cab48b536..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/flavors/results.go +++ /dev/null @@ -1,71 +0,0 @@ -package flavors - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// Provider represents a provider for a particular flavor. -type Provider struct { - // Specifies the name of the provider. The name must not exceed 64 bytes in - // length and is limited to unicode, digits, underscores, and hyphens. - Provider string `mapstructure:"provider"` - // Specifies a list with an href where rel is provider_url. - Links []gophercloud.Link `mapstructure:"links"` -} - -// Flavor represents a mapping configuration to a CDN provider. -type Flavor struct { - // Specifies the name of the flavor. The name must not exceed 64 bytes in - // length and is limited to unicode, digits, underscores, and hyphens. - ID string `mapstructure:"id"` - // Specifies the list of providers mapped to this flavor. - Providers []Provider `mapstructure:"providers"` - // Specifies the self-navigating JSON document paths. - Links []gophercloud.Link `mapstructure:"links"` -} - -// FlavorPage is the page returned by a pager when traversing over a -// collection of CDN flavors. -type FlavorPage struct { - pagination.SinglePageBase -} - -// IsEmpty returns true if a FlavorPage contains no Flavors. -func (r FlavorPage) IsEmpty() (bool, error) { - flavors, err := ExtractFlavors(r) - if err != nil { - return true, err - } - return len(flavors) == 0, nil -} - -// ExtractFlavors extracts and returns Flavors. It is used while iterating over -// a flavors.List call. -func ExtractFlavors(page pagination.Page) ([]Flavor, error) { - var response struct { - Flavors []Flavor `json:"flavors"` - } - - err := mapstructure.Decode(page.(FlavorPage).Body, &response) - return response.Flavors, err -} - -// GetResult represents the result of a get operation. -type GetResult struct { - gophercloud.Result -} - -// Extract is a function that extracts a flavor from a GetResult. -func (r GetResult) Extract() (*Flavor, error) { - if r.Err != nil { - return nil, r.Err - } - - var res Flavor - - err := mapstructure.Decode(r.Body, &res) - - return &res, err -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/flavors/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/flavors/urls.go deleted file mode 100644 index 6eb38d2939..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/flavors/urls.go +++ /dev/null @@ -1,11 +0,0 @@ -package flavors - -import "github.com/rackspace/gophercloud" - -func listURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL("flavors") -} - -func getURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL("flavors", id) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets/doc.go deleted file mode 100644 index ceecaa5a5e..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -// Package serviceassets provides information and interaction with the -// serviceassets API resource in the OpenStack CDN service. This API resource -// allows for deleting cached assets. -// -// A service distributes assets across the network. Service assets let you -// interrogate properties about these assets and perform certain actions on them. -package serviceassets diff --git a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets/fixtures.go deleted file mode 100644 index 5c6b5d00e4..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets/fixtures.go +++ /dev/null @@ -1,19 +0,0 @@ -package serviceassets - -import ( - "net/http" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -// HandleDeleteCDNAssetSuccessfully creates an HTTP handler at `/services/{id}/assets` on the test handler mux -// that responds with a `Delete` response. -func HandleDeleteCDNAssetSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0/assets", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.WriteHeader(http.StatusAccepted) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets/requests.go deleted file mode 100644 index 1ddc65fafd..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets/requests.go +++ /dev/null @@ -1,48 +0,0 @@ -package serviceassets - -import ( - "strings" - - "github.com/rackspace/gophercloud" -) - -// DeleteOptsBuilder allows extensions to add additional parameters to the Delete -// request. -type DeleteOptsBuilder interface { - ToCDNAssetDeleteParams() (string, error) -} - -// DeleteOpts is a structure that holds options for deleting CDN service assets. -type DeleteOpts struct { - // If all is set to true, specifies that the delete occurs against all of the - // assets for the service. - All bool `q:"all"` - // Specifies the relative URL of the asset to be deleted. - URL string `q:"url"` -} - -// ToCDNAssetDeleteParams formats a DeleteOpts into a query string. -func (opts DeleteOpts) ToCDNAssetDeleteParams() (string, error) { - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return "", err - } - return q.String(), nil -} - -// Delete accepts a unique service ID or URL and deletes the CDN service asset associated with -// it. For example, both "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0" and -// "https://global.cdn.api.rackspacecloud.com/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0" -// are valid options for idOrURL. -func Delete(c *gophercloud.ServiceClient, idOrURL string, opts DeleteOptsBuilder) DeleteResult { - var url string - if strings.Contains(idOrURL, "/") { - url = idOrURL - } else { - url = deleteURL(c, idOrURL) - } - - var res DeleteResult - _, res.Err = c.Delete(url, nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets/results.go b/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets/results.go deleted file mode 100644 index 1d8734b7c3..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets/results.go +++ /dev/null @@ -1,8 +0,0 @@ -package serviceassets - -import "github.com/rackspace/gophercloud" - -// DeleteResult represents the result of a Delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets/urls.go deleted file mode 100644 index cb0aea8fca..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets/urls.go +++ /dev/null @@ -1,7 +0,0 @@ -package serviceassets - -import "github.com/rackspace/gophercloud" - -func deleteURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL("services", id, "assets") -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/doc.go deleted file mode 100644 index 41f7c60dae..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -// Package services provides information and interaction with the services API -// resource in the OpenStack CDN service. This API resource allows for -// listing, creating, updating, retrieving, and deleting services. -// -// A service represents an application that has its content cached to the edge -// nodes. -package services diff --git a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/errors.go b/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/errors.go deleted file mode 100644 index 359584c2a6..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/errors.go +++ /dev/null @@ -1,7 +0,0 @@ -package services - -import "fmt" - -func no(str string) error { - return fmt.Errorf("Required parameter %s not provided", str) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/fixtures.go deleted file mode 100644 index d9bc9f20b7..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/fixtures.go +++ /dev/null @@ -1,372 +0,0 @@ -package services - -import ( - "fmt" - "net/http" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -// HandleListCDNServiceSuccessfully creates an HTTP handler at `/services` on the test handler mux -// that responds with a `List` response. -func HandleListCDNServiceSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/services", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - r.ParseForm() - marker := r.Form.Get("marker") - switch marker { - case "": - fmt.Fprintf(w, ` - { - "links": [ - { - "rel": "next", - "href": "https://www.poppycdn.io/v1.0/services?marker=96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0&limit=20" - } - ], - "services": [ - { - "id": "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0", - "name": "mywebsite.com", - "domains": [ - { - "domain": "www.mywebsite.com" - } - ], - "origins": [ - { - "origin": "mywebsite.com", - "port": 80, - "ssl": false - } - ], - "caching": [ - { - "name": "default", - "ttl": 3600 - }, - { - "name": "home", - "ttl": 17200, - "rules": [ - { - "name": "index", - "request_url": "/index.htm" - } - ] - }, - { - "name": "images", - "ttl": 12800, - "rules": [ - { - "name": "images", - "request_url": "*.png" - } - ] - } - ], - "restrictions": [ - { - "name": "website only", - "rules": [ - { - "name": "mywebsite.com", - "referrer": "www.mywebsite.com" - } - ] - } - ], - "flavor_id": "asia", - "status": "deployed", - "errors" : [], - "links": [ - { - "href": "https://www.poppycdn.io/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0", - "rel": "self" - }, - { - "href": "mywebsite.com.cdn123.poppycdn.net", - "rel": "access_url" - }, - { - "href": "https://www.poppycdn.io/v1.0/flavors/asia", - "rel": "flavor" - } - ] - }, - { - "id": "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f1", - "name": "myothersite.com", - "domains": [ - { - "domain": "www.myothersite.com" - } - ], - "origins": [ - { - "origin": "44.33.22.11", - "port": 80, - "ssl": false - }, - { - "origin": "77.66.55.44", - "port": 80, - "ssl": false, - "rules": [ - { - "name": "videos", - "request_url": "^/videos/*.m3u" - } - ] - } - ], - "caching": [ - { - "name": "default", - "ttl": 3600 - } - ], - "restrictions": [ - {} - ], - "flavor_id": "europe", - "status": "deployed", - "links": [ - { - "href": "https://www.poppycdn.io/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f1", - "rel": "self" - }, - { - "href": "myothersite.com.poppycdn.net", - "rel": "access_url" - }, - { - "href": "https://www.poppycdn.io/v1.0/flavors/europe", - "rel": "flavor" - } - ] - } - ] - } - `) - case "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f1": - fmt.Fprintf(w, `{ - "services": [] - }`) - default: - t.Fatalf("Unexpected marker: [%s]", marker) - } - }) -} - -// HandleCreateCDNServiceSuccessfully creates an HTTP handler at `/services` on the test handler mux -// that responds with a `Create` response. -func HandleCreateCDNServiceSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/services", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestJSONRequest(t, r, ` - { - "name": "mywebsite.com", - "domains": [ - { - "domain": "www.mywebsite.com" - }, - { - "domain": "blog.mywebsite.com" - } - ], - "origins": [ - { - "origin": "mywebsite.com", - "port": 80, - "ssl": false - } - ], - "restrictions": [ - { - "name": "website only", - "rules": [ - { - "name": "mywebsite.com", - "referrer": "www.mywebsite.com" - } - ] - } - ], - "caching": [ - { - "name": "default", - "ttl": 3600 - } - ], - - "flavor_id": "cdn" - } - `) - w.Header().Add("Location", "https://global.cdn.api.rackspacecloud.com/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0") - w.WriteHeader(http.StatusAccepted) - }) -} - -// HandleGetCDNServiceSuccessfully creates an HTTP handler at `/services/{id}` on the test handler mux -// that responds with a `Get` response. -func HandleGetCDNServiceSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, ` - { - "id": "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0", - "name": "mywebsite.com", - "domains": [ - { - "domain": "www.mywebsite.com", - "protocol": "http" - } - ], - "origins": [ - { - "origin": "mywebsite.com", - "port": 80, - "ssl": false - } - ], - "caching": [ - { - "name": "default", - "ttl": 3600 - }, - { - "name": "home", - "ttl": 17200, - "rules": [ - { - "name": "index", - "request_url": "/index.htm" - } - ] - }, - { - "name": "images", - "ttl": 12800, - "rules": [ - { - "name": "images", - "request_url": "*.png" - } - ] - } - ], - "restrictions": [ - { - "name": "website only", - "rules": [ - { - "name": "mywebsite.com", - "referrer": "www.mywebsite.com" - } - ] - } - ], - "flavor_id": "cdn", - "status": "deployed", - "errors" : [], - "links": [ - { - "href": "https://global.cdn.api.rackspacecloud.com/v1.0/110011/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0", - "rel": "self" - }, - { - "href": "blog.mywebsite.com.cdn1.raxcdn.com", - "rel": "access_url" - }, - { - "href": "https://global.cdn.api.rackspacecloud.com/v1.0/110011/flavors/cdn", - "rel": "flavor" - } - ] - } - `) - }) -} - -// HandleUpdateCDNServiceSuccessfully creates an HTTP handler at `/services/{id}` on the test handler mux -// that responds with a `Update` response. -func HandleUpdateCDNServiceSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PATCH") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestJSONRequest(t, r, ` - [ - { - "op": "add", - "path": "/domains/-", - "value": {"domain": "appended.mocksite4.com"} - }, - { - "op": "add", - "path": "/domains/4", - "value": {"domain": "inserted.mocksite4.com"} - }, - { - "op": "add", - "path": "/domains", - "value": [ - {"domain": "bulkadded1.mocksite4.com"}, - {"domain": "bulkadded2.mocksite4.com"} - ] - }, - { - "op": "replace", - "path": "/origins/2", - "value": {"origin": "44.33.22.11", "port": 80, "ssl": false} - }, - { - "op": "replace", - "path": "/origins", - "value": [ - {"origin": "44.33.22.11", "port": 80, "ssl": false}, - {"origin": "55.44.33.22", "port": 443, "ssl": true} - ] - }, - { - "op": "remove", - "path": "/caching/8" - }, - { - "op": "remove", - "path": "/caching" - }, - { - "op": "replace", - "path": "/name", - "value": "differentServiceName" - } - ] - `) - w.Header().Add("Location", "https://www.poppycdn.io/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0") - w.WriteHeader(http.StatusAccepted) - }) -} - -// HandleDeleteCDNServiceSuccessfully creates an HTTP handler at `/services/{id}` on the test handler mux -// that responds with a `Delete` response. -func HandleDeleteCDNServiceSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.WriteHeader(http.StatusAccepted) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/requests.go deleted file mode 100644 index 8b37928e21..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/requests.go +++ /dev/null @@ -1,378 +0,0 @@ -package services - -import ( - "fmt" - "strings" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// ListOptsBuilder allows extensions to add additional parameters to the -// List request. -type ListOptsBuilder interface { - ToCDNServiceListQuery() (string, error) -} - -// ListOpts allows the filtering and sorting of paginated collections through -// the API. Marker and Limit are used for pagination. -type ListOpts struct { - Marker string `q:"marker"` - Limit int `q:"limit"` -} - -// ToCDNServiceListQuery formats a ListOpts into a query string. -func (opts ListOpts) ToCDNServiceListQuery() (string, error) { - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return "", err - } - return q.String(), nil -} - -// List returns a Pager which allows you to iterate over a collection of -// CDN services. It accepts a ListOpts struct, which allows for pagination via -// marker and limit. -func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { - url := listURL(c) - if opts != nil { - query, err := opts.ToCDNServiceListQuery() - if err != nil { - return pagination.Pager{Err: err} - } - url += query - } - - createPage := func(r pagination.PageResult) pagination.Page { - p := ServicePage{pagination.MarkerPageBase{PageResult: r}} - p.MarkerPageBase.Owner = p - return p - } - - pager := pagination.NewPager(c, url, createPage) - return pager -} - -// CreateOptsBuilder is the interface options structs have to satisfy in order -// to be used in the main Create operation in this package. Since many -// extensions decorate or modify the common logic, it is useful for them to -// satisfy a basic interface in order for them to be used. -type CreateOptsBuilder interface { - ToCDNServiceCreateMap() (map[string]interface{}, error) -} - -// CreateOpts is the common options struct used in this package's Create -// operation. -type CreateOpts struct { - // REQUIRED. Specifies the name of the service. The minimum length for name is - // 3. The maximum length is 256. - Name string - // REQUIRED. Specifies a list of domains used by users to access their website. - Domains []Domain - // REQUIRED. Specifies a list of origin domains or IP addresses where the - // original assets are stored. - Origins []Origin - // REQUIRED. Specifies the CDN provider flavor ID to use. For a list of - // flavors, see the operation to list the available flavors. The minimum - // length for flavor_id is 1. The maximum length is 256. - FlavorID string - // OPTIONAL. Specifies the TTL rules for the assets under this service. Supports wildcards for fine-grained control. - Caching []CacheRule - // OPTIONAL. Specifies the restrictions that define who can access assets (content from the CDN cache). - Restrictions []Restriction -} - -// ToCDNServiceCreateMap casts a CreateOpts struct to a map. -func (opts CreateOpts) ToCDNServiceCreateMap() (map[string]interface{}, error) { - s := make(map[string]interface{}) - - if opts.Name == "" { - return nil, no("Name") - } - s["name"] = opts.Name - - if opts.Domains == nil { - return nil, no("Domains") - } - for _, domain := range opts.Domains { - if domain.Domain == "" { - return nil, no("Domains[].Domain") - } - } - s["domains"] = opts.Domains - - if opts.Origins == nil { - return nil, no("Origins") - } - for _, origin := range opts.Origins { - if origin.Origin == "" { - return nil, no("Origins[].Origin") - } - if origin.Rules == nil && len(opts.Origins) > 1 { - return nil, no("Origins[].Rules") - } - for _, rule := range origin.Rules { - if rule.Name == "" { - return nil, no("Origins[].Rules[].Name") - } - if rule.RequestURL == "" { - return nil, no("Origins[].Rules[].RequestURL") - } - } - } - s["origins"] = opts.Origins - - if opts.FlavorID == "" { - return nil, no("FlavorID") - } - s["flavor_id"] = opts.FlavorID - - if opts.Caching != nil { - for _, cache := range opts.Caching { - if cache.Name == "" { - return nil, no("Caching[].Name") - } - if cache.Rules != nil { - for _, rule := range cache.Rules { - if rule.Name == "" { - return nil, no("Caching[].Rules[].Name") - } - if rule.RequestURL == "" { - return nil, no("Caching[].Rules[].RequestURL") - } - } - } - } - s["caching"] = opts.Caching - } - - if opts.Restrictions != nil { - for _, restriction := range opts.Restrictions { - if restriction.Name == "" { - return nil, no("Restrictions[].Name") - } - if restriction.Rules != nil { - for _, rule := range restriction.Rules { - if rule.Name == "" { - return nil, no("Restrictions[].Rules[].Name") - } - } - } - } - s["restrictions"] = opts.Restrictions - } - - return s, nil -} - -// Create accepts a CreateOpts struct and creates a new CDN service using the -// values provided. -func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult { - var res CreateResult - - reqBody, err := opts.ToCDNServiceCreateMap() - if err != nil { - res.Err = err - return res - } - - // Send request to API - resp, err := c.Post(createURL(c), &reqBody, nil, nil) - res.Header = resp.Header - res.Err = err - return res -} - -// Get retrieves a specific service based on its URL or its unique ID. For -// example, both "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0" and -// "https://global.cdn.api.rackspacecloud.com/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0" -// are valid options for idOrURL. -func Get(c *gophercloud.ServiceClient, idOrURL string) GetResult { - var url string - if strings.Contains(idOrURL, "/") { - url = idOrURL - } else { - url = getURL(c, idOrURL) - } - - var res GetResult - _, res.Err = c.Get(url, &res.Body, nil) - return res -} - -// Path is a JSON pointer location that indicates which service parameter is being added, replaced, -// or removed. -type Path struct { - baseElement string -} - -func (p Path) renderRoot() string { - return "/" + p.baseElement -} - -func (p Path) renderDash() string { - return fmt.Sprintf("/%s/-", p.baseElement) -} - -func (p Path) renderIndex(index int64) string { - return fmt.Sprintf("/%s/%d", p.baseElement, index) -} - -var ( - // PathDomains indicates that an update operation is to be performed on a Domain. - PathDomains = Path{baseElement: "domains"} - - // PathOrigins indicates that an update operation is to be performed on an Origin. - PathOrigins = Path{baseElement: "origins"} - - // PathCaching indicates that an update operation is to be performed on a CacheRule. - PathCaching = Path{baseElement: "caching"} -) - -type value interface { - toPatchValue() interface{} - appropriatePath() Path - renderRootOr(func(p Path) string) string -} - -// Patch represents a single update to an existing Service. Multiple updates to a service can be -// submitted at the same time. -type Patch interface { - ToCDNServiceUpdateMap() map[string]interface{} -} - -// Insertion is a Patch that requests the addition of a value (Domain, Origin, or CacheRule) to -// a Service at a fixed index. Use an Append instead to append the new value to the end of its -// collection. Pass it to the Update function as part of the Patch slice. -type Insertion struct { - Index int64 - Value value -} - -// ToCDNServiceUpdateMap converts an Insertion into a request body fragment suitable for the -// Update call. -func (i Insertion) ToCDNServiceUpdateMap() map[string]interface{} { - return map[string]interface{}{ - "op": "add", - "path": i.Value.renderRootOr(func(p Path) string { return p.renderIndex(i.Index) }), - "value": i.Value.toPatchValue(), - } -} - -// Append is a Patch that requests the addition of a value (Domain, Origin, or CacheRule) to a -// Service at the end of its respective collection. Use an Insertion instead to insert the value -// at a fixed index within the collection. Pass this to the Update function as part of its -// Patch slice. -type Append struct { - Value value -} - -// ToCDNServiceUpdateMap converts an Append into a request body fragment suitable for the -// Update call. -func (a Append) ToCDNServiceUpdateMap() map[string]interface{} { - return map[string]interface{}{ - "op": "add", - "path": a.Value.renderRootOr(func(p Path) string { return p.renderDash() }), - "value": a.Value.toPatchValue(), - } -} - -// Replacement is a Patch that alters a specific service parameter (Domain, Origin, or CacheRule) -// in-place by index. Pass it to the Update function as part of the Patch slice. -type Replacement struct { - Value value - Index int64 -} - -// ToCDNServiceUpdateMap converts a Replacement into a request body fragment suitable for the -// Update call. -func (r Replacement) ToCDNServiceUpdateMap() map[string]interface{} { - return map[string]interface{}{ - "op": "replace", - "path": r.Value.renderRootOr(func(p Path) string { return p.renderIndex(r.Index) }), - "value": r.Value.toPatchValue(), - } -} - -// NameReplacement specifically updates the Service name. Pass it to the Update function as part -// of the Patch slice. -type NameReplacement struct { - NewName string -} - -// ToCDNServiceUpdateMap converts a NameReplacement into a request body fragment suitable for the -// Update call. -func (r NameReplacement) ToCDNServiceUpdateMap() map[string]interface{} { - return map[string]interface{}{ - "op": "replace", - "path": "/name", - "value": r.NewName, - } -} - -// Removal is a Patch that requests the removal of a service parameter (Domain, Origin, or -// CacheRule) by index. Pass it to the Update function as part of the Patch slice. -type Removal struct { - Path Path - Index int64 - All bool -} - -// ToCDNServiceUpdateMap converts a Removal into a request body fragment suitable for the -// Update call. -func (r Removal) ToCDNServiceUpdateMap() map[string]interface{} { - result := map[string]interface{}{"op": "remove"} - if r.All { - result["path"] = r.Path.renderRoot() - } else { - result["path"] = r.Path.renderIndex(r.Index) - } - return result -} - -type UpdateOpts []Patch - -// Update accepts a slice of Patch operations (Insertion, Append, Replacement or Removal) and -// updates an existing CDN service using the values provided. idOrURL can be either the service's -// URL or its ID. For example, both "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0" and -// "https://global.cdn.api.rackspacecloud.com/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0" -// are valid options for idOrURL. -func Update(c *gophercloud.ServiceClient, idOrURL string, opts UpdateOpts) UpdateResult { - var url string - if strings.Contains(idOrURL, "/") { - url = idOrURL - } else { - url = updateURL(c, idOrURL) - } - - reqBody := make([]map[string]interface{}, len(opts)) - for i, patch := range opts { - reqBody[i] = patch.ToCDNServiceUpdateMap() - } - - resp, err := c.Request("PATCH", url, gophercloud.RequestOpts{ - JSONBody: &reqBody, - OkCodes: []int{202}, - }) - var result UpdateResult - result.Header = resp.Header - result.Err = err - return result -} - -// Delete accepts a service's ID or its URL and deletes the CDN service -// associated with it. For example, both "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0" and -// "https://global.cdn.api.rackspacecloud.com/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0" -// are valid options for idOrURL. -func Delete(c *gophercloud.ServiceClient, idOrURL string) DeleteResult { - var url string - if strings.Contains(idOrURL, "/") { - url = idOrURL - } else { - url = deleteURL(c, idOrURL) - } - - var res DeleteResult - _, res.Err = c.Delete(url, nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/results.go b/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/results.go deleted file mode 100644 index 33406c482b..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/results.go +++ /dev/null @@ -1,316 +0,0 @@ -package services - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" - - "github.com/mitchellh/mapstructure" -) - -// Domain represents a domain used by users to access their website. -type Domain struct { - // Specifies the domain used to access the assets on their website, for which - // a CNAME is given to the CDN provider. - Domain string `mapstructure:"domain" json:"domain"` - // Specifies the protocol used to access the assets on this domain. Only "http" - // or "https" are currently allowed. The default is "http". - Protocol string `mapstructure:"protocol" json:"protocol,omitempty"` -} - -func (d Domain) toPatchValue() interface{} { - r := make(map[string]interface{}) - r["domain"] = d.Domain - if d.Protocol != "" { - r["protocol"] = d.Protocol - } - return r -} - -func (d Domain) appropriatePath() Path { - return PathDomains -} - -func (d Domain) renderRootOr(render func(p Path) string) string { - return render(d.appropriatePath()) -} - -// DomainList provides a useful way to perform bulk operations in a single Patch. -type DomainList []Domain - -func (list DomainList) toPatchValue() interface{} { - r := make([]interface{}, len(list)) - for i, domain := range list { - r[i] = domain.toPatchValue() - } - return r -} - -func (list DomainList) appropriatePath() Path { - return PathDomains -} - -func (list DomainList) renderRootOr(_ func(p Path) string) string { - return list.appropriatePath().renderRoot() -} - -// OriginRule represents a rule that defines when an origin should be accessed. -type OriginRule struct { - // Specifies the name of this rule. - Name string `mapstructure:"name" json:"name"` - // Specifies the request URL this rule should match for this origin to be used. Regex is supported. - RequestURL string `mapstructure:"request_url" json:"request_url"` -} - -// Origin specifies a list of origin domains or IP addresses where the original assets are stored. -type Origin struct { - // Specifies the URL or IP address to pull origin content from. - Origin string `mapstructure:"origin" json:"origin"` - // Specifies the port used to access the origin. The default is port 80. - Port int `mapstructure:"port" json:"port,omitempty"` - // Specifies whether or not to use HTTPS to access the origin. The default - // is false. - SSL bool `mapstructure:"ssl" json:"ssl"` - // Specifies a collection of rules that define the conditions when this origin - // should be accessed. If there is more than one origin, the rules parameter is required. - Rules []OriginRule `mapstructure:"rules" json:"rules,omitempty"` -} - -func (o Origin) toPatchValue() interface{} { - r := make(map[string]interface{}) - r["origin"] = o.Origin - r["port"] = o.Port - r["ssl"] = o.SSL - if len(o.Rules) > 0 { - r["rules"] = make([]map[string]interface{}, len(o.Rules)) - for index, rule := range o.Rules { - submap := r["rules"].([]map[string]interface{})[index] - submap["name"] = rule.Name - submap["request_url"] = rule.RequestURL - } - } - return r -} - -func (o Origin) appropriatePath() Path { - return PathOrigins -} - -func (o Origin) renderRootOr(render func(p Path) string) string { - return render(o.appropriatePath()) -} - -// OriginList provides a useful way to perform bulk operations in a single Patch. -type OriginList []Origin - -func (list OriginList) toPatchValue() interface{} { - r := make([]interface{}, len(list)) - for i, origin := range list { - r[i] = origin.toPatchValue() - } - return r -} - -func (list OriginList) appropriatePath() Path { - return PathOrigins -} - -func (list OriginList) renderRootOr(_ func(p Path) string) string { - return list.appropriatePath().renderRoot() -} - -// TTLRule specifies a rule that determines if a TTL should be applied to an asset. -type TTLRule struct { - // Specifies the name of this rule. - Name string `mapstructure:"name" json:"name"` - // Specifies the request URL this rule should match for this TTL to be used. Regex is supported. - RequestURL string `mapstructure:"request_url" json:"request_url"` -} - -// CacheRule specifies the TTL rules for the assets under this service. -type CacheRule struct { - // Specifies the name of this caching rule. Note: 'default' is a reserved name used for the default TTL setting. - Name string `mapstructure:"name" json:"name"` - // Specifies the TTL to apply. - TTL int `mapstructure:"ttl" json:"ttl"` - // Specifies a collection of rules that determine if this TTL should be applied to an asset. - Rules []TTLRule `mapstructure:"rules" json:"rules,omitempty"` -} - -func (c CacheRule) toPatchValue() interface{} { - r := make(map[string]interface{}) - r["name"] = c.Name - r["ttl"] = c.TTL - r["rules"] = make([]map[string]interface{}, len(c.Rules)) - for index, rule := range c.Rules { - submap := r["rules"].([]map[string]interface{})[index] - submap["name"] = rule.Name - submap["request_url"] = rule.RequestURL - } - return r -} - -func (c CacheRule) appropriatePath() Path { - return PathCaching -} - -func (c CacheRule) renderRootOr(render func(p Path) string) string { - return render(c.appropriatePath()) -} - -// CacheRuleList provides a useful way to perform bulk operations in a single Patch. -type CacheRuleList []CacheRule - -func (list CacheRuleList) toPatchValue() interface{} { - r := make([]interface{}, len(list)) - for i, rule := range list { - r[i] = rule.toPatchValue() - } - return r -} - -func (list CacheRuleList) appropriatePath() Path { - return PathCaching -} - -func (list CacheRuleList) renderRootOr(_ func(p Path) string) string { - return list.appropriatePath().renderRoot() -} - -// RestrictionRule specifies a rule that determines if this restriction should be applied to an asset. -type RestrictionRule struct { - // Specifies the name of this rule. - Name string `mapstructure:"name" json:"name"` - // Specifies the http host that requests must come from. - Referrer string `mapstructure:"referrer" json:"referrer,omitempty"` -} - -// Restriction specifies a restriction that defines who can access assets (content from the CDN cache). -type Restriction struct { - // Specifies the name of this restriction. - Name string `mapstructure:"name" json:"name"` - // Specifies a collection of rules that determine if this TTL should be applied to an asset. - Rules []RestrictionRule `mapstructure:"rules" json:"rules"` -} - -// Error specifies an error that occurred during the previous service action. -type Error struct { - // Specifies an error message detailing why there is an error. - Message string `mapstructure:"message"` -} - -// Service represents a CDN service resource. -type Service struct { - // Specifies the service ID that represents distributed content. The value is - // a UUID, such as 96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0, that is generated by the server. - ID string `mapstructure:"id"` - // Specifies the name of the service. - Name string `mapstructure:"name"` - // Specifies a list of domains used by users to access their website. - Domains []Domain `mapstructure:"domains"` - // Specifies a list of origin domains or IP addresses where the original assets are stored. - Origins []Origin `mapstructure:"origins"` - // Specifies the TTL rules for the assets under this service. Supports wildcards for fine grained control. - Caching []CacheRule `mapstructure:"caching"` - // Specifies the restrictions that define who can access assets (content from the CDN cache). - Restrictions []Restriction `mapstructure:"restrictions" json:"restrictions,omitempty"` - // Specifies the CDN provider flavor ID to use. For a list of flavors, see the operation to list the available flavors. - FlavorID string `mapstructure:"flavor_id"` - // Specifies the current status of the service. - Status string `mapstructure:"status"` - // Specifies the list of errors that occurred during the previous service action. - Errors []Error `mapstructure:"errors"` - // Specifies the self-navigating JSON document paths. - Links []gophercloud.Link `mapstructure:"links"` -} - -// ServicePage is the page returned by a pager when traversing over a -// collection of CDN services. -type ServicePage struct { - pagination.MarkerPageBase -} - -// IsEmpty returns true if a ListResult contains no services. -func (r ServicePage) IsEmpty() (bool, error) { - services, err := ExtractServices(r) - if err != nil { - return true, err - } - return len(services) == 0, nil -} - -// LastMarker returns the last service in a ListResult. -func (r ServicePage) LastMarker() (string, error) { - services, err := ExtractServices(r) - if err != nil { - return "", err - } - if len(services) == 0 { - return "", nil - } - return (services[len(services)-1]).ID, nil -} - -// ExtractServices is a function that takes a ListResult and returns the services' information. -func ExtractServices(page pagination.Page) ([]Service, error) { - var response struct { - Services []Service `mapstructure:"services"` - } - - err := mapstructure.Decode(page.(ServicePage).Body, &response) - return response.Services, err -} - -// CreateResult represents the result of a Create operation. -type CreateResult struct { - gophercloud.Result -} - -// Extract is a method that extracts the location of a newly created service. -func (r CreateResult) Extract() (string, error) { - if r.Err != nil { - return "", r.Err - } - if l, ok := r.Header["Location"]; ok && len(l) > 0 { - return l[0], nil - } - return "", nil -} - -// GetResult represents the result of a get operation. -type GetResult struct { - gophercloud.Result -} - -// Extract is a function that extracts a service from a GetResult. -func (r GetResult) Extract() (*Service, error) { - if r.Err != nil { - return nil, r.Err - } - - var res Service - - err := mapstructure.Decode(r.Body, &res) - - return &res, err -} - -// UpdateResult represents the result of a Update operation. -type UpdateResult struct { - gophercloud.Result -} - -// Extract is a method that extracts the location of an updated service. -func (r UpdateResult) Extract() (string, error) { - if r.Err != nil { - return "", r.Err - } - if l, ok := r.Header["Location"]; ok && len(l) > 0 { - return l[0], nil - } - return "", nil -} - -// DeleteResult represents the result of a Delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/urls.go deleted file mode 100644 index d953d4c198..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/cdn/v1/services/urls.go +++ /dev/null @@ -1,23 +0,0 @@ -package services - -import "github.com/rackspace/gophercloud" - -func listURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL("services") -} - -func createURL(c *gophercloud.ServiceClient) string { - return listURL(c) -} - -func getURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL("services", id) -} - -func updateURL(c *gophercloud.ServiceClient, id string) string { - return getURL(c, id) -} - -func deleteURL(c *gophercloud.ServiceClient, id string) string { - return getURL(c, id) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/common/README.md b/vendor/github.com/rackspace/gophercloud/openstack/common/README.md deleted file mode 100644 index 7b55795d08..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/common/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Common Resources - -This directory is for resources that are shared by multiple services. diff --git a/vendor/github.com/rackspace/gophercloud/openstack/common/extensions/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/common/extensions/doc.go deleted file mode 100644 index 4a168f4b2c..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/common/extensions/doc.go +++ /dev/null @@ -1,15 +0,0 @@ -// Package extensions provides information and interaction with the different extensions available -// for an OpenStack service. -// -// The purpose of OpenStack API extensions is to: -// -// - Introduce new features in the API without requiring a version change. -// - Introduce vendor-specific niche functionality. -// - Act as a proving ground for experimental functionalities that might be included in a future -// version of the API. -// -// Extensions usually have tags that prevent conflicts with other extensions that define attributes -// or resources with the same names, and with core resources and attributes. -// Because an extension might not be supported by all plug-ins, its availability varies with deployments -// and the specific plug-in. -package extensions diff --git a/vendor/github.com/rackspace/gophercloud/openstack/common/extensions/errors.go b/vendor/github.com/rackspace/gophercloud/openstack/common/extensions/errors.go deleted file mode 100644 index aeec0fa756..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/common/extensions/errors.go +++ /dev/null @@ -1 +0,0 @@ -package extensions diff --git a/vendor/github.com/rackspace/gophercloud/openstack/common/extensions/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/common/extensions/fixtures.go deleted file mode 100644 index 0ed7de9f1d..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/common/extensions/fixtures.go +++ /dev/null @@ -1,91 +0,0 @@ -// +build fixtures - -package extensions - -import ( - "fmt" - "net/http" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - "github.com/rackspace/gophercloud/testhelper/client" -) - -// ListOutput provides a single page of Extension results. -const ListOutput = ` -{ - "extensions": [ - { - "updated": "2013-01-20T00:00:00-00:00", - "name": "Neutron Service Type Management", - "links": [], - "namespace": "http://docs.openstack.org/ext/neutron/service-type/api/v1.0", - "alias": "service-type", - "description": "API for retrieving service providers for Neutron advanced services" - } - ] -}` - -// GetOutput provides a single Extension result. -const GetOutput = ` -{ - "extension": { - "updated": "2013-02-03T10:00:00-00:00", - "name": "agent", - "links": [], - "namespace": "http://docs.openstack.org/ext/agent/api/v2.0", - "alias": "agent", - "description": "The agent management extension." - } -} -` - -// ListedExtension is the Extension that should be parsed from ListOutput. -var ListedExtension = Extension{ - Updated: "2013-01-20T00:00:00-00:00", - Name: "Neutron Service Type Management", - Links: []interface{}{}, - Namespace: "http://docs.openstack.org/ext/neutron/service-type/api/v1.0", - Alias: "service-type", - Description: "API for retrieving service providers for Neutron advanced services", -} - -// ExpectedExtensions is a slice containing the Extension that should be parsed from ListOutput. -var ExpectedExtensions = []Extension{ListedExtension} - -// SingleExtension is the Extension that should be parsed from GetOutput. -var SingleExtension = &Extension{ - Updated: "2013-02-03T10:00:00-00:00", - Name: "agent", - Links: []interface{}{}, - Namespace: "http://docs.openstack.org/ext/agent/api/v2.0", - Alias: "agent", - Description: "The agent management extension.", -} - -// HandleListExtensionsSuccessfully creates an HTTP handler at `/extensions` on the test handler -// mux that response with a list containing a single tenant. -func HandleListExtensionsSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/extensions", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", client.TokenID) - - w.Header().Add("Content-Type", "application/json") - - fmt.Fprintf(w, ListOutput) - }) -} - -// HandleGetExtensionSuccessfully creates an HTTP handler at `/extensions/agent` that responds with -// a JSON payload corresponding to SingleExtension. -func HandleGetExtensionSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/extensions/agent", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", client.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, GetOutput) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/common/extensions/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/common/extensions/requests.go deleted file mode 100644 index 0b71085015..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/common/extensions/requests.go +++ /dev/null @@ -1,21 +0,0 @@ -package extensions - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// Get retrieves information for a specific extension using its alias. -func Get(c *gophercloud.ServiceClient, alias string) GetResult { - var res GetResult - _, res.Err = c.Get(ExtensionURL(c, alias), &res.Body, nil) - return res -} - -// List returns a Pager which allows you to iterate over the full collection of extensions. -// It does not accept query parameters. -func List(c *gophercloud.ServiceClient) pagination.Pager { - return pagination.NewPager(c, ListExtensionURL(c), func(r pagination.PageResult) pagination.Page { - return ExtensionPage{pagination.SinglePageBase(r)} - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/common/extensions/results.go b/vendor/github.com/rackspace/gophercloud/openstack/common/extensions/results.go deleted file mode 100644 index 777d083fa0..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/common/extensions/results.go +++ /dev/null @@ -1,65 +0,0 @@ -package extensions - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// GetResult temporarily stores the result of a Get call. -// Use its Extract() method to interpret it as an Extension. -type GetResult struct { - gophercloud.Result -} - -// Extract interprets a GetResult as an Extension. -func (r GetResult) Extract() (*Extension, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Extension *Extension `json:"extension"` - } - - err := mapstructure.Decode(r.Body, &res) - - return res.Extension, err -} - -// Extension is a struct that represents an OpenStack extension. -type Extension struct { - Updated string `json:"updated" mapstructure:"updated"` - Name string `json:"name" mapstructure:"name"` - Links []interface{} `json:"links" mapstructure:"links"` - Namespace string `json:"namespace" mapstructure:"namespace"` - Alias string `json:"alias" mapstructure:"alias"` - Description string `json:"description" mapstructure:"description"` -} - -// ExtensionPage is the page returned by a pager when traversing over a collection of extensions. -type ExtensionPage struct { - pagination.SinglePageBase -} - -// IsEmpty checks whether an ExtensionPage struct is empty. -func (r ExtensionPage) IsEmpty() (bool, error) { - is, err := ExtractExtensions(r) - if err != nil { - return true, err - } - return len(is) == 0, nil -} - -// ExtractExtensions accepts a Page struct, specifically an ExtensionPage struct, and extracts the -// elements into a slice of Extension structs. -// In other words, a generic collection is mapped into a relevant slice. -func ExtractExtensions(page pagination.Page) ([]Extension, error) { - var resp struct { - Extensions []Extension `mapstructure:"extensions"` - } - - err := mapstructure.Decode(page.(ExtensionPage).Body, &resp) - - return resp.Extensions, err -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/common/extensions/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/common/extensions/urls.go deleted file mode 100644 index 6460c66bc0..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/common/extensions/urls.go +++ /dev/null @@ -1,13 +0,0 @@ -package extensions - -import "github.com/rackspace/gophercloud" - -// ExtensionURL generates the URL for an extension resource by name. -func ExtensionURL(c *gophercloud.ServiceClient, name string) string { - return c.ServiceURL("extensions", name) -} - -// ListExtensionURL generates the URL for the extensions resource collection. -func ListExtensionURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL("extensions") -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume/requests.go deleted file mode 100644 index c0ba368db7..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume/requests.go +++ /dev/null @@ -1,106 +0,0 @@ -package bootfromvolume - -import ( - "errors" - "strconv" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/openstack/compute/v2/servers" -) - -// SourceType represents the type of medium being used to create the volume. -type SourceType string - -const ( - Volume SourceType = "volume" - Snapshot SourceType = "snapshot" - Image SourceType = "image" -) - -// BlockDevice is a structure with options for booting a server instance -// from a volume. The volume may be created from an image, snapshot, or another -// volume. -type BlockDevice struct { - // BootIndex [optional] is the boot index. It defaults to 0. - BootIndex int `json:"boot_index"` - - // DeleteOnTermination [optional] specifies whether or not to delete the attached volume - // when the server is deleted. Defaults to `false`. - DeleteOnTermination bool `json:"delete_on_termination"` - - // DestinationType [optional] is the type that gets created. Possible values are "volume" - // and "local". - DestinationType string `json:"destination_type"` - - // SourceType [required] must be one of: "volume", "snapshot", "image". - SourceType SourceType `json:"source_type"` - - // UUID [required] is the unique identifier for the volume, snapshot, or image (see above) - UUID string `json:"uuid"` - - // VolumeSize [optional] is the size of the volume to create (in gigabytes). - VolumeSize int `json:"volume_size"` -} - -// CreateOptsExt is a structure that extends the server `CreateOpts` structure -// by allowing for a block device mapping. -type CreateOptsExt struct { - servers.CreateOptsBuilder - BlockDevice []BlockDevice `json:"block_device_mapping_v2,omitempty"` -} - -// ToServerCreateMap adds the block device mapping option to the base server -// creation options. -func (opts CreateOptsExt) ToServerCreateMap() (map[string]interface{}, error) { - base, err := opts.CreateOptsBuilder.ToServerCreateMap() - if err != nil { - return nil, err - } - - if len(opts.BlockDevice) == 0 { - return nil, errors.New("Required fields UUID and SourceType not set.") - } - - serverMap := base["server"].(map[string]interface{}) - - blockDevice := make([]map[string]interface{}, len(opts.BlockDevice)) - - for i, bd := range opts.BlockDevice { - if string(bd.SourceType) == "" { - return nil, errors.New("SourceType must be one of: volume, image, snapshot.") - } - - blockDevice[i] = make(map[string]interface{}) - - blockDevice[i]["source_type"] = bd.SourceType - blockDevice[i]["boot_index"] = strconv.Itoa(bd.BootIndex) - blockDevice[i]["delete_on_termination"] = strconv.FormatBool(bd.DeleteOnTermination) - blockDevice[i]["volume_size"] = strconv.Itoa(bd.VolumeSize) - if bd.UUID != "" { - blockDevice[i]["uuid"] = bd.UUID - } - if bd.DestinationType != "" { - blockDevice[i]["destination_type"] = bd.DestinationType - } - - } - serverMap["block_device_mapping_v2"] = blockDevice - - return base, nil -} - -// Create requests the creation of a server from the given block device mapping. -func Create(client *gophercloud.ServiceClient, opts servers.CreateOptsBuilder) servers.CreateResult { - var res servers.CreateResult - - reqBody, err := opts.ToServerCreateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = client.Post(createURL(client), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200, 202}, - }) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume/results.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume/results.go deleted file mode 100644 index f60329f0f3..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume/results.go +++ /dev/null @@ -1,10 +0,0 @@ -package bootfromvolume - -import ( - os "github.com/rackspace/gophercloud/openstack/compute/v2/servers" -) - -// CreateResult temporarily contains the response from a Create call. -type CreateResult struct { - os.CreateResult -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume/urls.go deleted file mode 100644 index 0cffe25ffd..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume/urls.go +++ /dev/null @@ -1,7 +0,0 @@ -package bootfromvolume - -import "github.com/rackspace/gophercloud" - -func createURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL("os-volumes_boot") -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/defsecrules/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/defsecrules/doc.go deleted file mode 100644 index 2571a1a5a7..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/defsecrules/doc.go +++ /dev/null @@ -1 +0,0 @@ -package defsecrules diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/defsecrules/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/defsecrules/fixtures.go deleted file mode 100644 index c28e492d35..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/defsecrules/fixtures.go +++ /dev/null @@ -1,108 +0,0 @@ -package defsecrules - -import ( - "fmt" - "net/http" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -const rootPath = "/os-security-group-default-rules" - -func mockListRulesResponse(t *testing.T) { - th.Mux.HandleFunc(rootPath, func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "security_group_default_rules": [ - { - "from_port": 80, - "id": "{ruleID}", - "ip_protocol": "TCP", - "ip_range": { - "cidr": "10.10.10.0/24" - }, - "to_port": 80 - } - ] -} - `) - }) -} - -func mockCreateRuleResponse(t *testing.T) { - th.Mux.HandleFunc(rootPath, func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "security_group_default_rule": { - "ip_protocol": "TCP", - "from_port": 80, - "to_port": 80, - "cidr": "10.10.12.0/24" - } -} - `) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "security_group_default_rule": { - "from_port": 80, - "id": "{ruleID}", - "ip_protocol": "TCP", - "ip_range": { - "cidr": "10.10.12.0/24" - }, - "to_port": 80 - } -} -`) - }) -} - -func mockGetRuleResponse(t *testing.T, ruleID string) { - url := rootPath + "/" + ruleID - th.Mux.HandleFunc(url, func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "security_group_default_rule": { - "id": "{ruleID}", - "from_port": 80, - "to_port": 80, - "ip_protocol": "TCP", - "ip_range": { - "cidr": "10.10.12.0/24" - } - } -} - `) - }) -} - -func mockDeleteRuleResponse(t *testing.T, ruleID string) { - url := rootPath + "/" + ruleID - th.Mux.HandleFunc(url, func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusNoContent) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/defsecrules/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/defsecrules/requests.go deleted file mode 100644 index 9f27ef172c..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/defsecrules/requests.go +++ /dev/null @@ -1,95 +0,0 @@ -package defsecrules - -import ( - "errors" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// List will return a collection of default rules. -func List(client *gophercloud.ServiceClient) pagination.Pager { - createPage := func(r pagination.PageResult) pagination.Page { - return DefaultRulePage{pagination.SinglePageBase(r)} - } - - return pagination.NewPager(client, rootURL(client), createPage) -} - -// CreateOpts represents the configuration for adding a new default rule. -type CreateOpts struct { - // Required - the lower bound of the port range that will be opened. - FromPort int `json:"from_port"` - - // Required - the upper bound of the port range that will be opened. - ToPort int `json:"to_port"` - - // Required - the protocol type that will be allowed, e.g. TCP. - IPProtocol string `json:"ip_protocol"` - - // ONLY required if FromGroupID is blank. This represents the IP range that - // will be the source of network traffic to your security group. Use - // 0.0.0.0/0 to allow all IP addresses. - CIDR string `json:"cidr,omitempty"` -} - -// CreateOptsBuilder builds the create rule options into a serializable format. -type CreateOptsBuilder interface { - ToRuleCreateMap() (map[string]interface{}, error) -} - -// ToRuleCreateMap builds the create rule options into a serializable format. -func (opts CreateOpts) ToRuleCreateMap() (map[string]interface{}, error) { - rule := make(map[string]interface{}) - - if opts.FromPort == 0 { - return rule, errors.New("A FromPort must be set") - } - if opts.ToPort == 0 { - return rule, errors.New("A ToPort must be set") - } - if opts.IPProtocol == "" { - return rule, errors.New("A IPProtocol must be set") - } - if opts.CIDR == "" { - return rule, errors.New("A CIDR must be set") - } - - rule["from_port"] = opts.FromPort - rule["to_port"] = opts.ToPort - rule["ip_protocol"] = opts.IPProtocol - rule["cidr"] = opts.CIDR - - return map[string]interface{}{"security_group_default_rule": rule}, nil -} - -// Create is the operation responsible for creating a new default rule. -func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult { - var result CreateResult - - reqBody, err := opts.ToRuleCreateMap() - if err != nil { - result.Err = err - return result - } - - _, result.Err = client.Post(rootURL(client), reqBody, &result.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - - return result -} - -// Get will return details for a particular default rule. -func Get(client *gophercloud.ServiceClient, id string) GetResult { - var result GetResult - _, result.Err = client.Get(resourceURL(client, id), &result.Body, nil) - return result -} - -// Delete will permanently delete a default rule from the project. -func Delete(client *gophercloud.ServiceClient, id string) gophercloud.ErrResult { - var result gophercloud.ErrResult - _, result.Err = client.Delete(resourceURL(client, id), nil) - return result -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/defsecrules/results.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/defsecrules/results.go deleted file mode 100644 index e588d3e327..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/defsecrules/results.go +++ /dev/null @@ -1,69 +0,0 @@ -package defsecrules - -import ( - "github.com/mitchellh/mapstructure" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups" - "github.com/rackspace/gophercloud/pagination" -) - -// DefaultRule represents a default rule - which is identical to a -// normal security rule. -type DefaultRule secgroups.Rule - -// DefaultRulePage is a single page of a DefaultRule collection. -type DefaultRulePage struct { - pagination.SinglePageBase -} - -// IsEmpty determines whether or not a page of default rules contains any results. -func (page DefaultRulePage) IsEmpty() (bool, error) { - users, err := ExtractDefaultRules(page) - if err != nil { - return false, err - } - return len(users) == 0, nil -} - -// ExtractDefaultRules returns a slice of DefaultRules contained in a single -// page of results. -func ExtractDefaultRules(page pagination.Page) ([]DefaultRule, error) { - casted := page.(DefaultRulePage).Body - var response struct { - Rules []DefaultRule `mapstructure:"security_group_default_rules"` - } - - err := mapstructure.WeakDecode(casted, &response) - - return response.Rules, err -} - -type commonResult struct { - gophercloud.Result -} - -// CreateResult represents the result of a create operation. -type CreateResult struct { - commonResult -} - -// GetResult represents the result of a get operation. -type GetResult struct { - commonResult -} - -// Extract will extract a DefaultRule struct from most responses. -func (r commonResult) Extract() (*DefaultRule, error) { - if r.Err != nil { - return nil, r.Err - } - - var response struct { - Rule DefaultRule `mapstructure:"security_group_default_rule"` - } - - err := mapstructure.WeakDecode(r.Body, &response) - - return &response.Rule, err -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/defsecrules/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/defsecrules/urls.go deleted file mode 100644 index cc928ab895..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/defsecrules/urls.go +++ /dev/null @@ -1,13 +0,0 @@ -package defsecrules - -import "github.com/rackspace/gophercloud" - -const rulepath = "os-security-group-default-rules" - -func resourceURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(rulepath, id) -} - -func rootURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(rulepath) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/delegate.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/delegate.go deleted file mode 100644 index 10079097b6..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/delegate.go +++ /dev/null @@ -1,23 +0,0 @@ -package extensions - -import ( - "github.com/rackspace/gophercloud" - common "github.com/rackspace/gophercloud/openstack/common/extensions" - "github.com/rackspace/gophercloud/pagination" -) - -// ExtractExtensions interprets a Page as a slice of Extensions. -func ExtractExtensions(page pagination.Page) ([]common.Extension, error) { - return common.ExtractExtensions(page) -} - -// Get retrieves information for a specific extension using its alias. -func Get(c *gophercloud.ServiceClient, alias string) common.GetResult { - return common.Get(c, alias) -} - -// List returns a Pager which allows you to iterate over the full collection of extensions. -// It does not accept query parameters. -func List(c *gophercloud.ServiceClient) pagination.Pager { - return common.List(c) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/diskconfig/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/diskconfig/doc.go deleted file mode 100644 index 80785faca9..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/diskconfig/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package diskconfig provides information and interaction with the Disk -// Config extension that works with the OpenStack Compute service. -package diskconfig diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/diskconfig/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/diskconfig/requests.go deleted file mode 100644 index 7407e0d175..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/diskconfig/requests.go +++ /dev/null @@ -1,114 +0,0 @@ -package diskconfig - -import ( - "errors" - - "github.com/rackspace/gophercloud/openstack/compute/v2/servers" -) - -// DiskConfig represents one of the two possible settings for the DiskConfig option when creating, -// rebuilding, or resizing servers: Auto or Manual. -type DiskConfig string - -const ( - // Auto builds a server with a single partition the size of the target flavor disk and - // automatically adjusts the filesystem to fit the entire partition. Auto may only be used with - // images and servers that use a single EXT3 partition. - Auto DiskConfig = "AUTO" - - // Manual builds a server using whatever partition scheme and filesystem are present in the source - // image. If the target flavor disk is larger, the remaining space is left unpartitioned. This - // enables images to have non-EXT3 filesystems, multiple partitions, and so on, and enables you - // to manage the disk configuration. It also results in slightly shorter boot times. - Manual DiskConfig = "MANUAL" -) - -// ErrInvalidDiskConfig is returned if an invalid string is specified for a DiskConfig option. -var ErrInvalidDiskConfig = errors.New("DiskConfig must be either diskconfig.Auto or diskconfig.Manual.") - -// Validate ensures that a DiskConfig contains an appropriate value. -func (config DiskConfig) validate() error { - switch config { - case Auto, Manual: - return nil - default: - return ErrInvalidDiskConfig - } -} - -// CreateOptsExt adds a DiskConfig option to the base CreateOpts. -type CreateOptsExt struct { - servers.CreateOptsBuilder - - // DiskConfig [optional] controls how the created server's disk is partitioned. - DiskConfig DiskConfig `json:"OS-DCF:diskConfig,omitempty"` -} - -// ToServerCreateMap adds the diskconfig option to the base server creation options. -func (opts CreateOptsExt) ToServerCreateMap() (map[string]interface{}, error) { - base, err := opts.CreateOptsBuilder.ToServerCreateMap() - if err != nil { - return nil, err - } - - if string(opts.DiskConfig) == "" { - return base, nil - } - - serverMap := base["server"].(map[string]interface{}) - serverMap["OS-DCF:diskConfig"] = string(opts.DiskConfig) - - return base, nil -} - -// RebuildOptsExt adds a DiskConfig option to the base RebuildOpts. -type RebuildOptsExt struct { - servers.RebuildOptsBuilder - - // DiskConfig [optional] controls how the rebuilt server's disk is partitioned. - DiskConfig DiskConfig -} - -// ToServerRebuildMap adds the diskconfig option to the base server rebuild options. -func (opts RebuildOptsExt) ToServerRebuildMap() (map[string]interface{}, error) { - err := opts.DiskConfig.validate() - if err != nil { - return nil, err - } - - base, err := opts.RebuildOptsBuilder.ToServerRebuildMap() - if err != nil { - return nil, err - } - - serverMap := base["rebuild"].(map[string]interface{}) - serverMap["OS-DCF:diskConfig"] = string(opts.DiskConfig) - - return base, nil -} - -// ResizeOptsExt adds a DiskConfig option to the base server resize options. -type ResizeOptsExt struct { - servers.ResizeOptsBuilder - - // DiskConfig [optional] controls how the resized server's disk is partitioned. - DiskConfig DiskConfig -} - -// ToServerResizeMap adds the diskconfig option to the base server creation options. -func (opts ResizeOptsExt) ToServerResizeMap() (map[string]interface{}, error) { - err := opts.DiskConfig.validate() - if err != nil { - return nil, err - } - - base, err := opts.ResizeOptsBuilder.ToServerResizeMap() - if err != nil { - return nil, err - } - - serverMap := base["resize"].(map[string]interface{}) - serverMap["OS-DCF:diskConfig"] = string(opts.DiskConfig) - - return base, nil -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/diskconfig/results.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/diskconfig/results.go deleted file mode 100644 index 10ec2dafcb..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/diskconfig/results.go +++ /dev/null @@ -1,60 +0,0 @@ -package diskconfig - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/openstack/compute/v2/servers" - "github.com/rackspace/gophercloud/pagination" -) - -func commonExtract(result gophercloud.Result) (*DiskConfig, error) { - var resp struct { - Server struct { - DiskConfig string `mapstructure:"OS-DCF:diskConfig"` - } `mapstructure:"server"` - } - - err := mapstructure.Decode(result.Body, &resp) - if err != nil { - return nil, err - } - - config := DiskConfig(resp.Server.DiskConfig) - return &config, nil -} - -// ExtractGet returns the disk configuration from a servers.Get call. -func ExtractGet(result servers.GetResult) (*DiskConfig, error) { - return commonExtract(result.Result) -} - -// ExtractUpdate returns the disk configuration from a servers.Update call. -func ExtractUpdate(result servers.UpdateResult) (*DiskConfig, error) { - return commonExtract(result.Result) -} - -// ExtractRebuild returns the disk configuration from a servers.Rebuild call. -func ExtractRebuild(result servers.RebuildResult) (*DiskConfig, error) { - return commonExtract(result.Result) -} - -// ExtractDiskConfig returns the DiskConfig setting for a specific server acquired from an -// servers.ExtractServers call, while iterating through a Pager. -func ExtractDiskConfig(page pagination.Page, index int) (*DiskConfig, error) { - casted := page.(servers.ServerPage).Body - - type server struct { - DiskConfig string `mapstructure:"OS-DCF:diskConfig"` - } - var response struct { - Servers []server `mapstructure:"servers"` - } - - err := mapstructure.Decode(casted, &response) - if err != nil { - return nil, err - } - - config := DiskConfig(response.Servers[index].DiskConfig) - return &config, nil -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/doc.go deleted file mode 100644 index 2b447da1d6..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package extensions provides information and interaction with the -// different extensions available for the OpenStack Compute service. -package extensions diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/doc.go deleted file mode 100644 index 702f32c985..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/doc.go +++ /dev/null @@ -1 +0,0 @@ -package secgroups diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/fixtures.go deleted file mode 100644 index 1c6ba39492..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/fixtures.go +++ /dev/null @@ -1,265 +0,0 @@ -package secgroups - -import ( - "fmt" - "net/http" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -const rootPath = "/os-security-groups" - -const listGroupsJSON = ` -{ - "security_groups": [ - { - "description": "default", - "id": "{groupID}", - "name": "default", - "rules": [], - "tenant_id": "openstack" - } - ] -} -` - -func mockListGroupsResponse(t *testing.T) { - th.Mux.HandleFunc(rootPath, func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, listGroupsJSON) - }) -} - -func mockListGroupsByServerResponse(t *testing.T, serverID string) { - url := fmt.Sprintf("/servers/%s%s", serverID, rootPath) - th.Mux.HandleFunc(url, func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, listGroupsJSON) - }) -} - -func mockCreateGroupResponse(t *testing.T) { - th.Mux.HandleFunc(rootPath, func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "security_group": { - "name": "test", - "description": "something" - } -} - `) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "security_group": { - "description": "something", - "id": "{groupID}", - "name": "test", - "rules": [], - "tenant_id": "openstack" - } -} -`) - }) -} - -func mockUpdateGroupResponse(t *testing.T, groupID string) { - url := fmt.Sprintf("%s/%s", rootPath, groupID) - th.Mux.HandleFunc(url, func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PUT") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "security_group": { - "name": "new_name", - "description": "new_desc" - } -} - `) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "security_group": { - "description": "something", - "id": "{groupID}", - "name": "new_name", - "rules": [], - "tenant_id": "openstack" - } -} -`) - }) -} - -func mockGetGroupsResponse(t *testing.T, groupID string) { - url := fmt.Sprintf("%s/%s", rootPath, groupID) - th.Mux.HandleFunc(url, func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "security_group": { - "description": "default", - "id": "{groupID}", - "name": "default", - "rules": [ - { - "from_port": 80, - "group": { - "tenant_id": "openstack", - "name": "default" - }, - "ip_protocol": "TCP", - "to_port": 85, - "parent_group_id": "{groupID}", - "ip_range": { - "cidr": "0.0.0.0" - }, - "id": "{ruleID}" - } - ], - "tenant_id": "openstack" - } -} - `) - }) -} - -func mockGetNumericIDGroupResponse(t *testing.T, groupID int) { - url := fmt.Sprintf("%s/%d", rootPath, groupID) - th.Mux.HandleFunc(url, func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "security_group": { - "id": 12345 - } -} - `) - }) -} - -func mockDeleteGroupResponse(t *testing.T, groupID string) { - url := fmt.Sprintf("%s/%s", rootPath, groupID) - th.Mux.HandleFunc(url, func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusAccepted) - }) -} - -func mockAddRuleResponse(t *testing.T) { - th.Mux.HandleFunc("/os-security-group-rules", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "security_group_rule": { - "from_port": 22, - "ip_protocol": "TCP", - "to_port": 22, - "parent_group_id": "{groupID}", - "cidr": "0.0.0.0/0" - } -} `) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "security_group_rule": { - "from_port": 22, - "group": {}, - "ip_protocol": "TCP", - "to_port": 22, - "parent_group_id": "{groupID}", - "ip_range": { - "cidr": "0.0.0.0/0" - }, - "id": "{ruleID}" - } -}`) - }) -} - -func mockDeleteRuleResponse(t *testing.T, ruleID string) { - url := fmt.Sprintf("/os-security-group-rules/%s", ruleID) - th.Mux.HandleFunc(url, func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusAccepted) - }) -} - -func mockAddServerToGroupResponse(t *testing.T, serverID string) { - url := fmt.Sprintf("/servers/%s/action", serverID) - th.Mux.HandleFunc(url, func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "addSecurityGroup": { - "name": "test" - } -} - `) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusAccepted) - }) -} - -func mockRemoveServerFromGroupResponse(t *testing.T, serverID string) { - url := fmt.Sprintf("/servers/%s/action", serverID) - th.Mux.HandleFunc(url, func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "removeSecurityGroup": { - "name": "test" - } -} - `) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusAccepted) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/requests.go deleted file mode 100644 index 4cef480222..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/requests.go +++ /dev/null @@ -1,257 +0,0 @@ -package secgroups - -import ( - "errors" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -func commonList(client *gophercloud.ServiceClient, url string) pagination.Pager { - createPage := func(r pagination.PageResult) pagination.Page { - return SecurityGroupPage{pagination.SinglePageBase(r)} - } - - return pagination.NewPager(client, url, createPage) -} - -// List will return a collection of all the security groups for a particular -// tenant. -func List(client *gophercloud.ServiceClient) pagination.Pager { - return commonList(client, rootURL(client)) -} - -// ListByServer will return a collection of all the security groups which are -// associated with a particular server. -func ListByServer(client *gophercloud.ServiceClient, serverID string) pagination.Pager { - return commonList(client, listByServerURL(client, serverID)) -} - -// GroupOpts is the underlying struct responsible for creating or updating -// security groups. It therefore represents the mutable attributes of a -// security group. -type GroupOpts struct { - // Required - the name of your security group. - Name string `json:"name"` - - // Required - the description of your security group. - Description string `json:"description"` -} - -// CreateOpts is the struct responsible for creating a security group. -type CreateOpts GroupOpts - -// CreateOptsBuilder builds the create options into a serializable format. -type CreateOptsBuilder interface { - ToSecGroupCreateMap() (map[string]interface{}, error) -} - -var ( - errName = errors.New("Name is a required field") - errDesc = errors.New("Description is a required field") -) - -// ToSecGroupCreateMap builds the create options into a serializable format. -func (opts CreateOpts) ToSecGroupCreateMap() (map[string]interface{}, error) { - sg := make(map[string]interface{}) - - if opts.Name == "" { - return sg, errName - } - if opts.Description == "" { - return sg, errDesc - } - - sg["name"] = opts.Name - sg["description"] = opts.Description - - return map[string]interface{}{"security_group": sg}, nil -} - -// Create will create a new security group. -func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult { - var result CreateResult - - reqBody, err := opts.ToSecGroupCreateMap() - if err != nil { - result.Err = err - return result - } - - _, result.Err = client.Post(rootURL(client), reqBody, &result.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - - return result -} - -// UpdateOpts is the struct responsible for updating an existing security group. -type UpdateOpts GroupOpts - -// UpdateOptsBuilder builds the update options into a serializable format. -type UpdateOptsBuilder interface { - ToSecGroupUpdateMap() (map[string]interface{}, error) -} - -// ToSecGroupUpdateMap builds the update options into a serializable format. -func (opts UpdateOpts) ToSecGroupUpdateMap() (map[string]interface{}, error) { - sg := make(map[string]interface{}) - - if opts.Name == "" { - return sg, errName - } - if opts.Description == "" { - return sg, errDesc - } - - sg["name"] = opts.Name - sg["description"] = opts.Description - - return map[string]interface{}{"security_group": sg}, nil -} - -// Update will modify the mutable properties of a security group, notably its -// name and description. -func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) UpdateResult { - var result UpdateResult - - reqBody, err := opts.ToSecGroupUpdateMap() - if err != nil { - result.Err = err - return result - } - - _, result.Err = client.Put(resourceURL(client, id), reqBody, &result.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - - return result -} - -// Get will return details for a particular security group. -func Get(client *gophercloud.ServiceClient, id string) GetResult { - var result GetResult - _, result.Err = client.Get(resourceURL(client, id), &result.Body, nil) - return result -} - -// Delete will permanently delete a security group from the project. -func Delete(client *gophercloud.ServiceClient, id string) gophercloud.ErrResult { - var result gophercloud.ErrResult - _, result.Err = client.Delete(resourceURL(client, id), nil) - return result -} - -// CreateRuleOpts represents the configuration for adding a new rule to an -// existing security group. -type CreateRuleOpts struct { - // Required - the ID of the group that this rule will be added to. - ParentGroupID string `json:"parent_group_id"` - - // Required - the lower bound of the port range that will be opened. - FromPort int `json:"from_port"` - - // Required - the upper bound of the port range that will be opened. - ToPort int `json:"to_port"` - - // Required - the protocol type that will be allowed, e.g. TCP. - IPProtocol string `json:"ip_protocol"` - - // ONLY required if FromGroupID is blank. This represents the IP range that - // will be the source of network traffic to your security group. Use - // 0.0.0.0/0 to allow all IP addresses. - CIDR string `json:"cidr,omitempty"` - - // ONLY required if CIDR is blank. This value represents the ID of a group - // that forwards traffic to the parent group. So, instead of accepting - // network traffic from an entire IP range, you can instead refine the - // inbound source by an existing security group. - FromGroupID string `json:"group_id,omitempty"` -} - -// CreateRuleOptsBuilder builds the create rule options into a serializable format. -type CreateRuleOptsBuilder interface { - ToRuleCreateMap() (map[string]interface{}, error) -} - -// ToRuleCreateMap builds the create rule options into a serializable format. -func (opts CreateRuleOpts) ToRuleCreateMap() (map[string]interface{}, error) { - rule := make(map[string]interface{}) - - if opts.ParentGroupID == "" { - return rule, errors.New("A ParentGroupID must be set") - } - if opts.FromPort == 0 { - return rule, errors.New("A FromPort must be set") - } - if opts.ToPort == 0 { - return rule, errors.New("A ToPort must be set") - } - if opts.IPProtocol == "" { - return rule, errors.New("A IPProtocol must be set") - } - if opts.CIDR == "" && opts.FromGroupID == "" { - return rule, errors.New("A CIDR or FromGroupID must be set") - } - - rule["parent_group_id"] = opts.ParentGroupID - rule["from_port"] = opts.FromPort - rule["to_port"] = opts.ToPort - rule["ip_protocol"] = opts.IPProtocol - - if opts.CIDR != "" { - rule["cidr"] = opts.CIDR - } - if opts.FromGroupID != "" { - rule["group_id"] = opts.FromGroupID - } - - return map[string]interface{}{"security_group_rule": rule}, nil -} - -// CreateRule will add a new rule to an existing security group (whose ID is -// specified in CreateRuleOpts). You have the option of controlling inbound -// traffic from either an IP range (CIDR) or from another security group. -func CreateRule(client *gophercloud.ServiceClient, opts CreateRuleOptsBuilder) CreateRuleResult { - var result CreateRuleResult - - reqBody, err := opts.ToRuleCreateMap() - if err != nil { - result.Err = err - return result - } - - _, result.Err = client.Post(rootRuleURL(client), reqBody, &result.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - - return result -} - -// DeleteRule will permanently delete a rule from a security group. -func DeleteRule(client *gophercloud.ServiceClient, id string) gophercloud.ErrResult { - var result gophercloud.ErrResult - _, result.Err = client.Delete(resourceRuleURL(client, id), nil) - return result -} - -func actionMap(prefix, groupName string) map[string]map[string]string { - return map[string]map[string]string{ - prefix + "SecurityGroup": map[string]string{"name": groupName}, - } -} - -// AddServerToGroup will associate a server and a security group, enforcing the -// rules of the group on the server. -func AddServerToGroup(client *gophercloud.ServiceClient, serverID, groupName string) gophercloud.ErrResult { - var result gophercloud.ErrResult - _, result.Err = client.Post(serverActionURL(client, serverID), actionMap("add", groupName), &result.Body, nil) - return result -} - -// RemoveServerFromGroup will disassociate a server from a security group. -func RemoveServerFromGroup(client *gophercloud.ServiceClient, serverID, groupName string) gophercloud.ErrResult { - var result gophercloud.ErrResult - _, result.Err = client.Post(serverActionURL(client, serverID), actionMap("remove", groupName), &result.Body, nil) - return result -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/results.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/results.go deleted file mode 100644 index 478c5dc097..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/results.go +++ /dev/null @@ -1,147 +0,0 @@ -package secgroups - -import ( - "github.com/mitchellh/mapstructure" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// SecurityGroup represents a security group. -type SecurityGroup struct { - // The unique ID of the group. If Neutron is installed, this ID will be - // represented as a string UUID; if Neutron is not installed, it will be a - // numeric ID. For the sake of consistency, we always cast it to a string. - ID string - - // The human-readable name of the group, which needs to be unique. - Name string - - // The human-readable description of the group. - Description string - - // The rules which determine how this security group operates. - Rules []Rule - - // The ID of the tenant to which this security group belongs. - TenantID string `mapstructure:"tenant_id"` -} - -// Rule represents a security group rule, a policy which determines how a -// security group operates and what inbound traffic it allows in. -type Rule struct { - // The unique ID. If Neutron is installed, this ID will be - // represented as a string UUID; if Neutron is not installed, it will be a - // numeric ID. For the sake of consistency, we always cast it to a string. - ID string - - // The lower bound of the port range which this security group should open up - FromPort int `mapstructure:"from_port"` - - // The upper bound of the port range which this security group should open up - ToPort int `mapstructure:"to_port"` - - // The IP protocol (e.g. TCP) which the security group accepts - IPProtocol string `mapstructure:"ip_protocol"` - - // The CIDR IP range whose traffic can be received - IPRange IPRange `mapstructure:"ip_range"` - - // The security group ID to which this rule belongs - ParentGroupID string `mapstructure:"parent_group_id"` - - // Not documented. - Group Group -} - -// IPRange represents the IP range whose traffic will be accepted by the -// security group. -type IPRange struct { - CIDR string -} - -// Group represents a group. -type Group struct { - TenantID string `mapstructure:"tenant_id"` - Name string -} - -// SecurityGroupPage is a single page of a SecurityGroup collection. -type SecurityGroupPage struct { - pagination.SinglePageBase -} - -// IsEmpty determines whether or not a page of Security Groups contains any results. -func (page SecurityGroupPage) IsEmpty() (bool, error) { - users, err := ExtractSecurityGroups(page) - if err != nil { - return false, err - } - return len(users) == 0, nil -} - -// ExtractSecurityGroups returns a slice of SecurityGroups contained in a single page of results. -func ExtractSecurityGroups(page pagination.Page) ([]SecurityGroup, error) { - casted := page.(SecurityGroupPage).Body - var response struct { - SecurityGroups []SecurityGroup `mapstructure:"security_groups"` - } - - err := mapstructure.WeakDecode(casted, &response) - - return response.SecurityGroups, err -} - -type commonResult struct { - gophercloud.Result -} - -// CreateResult represents the result of a create operation. -type CreateResult struct { - commonResult -} - -// GetResult represents the result of a get operation. -type GetResult struct { - commonResult -} - -// UpdateResult represents the result of an update operation. -type UpdateResult struct { - commonResult -} - -// Extract will extract a SecurityGroup struct from most responses. -func (r commonResult) Extract() (*SecurityGroup, error) { - if r.Err != nil { - return nil, r.Err - } - - var response struct { - SecurityGroup SecurityGroup `mapstructure:"security_group"` - } - - err := mapstructure.WeakDecode(r.Body, &response) - - return &response.SecurityGroup, err -} - -// CreateRuleResult represents the result when adding rules to a security group. -type CreateRuleResult struct { - gophercloud.Result -} - -// Extract will extract a Rule struct from a CreateRuleResult. -func (r CreateRuleResult) Extract() (*Rule, error) { - if r.Err != nil { - return nil, r.Err - } - - var response struct { - Rule Rule `mapstructure:"security_group_rule"` - } - - err := mapstructure.WeakDecode(r.Body, &response) - - return &response.Rule, err -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/urls.go deleted file mode 100644 index dc53fbfac6..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/urls.go +++ /dev/null @@ -1,32 +0,0 @@ -package secgroups - -import "github.com/rackspace/gophercloud" - -const ( - secgrouppath = "os-security-groups" - rulepath = "os-security-group-rules" -) - -func resourceURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(secgrouppath, id) -} - -func rootURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(secgrouppath) -} - -func listByServerURL(c *gophercloud.ServiceClient, serverID string) string { - return c.ServiceURL("servers", serverID, secgrouppath) -} - -func rootRuleURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(rulepath) -} - -func resourceRuleURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(rulepath, id) -} - -func serverActionURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL("servers", id, "action") -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks/doc.go deleted file mode 100644 index 65c46ff507..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks/doc.go +++ /dev/null @@ -1,2 +0,0 @@ -// Package tenantnetworks provides the ability for tenants to see information about the networks they have access to -package tenantnetworks diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks/fixtures.go deleted file mode 100644 index 0cfa72ab06..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks/fixtures.go +++ /dev/null @@ -1,84 +0,0 @@ -// +build fixtures - -package tenantnetworks - -import ( - "fmt" - "net/http" - "testing" - "time" - - th "github.com/rackspace/gophercloud/testhelper" - "github.com/rackspace/gophercloud/testhelper/client" -) - -// ListOutput is a sample response to a List call. -const ListOutput = ` -{ - "networks": [ - { - "cidr": "10.0.0.0/29", - "id": "20c8acc0-f747-4d71-a389-46d078ebf047", - "label": "mynet_0" - }, - { - "cidr": "10.0.0.10/29", - "id": "20c8acc0-f747-4d71-a389-46d078ebf000", - "label": "mynet_1" - } - ] -} -` - -// GetOutput is a sample response to a Get call. -const GetOutput = ` -{ - "network": { - "cidr": "10.0.0.10/29", - "id": "20c8acc0-f747-4d71-a389-46d078ebf000", - "label": "mynet_1" - } -} -` - -// FirstNetwork is the first result in ListOutput. -var nilTime time.Time -var FirstNetwork = Network{ - CIDR: "10.0.0.0/29", - ID: "20c8acc0-f747-4d71-a389-46d078ebf047", - Name: "mynet_0", -} - -// SecondNetwork is the second result in ListOutput. -var SecondNetwork = Network{ - CIDR: "10.0.0.10/29", - ID: "20c8acc0-f747-4d71-a389-46d078ebf000", - Name: "mynet_1", -} - -// ExpectedNetworkSlice is the slice of results that should be parsed -// from ListOutput, in the expected order. -var ExpectedNetworkSlice = []Network{FirstNetwork, SecondNetwork} - -// HandleListSuccessfully configures the test server to respond to a List request. -func HandleListSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/os-tenant-networks", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", client.TokenID) - - w.Header().Add("Content-Type", "application/json") - fmt.Fprintf(w, ListOutput) - }) -} - -// HandleGetSuccessfully configures the test server to respond to a Get request -// for an existing network. -func HandleGetSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/os-tenant-networks/20c8acc0-f747-4d71-a389-46d078ebf000", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", client.TokenID) - - w.Header().Add("Content-Type", "application/json") - fmt.Fprintf(w, GetOutput) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks/requests.go deleted file mode 100644 index 3ec13d384b..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks/requests.go +++ /dev/null @@ -1,22 +0,0 @@ -package tenantnetworks - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// List returns a Pager that allows you to iterate over a collection of Network. -func List(client *gophercloud.ServiceClient) pagination.Pager { - url := listURL(client) - createPage := func(r pagination.PageResult) pagination.Page { - return NetworkPage{pagination.SinglePageBase(r)} - } - return pagination.NewPager(client, url, createPage) -} - -// Get returns data about a previously created Network. -func Get(client *gophercloud.ServiceClient, id string) GetResult { - var res GetResult - _, res.Err = client.Get(getURL(client, id), &res.Body, nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks/results.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks/results.go deleted file mode 100644 index 805009247a..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks/results.go +++ /dev/null @@ -1,68 +0,0 @@ -package tenantnetworks - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// A Network represents a nova-network that an instance communicates on -type Network struct { - // CIDR is the IPv4 subnet. - CIDR string `mapstructure:"cidr"` - - // ID is the UUID of the network. - ID string `mapstructure:"id"` - - // Name is the common name that the network has. - Name string `mapstructure:"label"` -} - -// NetworkPage stores a single, only page of Networks -// results from a List call. -type NetworkPage struct { - pagination.SinglePageBase -} - -// IsEmpty determines whether or not a NetworkPage is empty. -func (page NetworkPage) IsEmpty() (bool, error) { - va, err := ExtractNetworks(page) - return len(va) == 0, err -} - -// ExtractNetworks interprets a page of results as a slice of Networks -func ExtractNetworks(page pagination.Page) ([]Network, error) { - networks := page.(NetworkPage).Body - var res struct { - Networks []Network `mapstructure:"networks"` - } - - err := mapstructure.WeakDecode(networks, &res) - - return res.Networks, err -} - -type NetworkResult struct { - gophercloud.Result -} - -// Extract is a method that attempts to interpret any Network resource -// response as a Network struct. -func (r NetworkResult) Extract() (*Network, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Network *Network `json:"network" mapstructure:"network"` - } - - err := mapstructure.Decode(r.Body, &res) - return res.Network, err -} - -// GetResult is the response from a Get operation. Call its Extract method to interpret it -// as a Network. -type GetResult struct { - NetworkResult -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks/urls.go deleted file mode 100644 index 2401a5d038..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks/urls.go +++ /dev/null @@ -1,17 +0,0 @@ -package tenantnetworks - -import "github.com/rackspace/gophercloud" - -const resourcePath = "os-tenant-networks" - -func resourceURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(resourcePath) -} - -func listURL(c *gophercloud.ServiceClient) string { - return resourceURL(c) -} - -func getURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(resourcePath, id) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach/doc.go deleted file mode 100644 index 22f68d80e5..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package volumeattach provides the ability to attach and detach volumes -// to instances -package volumeattach diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach/fixtures.go deleted file mode 100644 index a7f03b322c..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach/fixtures.go +++ /dev/null @@ -1,138 +0,0 @@ -// +build fixtures - -package volumeattach - -import ( - "fmt" - "net/http" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - "github.com/rackspace/gophercloud/testhelper/client" -) - -// ListOutput is a sample response to a List call. -const ListOutput = ` -{ - "volumeAttachments": [ - { - "device": "/dev/vdd", - "id": "a26887c6-c47b-4654-abb5-dfadf7d3f803", - "serverId": "4d8c3732-a248-40ed-bebc-539a6ffd25c0", - "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803" - }, - { - "device": "/dev/vdc", - "id": "a26887c6-c47b-4654-abb5-dfadf7d3f804", - "serverId": "4d8c3732-a248-40ed-bebc-539a6ffd25c0", - "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f804" - } - ] -} -` - -// GetOutput is a sample response to a Get call. -const GetOutput = ` -{ - "volumeAttachment": { - "device": "/dev/vdc", - "id": "a26887c6-c47b-4654-abb5-dfadf7d3f804", - "serverId": "4d8c3732-a248-40ed-bebc-539a6ffd25c0", - "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f804" - } -} -` - -// CreateOutput is a sample response to a Create call. -const CreateOutput = ` -{ - "volumeAttachment": { - "device": "/dev/vdc", - "id": "a26887c6-c47b-4654-abb5-dfadf7d3f804", - "serverId": "4d8c3732-a248-40ed-bebc-539a6ffd25c0", - "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f804" - } -} -` - -// FirstVolumeAttachment is the first result in ListOutput. -var FirstVolumeAttachment = VolumeAttachment{ - Device: "/dev/vdd", - ID: "a26887c6-c47b-4654-abb5-dfadf7d3f803", - ServerID: "4d8c3732-a248-40ed-bebc-539a6ffd25c0", - VolumeID: "a26887c6-c47b-4654-abb5-dfadf7d3f803", -} - -// SecondVolumeAttachment is the first result in ListOutput. -var SecondVolumeAttachment = VolumeAttachment{ - Device: "/dev/vdc", - ID: "a26887c6-c47b-4654-abb5-dfadf7d3f804", - ServerID: "4d8c3732-a248-40ed-bebc-539a6ffd25c0", - VolumeID: "a26887c6-c47b-4654-abb5-dfadf7d3f804", -} - -// ExpectedVolumeAttachmentSlide is the slice of results that should be parsed -// from ListOutput, in the expected order. -var ExpectedVolumeAttachmentSlice = []VolumeAttachment{FirstVolumeAttachment, SecondVolumeAttachment} - -// CreatedVolumeAttachment is the parsed result from CreatedOutput. -var CreatedVolumeAttachment = VolumeAttachment{ - Device: "/dev/vdc", - ID: "a26887c6-c47b-4654-abb5-dfadf7d3f804", - ServerID: "4d8c3732-a248-40ed-bebc-539a6ffd25c0", - VolumeID: "a26887c6-c47b-4654-abb5-dfadf7d3f804", -} - -// HandleListSuccessfully configures the test server to respond to a List request. -func HandleListSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/servers/4d8c3732-a248-40ed-bebc-539a6ffd25c0/os-volume_attachments", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", client.TokenID) - - w.Header().Add("Content-Type", "application/json") - fmt.Fprintf(w, ListOutput) - }) -} - -// HandleGetSuccessfully configures the test server to respond to a Get request -// for an existing attachment -func HandleGetSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/servers/4d8c3732-a248-40ed-bebc-539a6ffd25c0/os-volume_attachments/a26887c6-c47b-4654-abb5-dfadf7d3f804", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", client.TokenID) - - w.Header().Add("Content-Type", "application/json") - fmt.Fprintf(w, GetOutput) - }) -} - -// HandleCreateSuccessfully configures the test server to respond to a Create request -// for a new attachment -func HandleCreateSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/servers/4d8c3732-a248-40ed-bebc-539a6ffd25c0/os-volume_attachments", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", client.TokenID) - th.TestJSONRequest(t, r, ` -{ - "volumeAttachment": { - "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f804", - "device": "/dev/vdc" - } -} -`) - - w.Header().Add("Content-Type", "application/json") - fmt.Fprintf(w, CreateOutput) - }) -} - -// HandleDeleteSuccessfully configures the test server to respond to a Delete request for a -// an existing attachment -func HandleDeleteSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/servers/4d8c3732-a248-40ed-bebc-539a6ffd25c0/os-volume_attachments/a26887c6-c47b-4654-abb5-dfadf7d3f804", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", client.TokenID) - - w.WriteHeader(http.StatusAccepted) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach/requests.go deleted file mode 100644 index b4ebedea86..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach/requests.go +++ /dev/null @@ -1,75 +0,0 @@ -package volumeattach - -import ( - "errors" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// List returns a Pager that allows you to iterate over a collection of VolumeAttachments. -func List(client *gophercloud.ServiceClient, serverId string) pagination.Pager { - return pagination.NewPager(client, listURL(client, serverId), func(r pagination.PageResult) pagination.Page { - return VolumeAttachmentsPage{pagination.SinglePageBase(r)} - }) -} - -// CreateOptsBuilder describes struct types that can be accepted by the Create call. Notable, the -// CreateOpts struct in this package does. -type CreateOptsBuilder interface { - ToVolumeAttachmentCreateMap() (map[string]interface{}, error) -} - -// CreateOpts specifies volume attachment creation or import parameters. -type CreateOpts struct { - // Device is the device that the volume will attach to the instance as. Omit for "auto" - Device string - - // VolumeID is the ID of the volume to attach to the instance - VolumeID string -} - -// ToVolumeAttachmentCreateMap constructs a request body from CreateOpts. -func (opts CreateOpts) ToVolumeAttachmentCreateMap() (map[string]interface{}, error) { - if opts.VolumeID == "" { - return nil, errors.New("Missing field required for volume attachment creation: VolumeID") - } - - volumeAttachment := make(map[string]interface{}) - volumeAttachment["volumeId"] = opts.VolumeID - if opts.Device != "" { - volumeAttachment["device"] = opts.Device - } - - return map[string]interface{}{"volumeAttachment": volumeAttachment}, nil -} - -// Create requests the creation of a new volume attachment on the server -func Create(client *gophercloud.ServiceClient, serverId string, opts CreateOptsBuilder) CreateResult { - var res CreateResult - - reqBody, err := opts.ToVolumeAttachmentCreateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = client.Post(createURL(client, serverId), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - return res -} - -// Get returns public data about a previously created VolumeAttachment. -func Get(client *gophercloud.ServiceClient, serverId, aId string) GetResult { - var res GetResult - _, res.Err = client.Get(getURL(client, serverId, aId), &res.Body, nil) - return res -} - -// Delete requests the deletion of a previous stored VolumeAttachment from the server. -func Delete(client *gophercloud.ServiceClient, serverId, aId string) DeleteResult { - var res DeleteResult - _, res.Err = client.Delete(deleteURL(client, serverId, aId), nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach/results.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach/results.go deleted file mode 100644 index 26be39e4f7..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach/results.go +++ /dev/null @@ -1,84 +0,0 @@ -package volumeattach - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// VolumeAttach controls the attachment of a volume to an instance. -type VolumeAttachment struct { - // ID is a unique id of the attachment - ID string `mapstructure:"id"` - - // Device is what device the volume is attached as - Device string `mapstructure:"device"` - - // VolumeID is the ID of the attached volume - VolumeID string `mapstructure:"volumeId"` - - // ServerID is the ID of the instance that has the volume attached - ServerID string `mapstructure:"serverId"` -} - -// VolumeAttachmentsPage stores a single, only page of VolumeAttachments -// results from a List call. -type VolumeAttachmentsPage struct { - pagination.SinglePageBase -} - -// IsEmpty determines whether or not a VolumeAttachmentsPage is empty. -func (page VolumeAttachmentsPage) IsEmpty() (bool, error) { - va, err := ExtractVolumeAttachments(page) - return len(va) == 0, err -} - -// ExtractVolumeAttachments interprets a page of results as a slice of -// VolumeAttachments. -func ExtractVolumeAttachments(page pagination.Page) ([]VolumeAttachment, error) { - casted := page.(VolumeAttachmentsPage).Body - var response struct { - VolumeAttachments []VolumeAttachment `mapstructure:"volumeAttachments"` - } - - err := mapstructure.WeakDecode(casted, &response) - - return response.VolumeAttachments, err -} - -type VolumeAttachmentResult struct { - gophercloud.Result -} - -// Extract is a method that attempts to interpret any VolumeAttachment resource -// response as a VolumeAttachment struct. -func (r VolumeAttachmentResult) Extract() (*VolumeAttachment, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - VolumeAttachment *VolumeAttachment `json:"volumeAttachment" mapstructure:"volumeAttachment"` - } - - err := mapstructure.Decode(r.Body, &res) - return res.VolumeAttachment, err -} - -// CreateResult is the response from a Create operation. Call its Extract method to interpret it -// as a VolumeAttachment. -type CreateResult struct { - VolumeAttachmentResult -} - -// GetResult is the response from a Get operation. Call its Extract method to interpret it -// as a VolumeAttachment. -type GetResult struct { - VolumeAttachmentResult -} - -// DeleteResult is the response from a Delete operation. Call its Extract method to determine if -// the call succeeded or failed. -type DeleteResult struct { - gophercloud.ErrResult -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach/urls.go deleted file mode 100644 index 9d9d1786db..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach/urls.go +++ /dev/null @@ -1,25 +0,0 @@ -package volumeattach - -import "github.com/rackspace/gophercloud" - -const resourcePath = "os-volume_attachments" - -func resourceURL(c *gophercloud.ServiceClient, serverId string) string { - return c.ServiceURL("servers", serverId, resourcePath) -} - -func listURL(c *gophercloud.ServiceClient, serverId string) string { - return resourceURL(c, serverId) -} - -func createURL(c *gophercloud.ServiceClient, serverId string) string { - return resourceURL(c, serverId) -} - -func getURL(c *gophercloud.ServiceClient, serverId, aId string) string { - return c.ServiceURL("servers", serverId, resourcePath, aId) -} - -func deleteURL(c *gophercloud.ServiceClient, serverId, aId string) string { - return getURL(c, serverId, aId) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/admin/roles/docs.go b/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/admin/roles/docs.go deleted file mode 100644 index 8954178716..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/admin/roles/docs.go +++ /dev/null @@ -1,16 +0,0 @@ -// Package roles provides functionality to interact with and control roles on -// the API. -// -// A role represents a personality that a user can assume when performing a -// specific set of operations. If a role includes a set of rights and -// privileges, a user assuming that role inherits those rights and privileges. -// -// When a token is generated, the list of roles that user can assume is returned -// back to them. Services that are being called by that user determine how they -// interpret the set of roles a user has and to which operations or resources -// each role grants access. -// -// It is up to individual services such as Compute or Image to assign meaning -// to these roles. As far as the Identity service is concerned, a role is an -// arbitrary name assigned by the user. -package roles diff --git a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/admin/roles/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/admin/roles/fixtures.go deleted file mode 100644 index 8256f0fe8e..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/admin/roles/fixtures.go +++ /dev/null @@ -1,48 +0,0 @@ -package roles - -import ( - "fmt" - "net/http" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -func MockListRoleResponse(t *testing.T) { - th.Mux.HandleFunc("/OS-KSADM/roles", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "roles": [ - { - "id": "123", - "name": "compute:admin", - "description": "Nova Administrator" - } - ] -} - `) - }) -} - -func MockAddUserRoleResponse(t *testing.T) { - th.Mux.HandleFunc("/tenants/{tenant_id}/users/{user_id}/roles/OS-KSADM/{role_id}", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PUT") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.WriteHeader(http.StatusCreated) - }) -} - -func MockDeleteUserRoleResponse(t *testing.T) { - th.Mux.HandleFunc("/tenants/{tenant_id}/users/{user_id}/roles/OS-KSADM/{role_id}", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.WriteHeader(http.StatusNoContent) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/admin/roles/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/admin/roles/requests.go deleted file mode 100644 index 9a333140b2..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/admin/roles/requests.go +++ /dev/null @@ -1,33 +0,0 @@ -package roles - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// List is the operation responsible for listing all available global roles -// that a user can adopt. -func List(client *gophercloud.ServiceClient) pagination.Pager { - createPage := func(r pagination.PageResult) pagination.Page { - return RolePage{pagination.SinglePageBase(r)} - } - return pagination.NewPager(client, rootURL(client), createPage) -} - -// AddUserRole is the operation responsible for assigning a particular role to -// a user. This is confined to the scope of the user's tenant - so the tenant -// ID is a required argument. -func AddUserRole(client *gophercloud.ServiceClient, tenantID, userID, roleID string) UserRoleResult { - var result UserRoleResult - _, result.Err = client.Put(userRoleURL(client, tenantID, userID, roleID), nil, nil, nil) - return result -} - -// DeleteUserRole is the operation responsible for deleting a particular role -// from a user. This is confined to the scope of the user's tenant - so the -// tenant ID is a required argument. -func DeleteUserRole(client *gophercloud.ServiceClient, tenantID, userID, roleID string) UserRoleResult { - var result UserRoleResult - _, result.Err = client.Delete(userRoleURL(client, tenantID, userID, roleID), nil) - return result -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/admin/roles/results.go b/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/admin/roles/results.go deleted file mode 100644 index ebb3aa530b..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/admin/roles/results.go +++ /dev/null @@ -1,53 +0,0 @@ -package roles - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// Role represents an API role resource. -type Role struct { - // The unique ID for the role. - ID string - - // The human-readable name of the role. - Name string - - // The description of the role. - Description string - - // The associated service for this role. - ServiceID string -} - -// RolePage is a single page of a user Role collection. -type RolePage struct { - pagination.SinglePageBase -} - -// IsEmpty determines whether or not a page of Tenants contains any results. -func (page RolePage) IsEmpty() (bool, error) { - users, err := ExtractRoles(page) - if err != nil { - return false, err - } - return len(users) == 0, nil -} - -// ExtractRoles returns a slice of roles contained in a single page of results. -func ExtractRoles(page pagination.Page) ([]Role, error) { - casted := page.(RolePage).Body - var response struct { - Roles []Role `mapstructure:"roles"` - } - - err := mapstructure.Decode(casted, &response) - return response.Roles, err -} - -// UserRoleResult represents the result of either an AddUserRole or -// a DeleteUserRole operation. -type UserRoleResult struct { - gophercloud.ErrResult -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/admin/roles/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/admin/roles/urls.go deleted file mode 100644 index 61b31551dd..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/admin/roles/urls.go +++ /dev/null @@ -1,21 +0,0 @@ -package roles - -import "github.com/rackspace/gophercloud" - -const ( - ExtPath = "OS-KSADM" - RolePath = "roles" - UserPath = "users" -) - -func resourceURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(ExtPath, RolePath, id) -} - -func rootURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(ExtPath, RolePath) -} - -func userRoleURL(c *gophercloud.ServiceClient, tenantID, userID, roleID string) string { - return c.ServiceURL("tenants", tenantID, UserPath, userID, RolePath, ExtPath, roleID) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/delegate.go b/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/delegate.go deleted file mode 100644 index fd6e80ea6f..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/delegate.go +++ /dev/null @@ -1,52 +0,0 @@ -package extensions - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - common "github.com/rackspace/gophercloud/openstack/common/extensions" - "github.com/rackspace/gophercloud/pagination" -) - -// ExtensionPage is a single page of Extension results. -type ExtensionPage struct { - common.ExtensionPage -} - -// IsEmpty returns true if the current page contains at least one Extension. -func (page ExtensionPage) IsEmpty() (bool, error) { - is, err := ExtractExtensions(page) - if err != nil { - return true, err - } - return len(is) == 0, nil -} - -// ExtractExtensions accepts a Page struct, specifically an ExtensionPage struct, and extracts the -// elements into a slice of Extension structs. -func ExtractExtensions(page pagination.Page) ([]common.Extension, error) { - // Identity v2 adds an intermediate "values" object. - - var resp struct { - Extensions struct { - Values []common.Extension `mapstructure:"values"` - } `mapstructure:"extensions"` - } - - err := mapstructure.Decode(page.(ExtensionPage).Body, &resp) - return resp.Extensions.Values, err -} - -// Get retrieves information for a specific extension using its alias. -func Get(c *gophercloud.ServiceClient, alias string) common.GetResult { - return common.Get(c, alias) -} - -// List returns a Pager which allows you to iterate over the full collection of extensions. -// It does not accept query parameters. -func List(c *gophercloud.ServiceClient) pagination.Pager { - return common.List(c).WithPageCreator(func(r pagination.PageResult) pagination.Page { - return ExtensionPage{ - ExtensionPage: common.ExtensionPage{SinglePageBase: pagination.SinglePageBase(r)}, - } - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/doc.go deleted file mode 100644 index 791e4e391d..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package extensions provides information and interaction with the -// different extensions available for the OpenStack Identity service. -package extensions diff --git a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/fixtures.go deleted file mode 100644 index 96cb7d24a1..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/fixtures.go +++ /dev/null @@ -1,60 +0,0 @@ -// +build fixtures - -package extensions - -import ( - "fmt" - "net/http" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - "github.com/rackspace/gophercloud/testhelper/client" -) - -// ListOutput provides a single Extension result. It differs from the delegated implementation -// by the introduction of an intermediate "values" member. -const ListOutput = ` -{ - "extensions": { - "values": [ - { - "updated": "2013-01-20T00:00:00-00:00", - "name": "Neutron Service Type Management", - "links": [], - "namespace": "http://docs.openstack.org/ext/neutron/service-type/api/v1.0", - "alias": "service-type", - "description": "API for retrieving service providers for Neutron advanced services" - } - ] - } -} -` - -// HandleListExtensionsSuccessfully creates an HTTP handler that returns ListOutput for a List -// call. -func HandleListExtensionsSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/extensions", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", client.TokenID) - - w.Header().Add("Content-Type", "application/json") - - fmt.Fprintf(w, ` -{ - "extensions": { - "values": [ - { - "updated": "2013-01-20T00:00:00-00:00", - "name": "Neutron Service Type Management", - "links": [], - "namespace": "http://docs.openstack.org/ext/neutron/service-type/api/v1.0", - "alias": "service-type", - "description": "API for retrieving service providers for Neutron advanced services" - } - ] - } -} - `) - }) - -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/doc.go deleted file mode 100644 index 82abcb9fcc..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/doc.go +++ /dev/null @@ -1 +0,0 @@ -package users diff --git a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/fixtures.go deleted file mode 100644 index 8941868dd2..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/fixtures.go +++ /dev/null @@ -1,163 +0,0 @@ -package users - -import ( - "fmt" - "net/http" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -func MockListUserResponse(t *testing.T) { - th.Mux.HandleFunc("/users", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "users":[ - { - "id": "u1000", - "name": "John Smith", - "username": "jqsmith", - "email": "john.smith@example.org", - "enabled": true, - "tenant_id": "12345" - }, - { - "id": "u1001", - "name": "Jane Smith", - "username": "jqsmith", - "email": "jane.smith@example.org", - "enabled": true, - "tenant_id": "12345" - } - ] -} - `) - }) -} - -func mockCreateUserResponse(t *testing.T) { - th.Mux.HandleFunc("/users", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "user": { - "name": "new_user", - "tenant_id": "12345", - "enabled": false, - "email": "new_user@foo.com" - } -} - `) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "user": { - "name": "new_user", - "tenant_id": "12345", - "enabled": false, - "email": "new_user@foo.com", - "id": "c39e3de9be2d4c779f1dfd6abacc176d" - } -} -`) - }) -} - -func mockGetUserResponse(t *testing.T) { - th.Mux.HandleFunc("/users/new_user", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "user": { - "name": "new_user", - "tenant_id": "12345", - "enabled": false, - "email": "new_user@foo.com", - "id": "c39e3de9be2d4c779f1dfd6abacc176d" - } -} -`) - }) -} - -func mockUpdateUserResponse(t *testing.T) { - th.Mux.HandleFunc("/users/c39e3de9be2d4c779f1dfd6abacc176d", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PUT") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "user": { - "name": "new_name", - "enabled": true, - "email": "new_email@foo.com" - } -} -`) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "user": { - "name": "new_name", - "tenant_id": "12345", - "enabled": true, - "email": "new_email@foo.com", - "id": "c39e3de9be2d4c779f1dfd6abacc176d" - } -} -`) - }) -} - -func mockDeleteUserResponse(t *testing.T) { - th.Mux.HandleFunc("/users/c39e3de9be2d4c779f1dfd6abacc176d", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.WriteHeader(http.StatusNoContent) - }) -} - -func mockListRolesResponse(t *testing.T) { - th.Mux.HandleFunc("/tenants/1d8b6120dcc640fda4fc9194ffc80273/users/c39e3de9be2d4c779f1dfd6abacc176d/roles", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "roles": [ - { - "id": "9fe2ff9ee4384b1894a90878d3e92bab", - "name": "foo_role" - }, - { - "id": "1ea3d56793574b668e85960fbf651e13", - "name": "admin" - } - ] -} - `) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/requests.go deleted file mode 100644 index 88be45ecc0..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/requests.go +++ /dev/null @@ -1,161 +0,0 @@ -package users - -import ( - "errors" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -func List(client *gophercloud.ServiceClient) pagination.Pager { - createPage := func(r pagination.PageResult) pagination.Page { - return UserPage{pagination.SinglePageBase(r)} - } - - return pagination.NewPager(client, rootURL(client), createPage) -} - -// EnabledState represents whether the user is enabled or not. -type EnabledState *bool - -// Useful variables to use when creating or updating users. -var ( - iTrue = true - iFalse = false - - Enabled EnabledState = &iTrue - Disabled EnabledState = &iFalse -) - -// CommonOpts are the parameters that are shared between CreateOpts and -// UpdateOpts -type CommonOpts struct { - // Either a name or username is required. When provided, the value must be - // unique or a 409 conflict error will be returned. If you provide a name but - // omit a username, the latter will be set to the former; and vice versa. - Name, Username string - - // The ID of the tenant to which you want to assign this user. - TenantID string - - // Indicates whether this user is enabled or not. - Enabled EnabledState - - // The email address of this user. - Email string -} - -// CreateOpts represents the options needed when creating new users. -type CreateOpts CommonOpts - -// CreateOptsBuilder describes struct types that can be accepted by the Create call. -type CreateOptsBuilder interface { - ToUserCreateMap() (map[string]interface{}, error) -} - -// ToUserCreateMap assembles a request body based on the contents of a CreateOpts. -func (opts CreateOpts) ToUserCreateMap() (map[string]interface{}, error) { - m := make(map[string]interface{}) - - if opts.Name == "" && opts.Username == "" { - return m, errors.New("Either a Name or Username must be provided") - } - - if opts.Name != "" { - m["name"] = opts.Name - } - if opts.Username != "" { - m["username"] = opts.Username - } - if opts.Enabled != nil { - m["enabled"] = &opts.Enabled - } - if opts.Email != "" { - m["email"] = opts.Email - } - if opts.TenantID != "" { - m["tenant_id"] = opts.TenantID - } - - return map[string]interface{}{"user": m}, nil -} - -// Create is the operation responsible for creating new users. -func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult { - var res CreateResult - - reqBody, err := opts.ToUserCreateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = client.Post(rootURL(client), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200, 201}, - }) - - return res -} - -// Get requests details on a single user, either by ID. -func Get(client *gophercloud.ServiceClient, id string) GetResult { - var result GetResult - _, result.Err = client.Get(ResourceURL(client, id), &result.Body, nil) - return result -} - -// UpdateOptsBuilder allows extensions to add additional attributes to the Update request. -type UpdateOptsBuilder interface { - ToUserUpdateMap() map[string]interface{} -} - -// UpdateOpts specifies the base attributes that may be updated on an existing server. -type UpdateOpts CommonOpts - -// ToUserUpdateMap formats an UpdateOpts structure into a request body. -func (opts UpdateOpts) ToUserUpdateMap() map[string]interface{} { - m := make(map[string]interface{}) - - if opts.Name != "" { - m["name"] = opts.Name - } - if opts.Username != "" { - m["username"] = opts.Username - } - if opts.Enabled != nil { - m["enabled"] = &opts.Enabled - } - if opts.Email != "" { - m["email"] = opts.Email - } - if opts.TenantID != "" { - m["tenant_id"] = opts.TenantID - } - - return map[string]interface{}{"user": m} -} - -// Update is the operation responsible for updating exist users by their UUID. -func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) UpdateResult { - var result UpdateResult - reqBody := opts.ToUserUpdateMap() - _, result.Err = client.Put(ResourceURL(client, id), reqBody, &result.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - return result -} - -// Delete is the operation responsible for permanently deleting an API user. -func Delete(client *gophercloud.ServiceClient, id string) DeleteResult { - var result DeleteResult - _, result.Err = client.Delete(ResourceURL(client, id), nil) - return result -} - -func ListRoles(client *gophercloud.ServiceClient, tenantID, userID string) pagination.Pager { - createPage := func(r pagination.PageResult) pagination.Page { - return RolePage{pagination.SinglePageBase(r)} - } - - return pagination.NewPager(client, listRolesURL(client, tenantID, userID), createPage) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/results.go b/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/results.go deleted file mode 100644 index f531d5d023..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/results.go +++ /dev/null @@ -1,128 +0,0 @@ -package users - -import ( - "github.com/mitchellh/mapstructure" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// User represents a user resource that exists on the API. -type User struct { - // The UUID for this user. - ID string - - // The human name for this user. - Name string - - // The username for this user. - Username string - - // Indicates whether the user is enabled (true) or disabled (false). - Enabled bool - - // The email address for this user. - Email string - - // The ID of the tenant to which this user belongs. - TenantID string `mapstructure:"tenant_id"` -} - -// Role assigns specific responsibilities to users, allowing them to accomplish -// certain API operations whilst scoped to a service. -type Role struct { - // UUID of the role - ID string - - // Name of the role - Name string -} - -// UserPage is a single page of a User collection. -type UserPage struct { - pagination.SinglePageBase -} - -// RolePage is a single page of a user Role collection. -type RolePage struct { - pagination.SinglePageBase -} - -// IsEmpty determines whether or not a page of Tenants contains any results. -func (page UserPage) IsEmpty() (bool, error) { - users, err := ExtractUsers(page) - if err != nil { - return false, err - } - return len(users) == 0, nil -} - -// ExtractUsers returns a slice of Tenants contained in a single page of results. -func ExtractUsers(page pagination.Page) ([]User, error) { - casted := page.(UserPage).Body - var response struct { - Users []User `mapstructure:"users"` - } - - err := mapstructure.Decode(casted, &response) - return response.Users, err -} - -// IsEmpty determines whether or not a page of Tenants contains any results. -func (page RolePage) IsEmpty() (bool, error) { - users, err := ExtractRoles(page) - if err != nil { - return false, err - } - return len(users) == 0, nil -} - -// ExtractRoles returns a slice of Roles contained in a single page of results. -func ExtractRoles(page pagination.Page) ([]Role, error) { - casted := page.(RolePage).Body - var response struct { - Roles []Role `mapstructure:"roles"` - } - - err := mapstructure.Decode(casted, &response) - return response.Roles, err -} - -type commonResult struct { - gophercloud.Result -} - -// Extract interprets any commonResult as a User, if possible. -func (r commonResult) Extract() (*User, error) { - if r.Err != nil { - return nil, r.Err - } - - var response struct { - User User `mapstructure:"user"` - } - - err := mapstructure.Decode(r.Body, &response) - - return &response.User, err -} - -// CreateResult represents the result of a Create operation -type CreateResult struct { - commonResult -} - -// GetResult represents the result of a Get operation -type GetResult struct { - commonResult -} - -// UpdateResult represents the result of an Update operation -type UpdateResult struct { - commonResult -} - -// DeleteResult represents the result of a Delete operation -type DeleteResult struct { - commonResult -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/urls.go deleted file mode 100644 index 7ec4385d74..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/urls.go +++ /dev/null @@ -1,21 +0,0 @@ -package users - -import "github.com/rackspace/gophercloud" - -const ( - tenantPath = "tenants" - userPath = "users" - rolePath = "roles" -) - -func ResourceURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(userPath, id) -} - -func rootURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(userPath) -} - -func listRolesURL(c *gophercloud.ServiceClient, tenantID, userID string) string { - return c.ServiceURL(tenantPath, tenantID, userPath, userID, rolePath) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/endpoints/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/endpoints/doc.go deleted file mode 100644 index 85163949a8..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/endpoints/doc.go +++ /dev/null @@ -1,6 +0,0 @@ -// Package endpoints provides information and interaction with the service -// endpoints API resource in the OpenStack Identity service. -// -// For more information, see: -// http://developer.openstack.org/api-ref-identity-v3.html#endpoints-v3 -package endpoints diff --git a/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/endpoints/errors.go b/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/endpoints/errors.go deleted file mode 100644 index 854957ff98..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/endpoints/errors.go +++ /dev/null @@ -1,21 +0,0 @@ -package endpoints - -import "fmt" - -func requiredAttribute(attribute string) error { - return fmt.Errorf("You must specify %s for this endpoint.", attribute) -} - -var ( - // ErrAvailabilityRequired is reported if an Endpoint is created without an Availability. - ErrAvailabilityRequired = requiredAttribute("an availability") - - // ErrNameRequired is reported if an Endpoint is created without a Name. - ErrNameRequired = requiredAttribute("a name") - - // ErrURLRequired is reported if an Endpoint is created without a URL. - ErrURLRequired = requiredAttribute("a URL") - - // ErrServiceIDRequired is reported if an Endpoint is created without a ServiceID. - ErrServiceIDRequired = requiredAttribute("a serviceID") -) diff --git a/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/endpoints/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/endpoints/requests.go deleted file mode 100644 index 99a495d594..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/endpoints/requests.go +++ /dev/null @@ -1,123 +0,0 @@ -package endpoints - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// EndpointOpts contains the subset of Endpoint attributes that should be used to create or update an Endpoint. -type EndpointOpts struct { - Availability gophercloud.Availability - Name string - Region string - URL string - ServiceID string -} - -// Create inserts a new Endpoint into the service catalog. -// Within EndpointOpts, Region may be omitted by being left as "", but all other fields are required. -func Create(client *gophercloud.ServiceClient, opts EndpointOpts) CreateResult { - // Redefined so that Region can be re-typed as a *string, which can be omitted from the JSON output. - type endpoint struct { - Interface string `json:"interface"` - Name string `json:"name"` - Region *string `json:"region,omitempty"` - URL string `json:"url"` - ServiceID string `json:"service_id"` - } - - type request struct { - Endpoint endpoint `json:"endpoint"` - } - - // Ensure that EndpointOpts is fully populated. - if opts.Availability == "" { - return createErr(ErrAvailabilityRequired) - } - if opts.Name == "" { - return createErr(ErrNameRequired) - } - if opts.URL == "" { - return createErr(ErrURLRequired) - } - if opts.ServiceID == "" { - return createErr(ErrServiceIDRequired) - } - - // Populate the request body. - reqBody := request{ - Endpoint: endpoint{ - Interface: string(opts.Availability), - Name: opts.Name, - URL: opts.URL, - ServiceID: opts.ServiceID, - }, - } - reqBody.Endpoint.Region = gophercloud.MaybeString(opts.Region) - - var result CreateResult - _, result.Err = client.Post(listURL(client), reqBody, &result.Body, nil) - return result -} - -// ListOpts allows finer control over the endpoints returned by a List call. -// All fields are optional. -type ListOpts struct { - Availability gophercloud.Availability `q:"interface"` - ServiceID string `q:"service_id"` - Page int `q:"page"` - PerPage int `q:"per_page"` -} - -// List enumerates endpoints in a paginated collection, optionally filtered by ListOpts criteria. -func List(client *gophercloud.ServiceClient, opts ListOpts) pagination.Pager { - u := listURL(client) - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return pagination.Pager{Err: err} - } - u += q.String() - createPage := func(r pagination.PageResult) pagination.Page { - return EndpointPage{pagination.LinkedPageBase{PageResult: r}} - } - - return pagination.NewPager(client, u, createPage) -} - -// Update changes an existing endpoint with new data. -// All fields are optional in the provided EndpointOpts. -func Update(client *gophercloud.ServiceClient, endpointID string, opts EndpointOpts) UpdateResult { - type endpoint struct { - Interface *string `json:"interface,omitempty"` - Name *string `json:"name,omitempty"` - Region *string `json:"region,omitempty"` - URL *string `json:"url,omitempty"` - ServiceID *string `json:"service_id,omitempty"` - } - - type request struct { - Endpoint endpoint `json:"endpoint"` - } - - reqBody := request{Endpoint: endpoint{}} - reqBody.Endpoint.Interface = gophercloud.MaybeString(string(opts.Availability)) - reqBody.Endpoint.Name = gophercloud.MaybeString(opts.Name) - reqBody.Endpoint.Region = gophercloud.MaybeString(opts.Region) - reqBody.Endpoint.URL = gophercloud.MaybeString(opts.URL) - reqBody.Endpoint.ServiceID = gophercloud.MaybeString(opts.ServiceID) - - var result UpdateResult - _, result.Err = client.Request("PATCH", endpointURL(client, endpointID), gophercloud.RequestOpts{ - JSONBody: &reqBody, - JSONResponse: &result.Body, - OkCodes: []int{200}, - }) - return result -} - -// Delete removes an endpoint from the service catalog. -func Delete(client *gophercloud.ServiceClient, endpointID string) DeleteResult { - var res DeleteResult - _, res.Err = client.Delete(endpointURL(client, endpointID), nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/endpoints/results.go b/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/endpoints/results.go deleted file mode 100644 index 128112295a..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/endpoints/results.go +++ /dev/null @@ -1,82 +0,0 @@ -package endpoints - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -type commonResult struct { - gophercloud.Result -} - -// Extract interprets a GetResult, CreateResult or UpdateResult as a concrete Endpoint. -// An error is returned if the original call or the extraction failed. -func (r commonResult) Extract() (*Endpoint, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Endpoint `json:"endpoint"` - } - - err := mapstructure.Decode(r.Body, &res) - - return &res.Endpoint, err -} - -// CreateResult is the deferred result of a Create call. -type CreateResult struct { - commonResult -} - -// createErr quickly wraps an error in a CreateResult. -func createErr(err error) CreateResult { - return CreateResult{commonResult{gophercloud.Result{Err: err}}} -} - -// UpdateResult is the deferred result of an Update call. -type UpdateResult struct { - commonResult -} - -// DeleteResult is the deferred result of an Delete call. -type DeleteResult struct { - gophercloud.ErrResult -} - -// Endpoint describes the entry point for another service's API. -type Endpoint struct { - ID string `mapstructure:"id" json:"id"` - Availability gophercloud.Availability `mapstructure:"interface" json:"interface"` - Name string `mapstructure:"name" json:"name"` - Region string `mapstructure:"region" json:"region"` - ServiceID string `mapstructure:"service_id" json:"service_id"` - URL string `mapstructure:"url" json:"url"` -} - -// EndpointPage is a single page of Endpoint results. -type EndpointPage struct { - pagination.LinkedPageBase -} - -// IsEmpty returns true if no Endpoints were returned. -func (p EndpointPage) IsEmpty() (bool, error) { - es, err := ExtractEndpoints(p) - if err != nil { - return true, err - } - return len(es) == 0, nil -} - -// ExtractEndpoints extracts an Endpoint slice from a Page. -func ExtractEndpoints(page pagination.Page) ([]Endpoint, error) { - var response struct { - Endpoints []Endpoint `mapstructure:"endpoints"` - } - - err := mapstructure.Decode(page.(EndpointPage).Body, &response) - - return response.Endpoints, err -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/endpoints/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/endpoints/urls.go deleted file mode 100644 index 547d7b102a..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/endpoints/urls.go +++ /dev/null @@ -1,11 +0,0 @@ -package endpoints - -import "github.com/rackspace/gophercloud" - -func listURL(client *gophercloud.ServiceClient) string { - return client.ServiceURL("endpoints") -} - -func endpointURL(client *gophercloud.ServiceClient, endpointID string) string { - return client.ServiceURL("endpoints", endpointID) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/services/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/services/doc.go deleted file mode 100644 index fa56411856..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/services/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package services provides information and interaction with the services API -// resource for the OpenStack Identity service. -package services diff --git a/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/services/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/services/requests.go deleted file mode 100644 index 3ee924f3ee..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/services/requests.go +++ /dev/null @@ -1,77 +0,0 @@ -package services - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -type response struct { - Service Service `json:"service"` -} - -// Create adds a new service of the requested type to the catalog. -func Create(client *gophercloud.ServiceClient, serviceType string) CreateResult { - type request struct { - Type string `json:"type"` - } - - req := request{Type: serviceType} - - var result CreateResult - _, result.Err = client.Post(listURL(client), req, &result.Body, nil) - return result -} - -// ListOpts allows you to query the List method. -type ListOpts struct { - ServiceType string `q:"type"` - PerPage int `q:"perPage"` - Page int `q:"page"` -} - -// List enumerates the services available to a specific user. -func List(client *gophercloud.ServiceClient, opts ListOpts) pagination.Pager { - u := listURL(client) - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return pagination.Pager{Err: err} - } - u += q.String() - createPage := func(r pagination.PageResult) pagination.Page { - return ServicePage{pagination.LinkedPageBase{PageResult: r}} - } - - return pagination.NewPager(client, u, createPage) -} - -// Get returns additional information about a service, given its ID. -func Get(client *gophercloud.ServiceClient, serviceID string) GetResult { - var result GetResult - _, result.Err = client.Get(serviceURL(client, serviceID), &result.Body, nil) - return result -} - -// Update changes the service type of an existing service. -func Update(client *gophercloud.ServiceClient, serviceID string, serviceType string) UpdateResult { - type request struct { - Type string `json:"type"` - } - - req := request{Type: serviceType} - - var result UpdateResult - _, result.Err = client.Request("PATCH", serviceURL(client, serviceID), gophercloud.RequestOpts{ - JSONBody: &req, - JSONResponse: &result.Body, - OkCodes: []int{200}, - }) - return result -} - -// Delete removes an existing service. -// It either deletes all associated endpoints, or fails until all endpoints are deleted. -func Delete(client *gophercloud.ServiceClient, serviceID string) DeleteResult { - var res DeleteResult - _, res.Err = client.Delete(serviceURL(client, serviceID), nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/services/results.go b/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/services/results.go deleted file mode 100644 index 1d0d141280..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/services/results.go +++ /dev/null @@ -1,80 +0,0 @@ -package services - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" - - "github.com/mitchellh/mapstructure" -) - -type commonResult struct { - gophercloud.Result -} - -// Extract interprets a GetResult, CreateResult or UpdateResult as a concrete Service. -// An error is returned if the original call or the extraction failed. -func (r commonResult) Extract() (*Service, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Service `json:"service"` - } - - err := mapstructure.Decode(r.Body, &res) - - return &res.Service, err -} - -// CreateResult is the deferred result of a Create call. -type CreateResult struct { - commonResult -} - -// GetResult is the deferred result of a Get call. -type GetResult struct { - commonResult -} - -// UpdateResult is the deferred result of an Update call. -type UpdateResult struct { - commonResult -} - -// DeleteResult is the deferred result of an Delete call. -type DeleteResult struct { - gophercloud.ErrResult -} - -// Service is the result of a list or information query. -type Service struct { - Description *string `json:"description,omitempty"` - ID string `json:"id"` - Name string `json:"name"` - Type string `json:"type"` -} - -// ServicePage is a single page of Service results. -type ServicePage struct { - pagination.LinkedPageBase -} - -// IsEmpty returns true if the page contains no results. -func (p ServicePage) IsEmpty() (bool, error) { - services, err := ExtractServices(p) - if err != nil { - return true, err - } - return len(services) == 0, nil -} - -// ExtractServices extracts a slice of Services from a Collection acquired from List. -func ExtractServices(page pagination.Page) ([]Service, error) { - var response struct { - Services []Service `mapstructure:"services"` - } - - err := mapstructure.Decode(page.(ServicePage).Body, &response) - return response.Services, err -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/services/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/services/urls.go deleted file mode 100644 index 85443a48a0..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/identity/v3/services/urls.go +++ /dev/null @@ -1,11 +0,0 @@ -package services - -import "github.com/rackspace/gophercloud" - -func listURL(client *gophercloud.ServiceClient) string { - return client.ServiceURL("services") -} - -func serviceURL(client *gophercloud.ServiceClient, serviceID string) string { - return client.ServiceURL("services", serviceID) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/apiversions/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/apiversions/doc.go deleted file mode 100644 index 0208ee20ec..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/apiversions/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -// Package apiversions provides information and interaction with the different -// API versions for the OpenStack Neutron service. This functionality is not -// restricted to this particular version. -package apiversions diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/apiversions/errors.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/apiversions/errors.go deleted file mode 100644 index 76bdb14f75..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/apiversions/errors.go +++ /dev/null @@ -1 +0,0 @@ -package apiversions diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/apiversions/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/apiversions/requests.go deleted file mode 100644 index 9fb6de1411..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/apiversions/requests.go +++ /dev/null @@ -1,21 +0,0 @@ -package apiversions - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// ListVersions lists all the Neutron API versions available to end-users -func ListVersions(c *gophercloud.ServiceClient) pagination.Pager { - return pagination.NewPager(c, apiVersionsURL(c), func(r pagination.PageResult) pagination.Page { - return APIVersionPage{pagination.SinglePageBase(r)} - }) -} - -// ListVersionResources lists all of the different API resources for a particular -// API versions. Typical resources for Neutron might be: networks, subnets, etc. -func ListVersionResources(c *gophercloud.ServiceClient, v string) pagination.Pager { - return pagination.NewPager(c, apiInfoURL(c, v), func(r pagination.PageResult) pagination.Page { - return APIVersionResourcePage{pagination.SinglePageBase(r)} - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/apiversions/results.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/apiversions/results.go deleted file mode 100644 index 97159341ff..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/apiversions/results.go +++ /dev/null @@ -1,77 +0,0 @@ -package apiversions - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud/pagination" -) - -// APIVersion represents an API version for Neutron. It contains the status of -// the API, and its unique ID. -type APIVersion struct { - Status string `mapstructure:"status" json:"status"` - ID string `mapstructure:"id" json:"id"` -} - -// APIVersionPage is the page returned by a pager when traversing over a -// collection of API versions. -type APIVersionPage struct { - pagination.SinglePageBase -} - -// IsEmpty checks whether an APIVersionPage struct is empty. -func (r APIVersionPage) IsEmpty() (bool, error) { - is, err := ExtractAPIVersions(r) - if err != nil { - return true, err - } - return len(is) == 0, nil -} - -// ExtractAPIVersions takes a collection page, extracts all of the elements, -// and returns them a slice of APIVersion structs. It is effectively a cast. -func ExtractAPIVersions(page pagination.Page) ([]APIVersion, error) { - var resp struct { - Versions []APIVersion `mapstructure:"versions"` - } - - err := mapstructure.Decode(page.(APIVersionPage).Body, &resp) - - return resp.Versions, err -} - -// APIVersionResource represents a generic API resource. It contains the name -// of the resource and its plural collection name. -type APIVersionResource struct { - Name string `mapstructure:"name" json:"name"` - Collection string `mapstructure:"collection" json:"collection"` -} - -// APIVersionResourcePage is a concrete type which embeds the common -// SinglePageBase struct, and is used when traversing API versions collections. -type APIVersionResourcePage struct { - pagination.SinglePageBase -} - -// IsEmpty is a concrete function which indicates whether an -// APIVersionResourcePage is empty or not. -func (r APIVersionResourcePage) IsEmpty() (bool, error) { - is, err := ExtractVersionResources(r) - if err != nil { - return true, err - } - return len(is) == 0, nil -} - -// ExtractVersionResources accepts a Page struct, specifically a -// APIVersionResourcePage struct, and extracts the elements into a slice of -// APIVersionResource structs. In other words, the collection is mapped into -// a relevant slice. -func ExtractVersionResources(page pagination.Page) ([]APIVersionResource, error) { - var resp struct { - APIVersionResources []APIVersionResource `mapstructure:"resources"` - } - - err := mapstructure.Decode(page.(APIVersionResourcePage).Body, &resp) - - return resp.APIVersionResources, err -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/apiversions/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/apiversions/urls.go deleted file mode 100644 index 58aa2b61f8..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/apiversions/urls.go +++ /dev/null @@ -1,15 +0,0 @@ -package apiversions - -import ( - "strings" - - "github.com/rackspace/gophercloud" -) - -func apiVersionsURL(c *gophercloud.ServiceClient) string { - return c.Endpoint -} - -func apiInfoURL(c *gophercloud.ServiceClient, version string) string { - return c.Endpoint + strings.TrimRight(version, "/") + "/" -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/common/common_tests.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/common/common_tests.go deleted file mode 100644 index 41603510d6..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/common/common_tests.go +++ /dev/null @@ -1,14 +0,0 @@ -package common - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/testhelper/client" -) - -const TokenID = client.TokenID - -func ServiceClient() *gophercloud.ServiceClient { - sc := client.ServiceClient() - sc.ResourceBase = sc.Endpoint + "v2.0/" - return sc -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/delegate.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/delegate.go deleted file mode 100644 index d08e1fda97..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/delegate.go +++ /dev/null @@ -1,41 +0,0 @@ -package extensions - -import ( - "github.com/rackspace/gophercloud" - common "github.com/rackspace/gophercloud/openstack/common/extensions" - "github.com/rackspace/gophercloud/pagination" -) - -// Extension is a single OpenStack extension. -type Extension struct { - common.Extension -} - -// GetResult wraps a GetResult from common. -type GetResult struct { - common.GetResult -} - -// ExtractExtensions interprets a Page as a slice of Extensions. -func ExtractExtensions(page pagination.Page) ([]Extension, error) { - inner, err := common.ExtractExtensions(page) - if err != nil { - return nil, err - } - outer := make([]Extension, len(inner)) - for index, ext := range inner { - outer[index] = Extension{ext} - } - return outer, nil -} - -// Get retrieves information for a specific extension using its alias. -func Get(c *gophercloud.ServiceClient, alias string) GetResult { - return GetResult{common.Get(c, alias)} -} - -// List returns a Pager which allows you to iterate over the full collection of extensions. -// It does not accept query parameters. -func List(c *gophercloud.ServiceClient) pagination.Pager { - return common.List(c) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/external/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/external/doc.go deleted file mode 100644 index dad3a844f7..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/external/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package external provides information and interaction with the external -// extension for the OpenStack Networking service. -package external diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/external/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/external/requests.go deleted file mode 100644 index 097ae37f24..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/external/requests.go +++ /dev/null @@ -1,69 +0,0 @@ -package external - -import ( - "time" - - "github.com/rackspace/gophercloud/openstack/networking/v2/networks" -) - -// AdminState gives users a solid type to work with for create and update -// operations. It is recommended that users use the `Up` and `Down` enums. -type AdminState *bool - -// Convenience vars for AdminStateUp values. -var ( - iTrue = true - iFalse = false - - Up AdminState = &iTrue - Down AdminState = &iFalse -) - -// CreateOpts is the structure used when creating new external network -// resources. It embeds networks.CreateOpts and so inherits all of its required -// and optional fields, with the addition of the External field. -type CreateOpts struct { - Parent networks.CreateOpts - External bool -} - -// ToNetworkCreateMap casts a CreateOpts struct to a map. -func (o CreateOpts) ToNetworkCreateMap() (map[string]interface{}, error) { - - // DO NOT REMOVE. Though this line seemingly does nothing of value, it is a - // splint to prevent the unit test from failing on Go Tip. We suspect it is a - // compiler issue that will hopefully be worked out prior to our next release. - // Again, for all the unit tests to pass, this line is necessary and sufficient - // at the moment. We should reassess after the Go 1.5 release to determine - // if this line is still needed. - time.Sleep(0 * time.Millisecond) - - outer, err := o.Parent.ToNetworkCreateMap() - if err != nil { - return nil, err - } - - outer["network"].(map[string]interface{})["router:external"] = o.External - - return outer, nil -} - -// UpdateOpts is the structure used when updating existing external network -// resources. It embeds networks.UpdateOpts and so inherits all of its required -// and optional fields, with the addition of the External field. -type UpdateOpts struct { - Parent networks.UpdateOpts - External bool -} - -// ToNetworkUpdateMap casts an UpdateOpts struct to a map. -func (o UpdateOpts) ToNetworkUpdateMap() (map[string]interface{}, error) { - outer, err := o.Parent.ToNetworkUpdateMap() - if err != nil { - return nil, err - } - - outer["network"].(map[string]interface{})["router:external"] = o.External - - return outer, nil -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/external/results.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/external/results.go deleted file mode 100644 index 54dbf4bb69..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/external/results.go +++ /dev/null @@ -1,81 +0,0 @@ -package external - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud/openstack/networking/v2/networks" - "github.com/rackspace/gophercloud/pagination" -) - -// NetworkExternal represents a decorated form of a Network with based on the -// "external-net" extension. -type NetworkExternal struct { - // UUID for the network - ID string `mapstructure:"id" json:"id"` - - // Human-readable name for the network. Might not be unique. - Name string `mapstructure:"name" json:"name"` - - // The administrative state of network. If false (down), the network does not forward packets. - AdminStateUp bool `mapstructure:"admin_state_up" json:"admin_state_up"` - - // Indicates whether network is currently operational. Possible values include - // `ACTIVE', `DOWN', `BUILD', or `ERROR'. Plug-ins might define additional values. - Status string `mapstructure:"status" json:"status"` - - // Subnets associated with this network. - Subnets []string `mapstructure:"subnets" json:"subnets"` - - // Owner of network. Only admin users can specify a tenant_id other than its own. - TenantID string `mapstructure:"tenant_id" json:"tenant_id"` - - // Specifies whether the network resource can be accessed by any tenant or not. - Shared bool `mapstructure:"shared" json:"shared"` - - // Specifies whether the network is an external network or not. - External bool `mapstructure:"router:external" json:"router:external"` -} - -func commonExtract(e error, response interface{}) (*NetworkExternal, error) { - if e != nil { - return nil, e - } - - var res struct { - Network *NetworkExternal `json:"network"` - } - - err := mapstructure.Decode(response, &res) - - return res.Network, err -} - -// ExtractGet decorates a GetResult struct returned from a networks.Get() -// function with extended attributes. -func ExtractGet(r networks.GetResult) (*NetworkExternal, error) { - return commonExtract(r.Err, r.Body) -} - -// ExtractCreate decorates a CreateResult struct returned from a networks.Create() -// function with extended attributes. -func ExtractCreate(r networks.CreateResult) (*NetworkExternal, error) { - return commonExtract(r.Err, r.Body) -} - -// ExtractUpdate decorates a UpdateResult struct returned from a -// networks.Update() function with extended attributes. -func ExtractUpdate(r networks.UpdateResult) (*NetworkExternal, error) { - return commonExtract(r.Err, r.Body) -} - -// ExtractList accepts a Page struct, specifically a NetworkPage struct, and -// extracts the elements into a slice of NetworkExternal structs. In other -// words, a generic collection is mapped into a relevant slice. -func ExtractList(page pagination.Page) ([]NetworkExternal, error) { - var resp struct { - Networks []NetworkExternal `mapstructure:"networks" json:"networks"` - } - - err := mapstructure.Decode(page.(networks.NetworkPage).Body, &resp) - - return resp.Networks, err -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/doc.go deleted file mode 100644 index 3ec450a7b3..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package fwaas provides information and interaction with the Firewall -// as a Service extension for the OpenStack Networking service. -package fwaas diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls/errors.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls/errors.go deleted file mode 100644 index dd92bb20db..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls/errors.go +++ /dev/null @@ -1,11 +0,0 @@ -package firewalls - -import "fmt" - -func err(str string) error { - return fmt.Errorf("%s", str) -} - -var ( - errPolicyRequired = err("A policy ID is required") -) diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls/requests.go deleted file mode 100644 index 12d587f389..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls/requests.go +++ /dev/null @@ -1,216 +0,0 @@ -package firewalls - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// AdminState gives users a solid type to work with for create and update -// operations. It is recommended that users use the `Up` and `Down` enums. -type AdminState *bool - -// Shared gives users a solid type to work with for create and update -// operations. It is recommended that users use the `Yes` and `No` enums. -type Shared *bool - -// Convenience vars for AdminStateUp and Shared values. -var ( - iTrue = true - iFalse = false - Up AdminState = &iTrue - Down AdminState = &iFalse - Yes Shared = &iTrue - No Shared = &iFalse -) - -// ListOptsBuilder allows extensions to add additional parameters to the -// List request. -type ListOptsBuilder interface { - ToFirewallListQuery() (string, error) -} - -// ListOpts allows the filtering and sorting of paginated collections through -// the API. Filtering is achieved by passing in struct field values that map to -// the firewall attributes you want to see returned. SortKey allows you to sort -// by a particular firewall attribute. SortDir sets the direction, and is either -// `asc' or `desc'. Marker and Limit are used for pagination. -type ListOpts struct { - TenantID string `q:"tenant_id"` - Name string `q:"name"` - Description string `q:"description"` - AdminStateUp bool `q:"admin_state_up"` - Shared bool `q:"shared"` - PolicyID string `q:"firewall_policy_id"` - ID string `q:"id"` - Limit int `q:"limit"` - Marker string `q:"marker"` - SortKey string `q:"sort_key"` - SortDir string `q:"sort_dir"` -} - -// ToFirewallListQuery formats a ListOpts into a query string. -func (opts ListOpts) ToFirewallListQuery() (string, error) { - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return "", err - } - return q.String(), nil -} - -// List returns a Pager which allows you to iterate over a collection of -// firewalls. It accepts a ListOpts struct, which allows you to filter -// and sort the returned collection for greater efficiency. -// -// Default policy settings return only those firewalls that are owned by the -// tenant who submits the request, unless an admin user submits the request. -func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { - url := rootURL(c) - - if opts != nil { - query, err := opts.ToFirewallListQuery() - if err != nil { - return pagination.Pager{Err: err} - } - url += query - } - - return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page { - return FirewallPage{pagination.LinkedPageBase{PageResult: r}} - }) -} - -// CreateOptsBuilder is the interface options structs have to satisfy in order -// to be used in the main Create operation in this package. Since many -// extensions decorate or modify the common logic, it is useful for them to -// satisfy a basic interface in order for them to be used. -type CreateOptsBuilder interface { - ToFirewallCreateMap() (map[string]interface{}, error) -} - -// CreateOpts contains all the values needed to create a new firewall. -type CreateOpts struct { - // Only required if the caller has an admin role and wants to create a firewall - // for another tenant. - TenantID string - Name string - Description string - AdminStateUp *bool - Shared *bool - PolicyID string -} - -// ToFirewallCreateMap casts a CreateOpts struct to a map. -func (opts CreateOpts) ToFirewallCreateMap() (map[string]interface{}, error) { - if opts.PolicyID == "" { - return nil, errPolicyRequired - } - - f := make(map[string]interface{}) - - if opts.TenantID != "" { - f["tenant_id"] = opts.TenantID - } - if opts.Name != "" { - f["name"] = opts.Name - } - if opts.Description != "" { - f["description"] = opts.Description - } - if opts.Shared != nil { - f["shared"] = *opts.Shared - } - if opts.AdminStateUp != nil { - f["admin_state_up"] = *opts.AdminStateUp - } - if opts.PolicyID != "" { - f["firewall_policy_id"] = opts.PolicyID - } - - return map[string]interface{}{"firewall": f}, nil -} - -// Create accepts a CreateOpts struct and uses the values to create a new firewall -func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult { - var res CreateResult - - reqBody, err := opts.ToFirewallCreateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil) - return res -} - -// Get retrieves a particular firewall based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) GetResult { - var res GetResult - _, res.Err = c.Get(resourceURL(c, id), &res.Body, nil) - return res -} - -// UpdateOptsBuilder is the interface options structs have to satisfy in order -// to be used in the main Update operation in this package. Since many -// extensions decorate or modify the common logic, it is useful for them to -// satisfy a basic interface in order for them to be used. -type UpdateOptsBuilder interface { - ToFirewallUpdateMap() (map[string]interface{}, error) -} - -// UpdateOpts contains the values used when updating a firewall. -type UpdateOpts struct { - // Name of the firewall. - Name string - Description string - AdminStateUp *bool - Shared *bool - PolicyID string -} - -// ToFirewallUpdateMap casts a CreateOpts struct to a map. -func (opts UpdateOpts) ToFirewallUpdateMap() (map[string]interface{}, error) { - f := make(map[string]interface{}) - - if opts.Name != "" { - f["name"] = opts.Name - } - if opts.Description != "" { - f["description"] = opts.Description - } - if opts.Shared != nil { - f["shared"] = *opts.Shared - } - if opts.AdminStateUp != nil { - f["admin_state_up"] = *opts.AdminStateUp - } - if opts.PolicyID != "" { - f["firewall_policy_id"] = opts.PolicyID - } - - return map[string]interface{}{"firewall": f}, nil -} - -// Update allows firewalls to be updated. -func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) UpdateResult { - var res UpdateResult - - reqBody, err := opts.ToFirewallUpdateMap() - if err != nil { - res.Err = err - return res - } - - // Send request to API - _, res.Err = c.Put(resourceURL(c, id), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - return res -} - -// Delete will permanently delete a particular firewall based on its unique ID. -func Delete(c *gophercloud.ServiceClient, id string) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(resourceURL(c, id), nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls/results.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls/results.go deleted file mode 100644 index a8c76eef23..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls/results.go +++ /dev/null @@ -1,101 +0,0 @@ -package firewalls - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -type Firewall struct { - ID string `json:"id" mapstructure:"id"` - Name string `json:"name" mapstructure:"name"` - Description string `json:"description" mapstructure:"description"` - AdminStateUp bool `json:"admin_state_up" mapstructure:"admin_state_up"` - Status string `json:"status" mapstructure:"status"` - PolicyID string `json:"firewall_policy_id" mapstructure:"firewall_policy_id"` - TenantID string `json:"tenant_id" mapstructure:"tenant_id"` -} - -type commonResult struct { - gophercloud.Result -} - -// Extract is a function that accepts a result and extracts a firewall. -func (r commonResult) Extract() (*Firewall, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Firewall *Firewall `json:"firewall"` - } - - err := mapstructure.Decode(r.Body, &res) - - return res.Firewall, err -} - -// FirewallPage is the page returned by a pager when traversing over a -// collection of firewalls. -type FirewallPage struct { - pagination.LinkedPageBase -} - -// NextPageURL is invoked when a paginated collection of firewalls has reached -// the end of a page and the pager seeks to traverse over a new one. In order -// to do this, it needs to construct the next page's URL. -func (p FirewallPage) NextPageURL() (string, error) { - type resp struct { - Links []gophercloud.Link `mapstructure:"firewalls_links"` - } - - var r resp - err := mapstructure.Decode(p.Body, &r) - if err != nil { - return "", err - } - - return gophercloud.ExtractNextURL(r.Links) -} - -// IsEmpty checks whether a FirewallPage struct is empty. -func (p FirewallPage) IsEmpty() (bool, error) { - is, err := ExtractFirewalls(p) - if err != nil { - return true, nil - } - return len(is) == 0, nil -} - -// ExtractFirewalls accepts a Page struct, specifically a RouterPage struct, -// and extracts the elements into a slice of Router structs. In other words, -// a generic collection is mapped into a relevant slice. -func ExtractFirewalls(page pagination.Page) ([]Firewall, error) { - var resp struct { - Firewalls []Firewall `mapstructure:"firewalls" json:"firewalls"` - } - - err := mapstructure.Decode(page.(FirewallPage).Body, &resp) - - return resp.Firewalls, err -} - -// GetResult represents the result of a get operation. -type GetResult struct { - commonResult -} - -// UpdateResult represents the result of an update operation. -type UpdateResult struct { - commonResult -} - -// DeleteResult represents the result of a delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} - -// CreateResult represents the result of a create operation. -type CreateResult struct { - commonResult -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls/urls.go deleted file mode 100644 index 4dde53005a..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls/urls.go +++ /dev/null @@ -1,16 +0,0 @@ -package firewalls - -import "github.com/rackspace/gophercloud" - -const ( - rootPath = "fw" - resourcePath = "firewalls" -) - -func rootURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(rootPath, resourcePath) -} - -func resourceURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(rootPath, resourcePath, id) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies/requests.go deleted file mode 100644 index fe07d9abb1..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies/requests.go +++ /dev/null @@ -1,243 +0,0 @@ -package policies - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// Binary gives users a solid type to work with for create and update -// operations. It is recommended that users use the `Yes` and `No` enums -type Binary *bool - -// Convenience vars for Audited and Shared values. -var ( - iTrue = true - iFalse = false - Yes Binary = &iTrue - No Binary = &iFalse -) - -// ListOptsBuilder allows extensions to add additional parameters to the -// List request. -type ListOptsBuilder interface { - ToPolicyListQuery() (string, error) -} - -// ListOpts allows the filtering and sorting of paginated collections through -// the API. Filtering is achieved by passing in struct field values that map to -// the firewall policy attributes you want to see returned. SortKey allows you -// to sort by a particular firewall policy attribute. SortDir sets the direction, -// and is either `asc' or `desc'. Marker and Limit are used for pagination. -type ListOpts struct { - TenantID string `q:"tenant_id"` - Name string `q:"name"` - Description string `q:"description"` - Shared bool `q:"shared"` - Audited bool `q:"audited"` - ID string `q:"id"` - Limit int `q:"limit"` - Marker string `q:"marker"` - SortKey string `q:"sort_key"` - SortDir string `q:"sort_dir"` -} - -// ToPolicyListQuery formats a ListOpts into a query string. -func (opts ListOpts) ToPolicyListQuery() (string, error) { - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return "", err - } - return q.String(), nil -} - -// List returns a Pager which allows you to iterate over a collection of -// firewall policies. It accepts a ListOpts struct, which allows you to filter -// and sort the returned collection for greater efficiency. -// -// Default policy settings return only those firewall policies that are owned by the -// tenant who submits the request, unless an admin user submits the request. -func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { - url := rootURL(c) - - if opts != nil { - query, err := opts.ToPolicyListQuery() - if err != nil { - return pagination.Pager{Err: err} - } - url += query - } - - return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page { - return PolicyPage{pagination.LinkedPageBase{PageResult: r}} - }) -} - -// CreateOptsBuilder is the interface options structs have to satisfy in order -// to be used in the main Create operation in this package. Since many -// extensions decorate or modify the common logic, it is useful for them to -// satisfy a basic interface in order for them to be used. -type CreateOptsBuilder interface { - ToPolicyCreateMap() (map[string]interface{}, error) -} - -// CreateOpts contains all the values needed to create a new firewall policy. -type CreateOpts struct { - // Only required if the caller has an admin role and wants to create a firewall policy - // for another tenant. - TenantID string - Name string - Description string - Shared *bool - Audited *bool - Rules []string -} - -// ToPolicyCreateMap casts a CreateOpts struct to a map. -func (opts CreateOpts) ToPolicyCreateMap() (map[string]interface{}, error) { - p := make(map[string]interface{}) - - if opts.TenantID != "" { - p["tenant_id"] = opts.TenantID - } - if opts.Name != "" { - p["name"] = opts.Name - } - if opts.Description != "" { - p["description"] = opts.Description - } - if opts.Shared != nil { - p["shared"] = *opts.Shared - } - if opts.Audited != nil { - p["audited"] = *opts.Audited - } - if opts.Rules != nil { - p["firewall_rules"] = opts.Rules - } - - return map[string]interface{}{"firewall_policy": p}, nil -} - -// Create accepts a CreateOpts struct and uses the values to create a new firewall policy -func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult { - var res CreateResult - - reqBody, err := opts.ToPolicyCreateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil) - return res -} - -// Get retrieves a particular firewall policy based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) GetResult { - var res GetResult - _, res.Err = c.Get(resourceURL(c, id), &res.Body, nil) - return res -} - -// UpdateOptsBuilder is the interface options structs have to satisfy in order -// to be used in the main Update operation in this package. Since many -// extensions decorate or modify the common logic, it is useful for them to -// satisfy a basic interface in order for them to be used. -type UpdateOptsBuilder interface { - ToPolicyUpdateMap() (map[string]interface{}, error) -} - -// UpdateOpts contains the values used when updating a firewall policy. -type UpdateOpts struct { - // Name of the firewall policy. - Name string - Description string - Shared *bool - Audited *bool - Rules []string -} - -// ToPolicyUpdateMap casts a CreateOpts struct to a map. -func (opts UpdateOpts) ToPolicyUpdateMap() (map[string]interface{}, error) { - p := make(map[string]interface{}) - - if opts.Name != "" { - p["name"] = opts.Name - } - if opts.Description != "" { - p["description"] = opts.Description - } - if opts.Shared != nil { - p["shared"] = *opts.Shared - } - if opts.Audited != nil { - p["audited"] = *opts.Audited - } - if opts.Rules != nil { - p["firewall_rules"] = opts.Rules - } - - return map[string]interface{}{"firewall_policy": p}, nil -} - -// Update allows firewall policies to be updated. -func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) UpdateResult { - var res UpdateResult - - reqBody, err := opts.ToPolicyUpdateMap() - if err != nil { - res.Err = err - return res - } - - // Send request to API - _, res.Err = c.Put(resourceURL(c, id), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - return res -} - -// Delete will permanently delete a particular firewall policy based on its unique ID. -func Delete(c *gophercloud.ServiceClient, id string) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(resourceURL(c, id), nil) - return res -} - -func InsertRule(c *gophercloud.ServiceClient, policyID, ruleID, beforeID, afterID string) error { - type request struct { - RuleId string `json:"firewall_rule_id"` - Before string `json:"insert_before,omitempty"` - After string `json:"insert_after,omitempty"` - } - - reqBody := request{ - RuleId: ruleID, - Before: beforeID, - After: afterID, - } - - // Send request to API - var res commonResult - _, res.Err = c.Put(insertURL(c, policyID), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - return res.Err -} - -func RemoveRule(c *gophercloud.ServiceClient, policyID, ruleID string) error { - type request struct { - RuleId string `json:"firewall_rule_id"` - } - - reqBody := request{ - RuleId: ruleID, - } - - // Send request to API - var res commonResult - _, res.Err = c.Put(removeURL(c, policyID), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - return res.Err -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies/results.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies/results.go deleted file mode 100644 index a9a0c358d5..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies/results.go +++ /dev/null @@ -1,101 +0,0 @@ -package policies - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -type Policy struct { - ID string `json:"id" mapstructure:"id"` - Name string `json:"name" mapstructure:"name"` - Description string `json:"description" mapstructure:"description"` - TenantID string `json:"tenant_id" mapstructure:"tenant_id"` - Audited bool `json:"audited" mapstructure:"audited"` - Shared bool `json:"shared" mapstructure:"shared"` - Rules []string `json:"firewall_rules,omitempty" mapstructure:"firewall_rules"` -} - -type commonResult struct { - gophercloud.Result -} - -// Extract is a function that accepts a result and extracts a firewall policy. -func (r commonResult) Extract() (*Policy, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Policy *Policy `json:"firewall_policy" mapstructure:"firewall_policy"` - } - - err := mapstructure.Decode(r.Body, &res) - - return res.Policy, err -} - -// PolicyPage is the page returned by a pager when traversing over a -// collection of firewall policies. -type PolicyPage struct { - pagination.LinkedPageBase -} - -// NextPageURL is invoked when a paginated collection of firewall policies has -// reached the end of a page and the pager seeks to traverse over a new one. -// In order to do this, it needs to construct the next page's URL. -func (p PolicyPage) NextPageURL() (string, error) { - type resp struct { - Links []gophercloud.Link `mapstructure:"firewall_policies_links"` - } - - var r resp - err := mapstructure.Decode(p.Body, &r) - if err != nil { - return "", err - } - - return gophercloud.ExtractNextURL(r.Links) -} - -// IsEmpty checks whether a PolicyPage struct is empty. -func (p PolicyPage) IsEmpty() (bool, error) { - is, err := ExtractPolicies(p) - if err != nil { - return true, nil - } - return len(is) == 0, nil -} - -// ExtractPolicies accepts a Page struct, specifically a RouterPage struct, -// and extracts the elements into a slice of Router structs. In other words, -// a generic collection is mapped into a relevant slice. -func ExtractPolicies(page pagination.Page) ([]Policy, error) { - var resp struct { - Policies []Policy `mapstructure:"firewall_policies" json:"firewall_policies"` - } - - err := mapstructure.Decode(page.(PolicyPage).Body, &resp) - - return resp.Policies, err -} - -// GetResult represents the result of a get operation. -type GetResult struct { - commonResult -} - -// UpdateResult represents the result of an update operation. -type UpdateResult struct { - commonResult -} - -// DeleteResult represents the result of a delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} - -// CreateResult represents the result of a create operation. -type CreateResult struct { - commonResult -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies/urls.go deleted file mode 100644 index 27ea9ae614..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies/urls.go +++ /dev/null @@ -1,26 +0,0 @@ -package policies - -import "github.com/rackspace/gophercloud" - -const ( - rootPath = "fw" - resourcePath = "firewall_policies" - insertPath = "insert_rule" - removePath = "remove_rule" -) - -func rootURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(rootPath, resourcePath) -} - -func resourceURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(rootPath, resourcePath, id) -} - -func insertURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(rootPath, resourcePath, id, insertPath) -} - -func removeURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(rootPath, resourcePath, id, removePath) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules/errors.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules/errors.go deleted file mode 100644 index 0b29d39fd9..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules/errors.go +++ /dev/null @@ -1,12 +0,0 @@ -package rules - -import "fmt" - -func err(str string) error { - return fmt.Errorf("%s", str) -} - -var ( - errProtocolRequired = err("A protocol is required (tcp, udp, icmp or any)") - errActionRequired = err("An action is required (allow or deny)") -) diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules/requests.go deleted file mode 100644 index 57a0e8baff..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules/requests.go +++ /dev/null @@ -1,285 +0,0 @@ -package rules - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// Binary gives users a solid type to work with for create and update -// operations. It is recommended that users use the `Yes` and `No` enums -type Binary *bool - -// Convenience vars for Enabled and Shared values. -var ( - iTrue = true - iFalse = false - Yes Binary = &iTrue - No Binary = &iFalse -) - -// ListOptsBuilder allows extensions to add additional parameters to the -// List request. -type ListOptsBuilder interface { - ToRuleListQuery() (string, error) -} - -// ListOpts allows the filtering and sorting of paginated collections through -// the API. Filtering is achieved by passing in struct field values that map to -// the Firewall rule attributes you want to see returned. SortKey allows you to -// sort by a particular firewall rule attribute. SortDir sets the direction, and is -// either `asc' or `desc'. Marker and Limit are used for pagination. -type ListOpts struct { - TenantID string `q:"tenant_id"` - Name string `q:"name"` - Description string `q:"description"` - Protocol string `q:"protocol"` - Action string `q:"action"` - IPVersion int `q:"ip_version"` - SourceIPAddress string `q:"source_ip_address"` - DestinationIPAddress string `q:"destination_ip_address"` - SourcePort string `q:"source_port"` - DestinationPort string `q:"destination_port"` - Enabled bool `q:"enabled"` - ID string `q:"id"` - Limit int `q:"limit"` - Marker string `q:"marker"` - SortKey string `q:"sort_key"` - SortDir string `q:"sort_dir"` -} - -// ToRuleListQuery formats a ListOpts into a query string. -func (opts ListOpts) ToRuleListQuery() (string, error) { - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return "", err - } - return q.String(), nil -} - -// List returns a Pager which allows you to iterate over a collection of -// firewall rules. It accepts a ListOpts struct, which allows you to filter -// and sort the returned collection for greater efficiency. -// -// Default policy settings return only those firewall rules that are owned by the -// tenant who submits the request, unless an admin user submits the request. -func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { - url := rootURL(c) - - if opts != nil { - query, err := opts.ToRuleListQuery() - if err != nil { - return pagination.Pager{Err: err} - } - url += query - } - - return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page { - return RulePage{pagination.LinkedPageBase{PageResult: r}} - }) -} - -// CreateOptsBuilder is the interface options structs have to satisfy in order -// to be used in the main Create operation in this package. Since many -// extensions decorate or modify the common logic, it is useful for them to -// satisfy a basic interface in order for them to be used. -type CreateOptsBuilder interface { - ToRuleCreateMap() (map[string]interface{}, error) -} - -// CreateOpts contains all the values needed to create a new firewall rule. -type CreateOpts struct { - // Mandatory for create - Protocol string - Action string - // Optional - TenantID string - Name string - Description string - IPVersion int - SourceIPAddress string - DestinationIPAddress string - SourcePort string - DestinationPort string - Shared *bool - Enabled *bool -} - -// ToRuleCreateMap casts a CreateOpts struct to a map. -func (opts CreateOpts) ToRuleCreateMap() (map[string]interface{}, error) { - if opts.Protocol == "" { - return nil, errProtocolRequired - } - - if opts.Action == "" { - return nil, errActionRequired - } - - r := make(map[string]interface{}) - - r["protocol"] = opts.Protocol - r["action"] = opts.Action - - if opts.TenantID != "" { - r["tenant_id"] = opts.TenantID - } - if opts.Name != "" { - r["name"] = opts.Name - } - if opts.Description != "" { - r["description"] = opts.Description - } - if opts.IPVersion != 0 { - r["ip_version"] = opts.IPVersion - } - if opts.SourceIPAddress != "" { - r["source_ip_address"] = opts.SourceIPAddress - } - if opts.DestinationIPAddress != "" { - r["destination_ip_address"] = opts.DestinationIPAddress - } - if opts.SourcePort != "" { - r["source_port"] = opts.SourcePort - } - if opts.DestinationPort != "" { - r["destination_port"] = opts.DestinationPort - } - if opts.Shared != nil { - r["shared"] = *opts.Shared - } - if opts.Enabled != nil { - r["enabled"] = *opts.Enabled - } - - return map[string]interface{}{"firewall_rule": r}, nil -} - -// Create accepts a CreateOpts struct and uses the values to create a new firewall rule -func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult { - var res CreateResult - - reqBody, err := opts.ToRuleCreateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil) - return res -} - -// Get retrieves a particular firewall rule based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) GetResult { - var res GetResult - _, res.Err = c.Get(resourceURL(c, id), &res.Body, nil) - return res -} - -// UpdateOptsBuilder is the interface options structs have to satisfy in order -// to be used in the main Update operation in this package. Since many -// extensions decorate or modify the common logic, it is useful for them to -// satisfy a basic interface in order for them to be used. -type UpdateOptsBuilder interface { - ToRuleUpdateMap() (map[string]interface{}, error) -} - -// UpdateOpts contains the values used when updating a firewall rule. -// Optional -type UpdateOpts struct { - Protocol string - Action string - Name string - Description string - IPVersion int - SourceIPAddress *string - DestinationIPAddress *string - SourcePort *string - DestinationPort *string - Shared *bool - Enabled *bool -} - -// ToRuleUpdateMap casts a UpdateOpts struct to a map. -func (opts UpdateOpts) ToRuleUpdateMap() (map[string]interface{}, error) { - r := make(map[string]interface{}) - - if opts.Protocol != "" { - r["protocol"] = opts.Protocol - } - if opts.Action != "" { - r["action"] = opts.Action - } - if opts.Name != "" { - r["name"] = opts.Name - } - if opts.Description != "" { - r["description"] = opts.Description - } - if opts.IPVersion != 0 { - r["ip_version"] = opts.IPVersion - } - if opts.SourceIPAddress != nil { - s := *opts.SourceIPAddress - if s == "" { - r["source_ip_address"] = nil - } else { - r["source_ip_address"] = s - } - } - if opts.DestinationIPAddress != nil { - s := *opts.DestinationIPAddress - if s == "" { - r["destination_ip_address"] = nil - } else { - r["destination_ip_address"] = s - } - } - if opts.SourcePort != nil { - s := *opts.SourcePort - if s == "" { - r["source_port"] = nil - } else { - r["source_port"] = s - } - } - if opts.DestinationPort != nil { - s := *opts.DestinationPort - if s == "" { - r["destination_port"] = nil - } else { - r["destination_port"] = s - } - } - if opts.Shared != nil { - r["shared"] = *opts.Shared - } - if opts.Enabled != nil { - r["enabled"] = *opts.Enabled - } - - return map[string]interface{}{"firewall_rule": r}, nil -} - -// Update allows firewall policies to be updated. -func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) UpdateResult { - var res UpdateResult - - reqBody, err := opts.ToRuleUpdateMap() - if err != nil { - res.Err = err - return res - } - - // Send request to API - _, res.Err = c.Put(resourceURL(c, id), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - - return res -} - -// Delete will permanently delete a particular firewall rule based on its unique ID. -func Delete(c *gophercloud.ServiceClient, id string) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(resourceURL(c, id), nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules/results.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules/results.go deleted file mode 100644 index d772024b39..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules/results.go +++ /dev/null @@ -1,110 +0,0 @@ -package rules - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// Rule represents a firewall rule -type Rule struct { - ID string `json:"id" mapstructure:"id"` - Name string `json:"name,omitempty" mapstructure:"name"` - Description string `json:"description,omitempty" mapstructure:"description"` - Protocol string `json:"protocol" mapstructure:"protocol"` - Action string `json:"action" mapstructure:"action"` - IPVersion int `json:"ip_version,omitempty" mapstructure:"ip_version"` - SourceIPAddress string `json:"source_ip_address,omitempty" mapstructure:"source_ip_address"` - DestinationIPAddress string `json:"destination_ip_address,omitempty" mapstructure:"destination_ip_address"` - SourcePort string `json:"source_port,omitempty" mapstructure:"source_port"` - DestinationPort string `json:"destination_port,omitempty" mapstructure:"destination_port"` - Shared bool `json:"shared,omitempty" mapstructure:"shared"` - Enabled bool `json:"enabled,omitempty" mapstructure:"enabled"` - PolicyID string `json:"firewall_policy_id" mapstructure:"firewall_policy_id"` - Position int `json:"position" mapstructure:"position"` - TenantID string `json:"tenant_id" mapstructure:"tenant_id"` -} - -// RulePage is the page returned by a pager when traversing over a -// collection of firewall rules. -type RulePage struct { - pagination.LinkedPageBase -} - -// NextPageURL is invoked when a paginated collection of firewall rules has -// reached the end of a page and the pager seeks to traverse over a new one. -// In order to do this, it needs to construct the next page's URL. -func (p RulePage) NextPageURL() (string, error) { - type resp struct { - Links []gophercloud.Link `mapstructure:"firewall_rules_links"` - } - - var r resp - err := mapstructure.Decode(p.Body, &r) - if err != nil { - return "", err - } - - return gophercloud.ExtractNextURL(r.Links) -} - -// IsEmpty checks whether a RulePage struct is empty. -func (p RulePage) IsEmpty() (bool, error) { - is, err := ExtractRules(p) - if err != nil { - return true, nil - } - return len(is) == 0, nil -} - -// ExtractRules accepts a Page struct, specifically a RouterPage struct, -// and extracts the elements into a slice of Router structs. In other words, -// a generic collection is mapped into a relevant slice. -func ExtractRules(page pagination.Page) ([]Rule, error) { - var resp struct { - Rules []Rule `mapstructure:"firewall_rules" json:"firewall_rules"` - } - - err := mapstructure.Decode(page.(RulePage).Body, &resp) - - return resp.Rules, err -} - -type commonResult struct { - gophercloud.Result -} - -// Extract is a function that accepts a result and extracts a firewall rule. -func (r commonResult) Extract() (*Rule, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Rule *Rule `json:"firewall_rule" mapstructure:"firewall_rule"` - } - - err := mapstructure.Decode(r.Body, &res) - - return res.Rule, err -} - -// GetResult represents the result of a get operation. -type GetResult struct { - commonResult -} - -// UpdateResult represents the result of an update operation. -type UpdateResult struct { - commonResult -} - -// DeleteResult represents the result of a delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} - -// CreateResult represents the result of a create operation. -type CreateResult struct { - commonResult -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules/urls.go deleted file mode 100644 index 20b08791ed..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules/urls.go +++ /dev/null @@ -1,16 +0,0 @@ -package rules - -import "github.com/rackspace/gophercloud" - -const ( - rootPath = "fw" - resourcePath = "firewall_rules" -) - -func rootURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(rootPath, resourcePath) -} - -func resourceURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(rootPath, resourcePath, id) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/doc.go deleted file mode 100644 index d533458267..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -// Package layer3 provides access to the Layer-3 networking extension for the -// OpenStack Neutron service. This extension allows API users to route packets -// between subnets, forward packets from internal networks to external ones, -// and access instances from external networks through floating IPs. -package layer3 diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers/requests.go deleted file mode 100644 index 077a71755a..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers/requests.go +++ /dev/null @@ -1,224 +0,0 @@ -package routers - -import ( - "errors" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// ListOpts allows the filtering and sorting of paginated collections through -// the API. Filtering is achieved by passing in struct field values that map to -// the floating IP attributes you want to see returned. SortKey allows you to -// sort by a particular network attribute. SortDir sets the direction, and is -// either `asc' or `desc'. Marker and Limit are used for pagination. -type ListOpts struct { - ID string `q:"id"` - Name string `q:"name"` - AdminStateUp *bool `q:"admin_state_up"` - Status string `q:"status"` - TenantID string `q:"tenant_id"` - Limit int `q:"limit"` - Marker string `q:"marker"` - SortKey string `q:"sort_key"` - SortDir string `q:"sort_dir"` -} - -// List returns a Pager which allows you to iterate over a collection of -// routers. It accepts a ListOpts struct, which allows you to filter and sort -// the returned collection for greater efficiency. -// -// Default policy settings return only those routers that are owned by the -// tenant who submits the request, unless an admin user submits the request. -func List(c *gophercloud.ServiceClient, opts ListOpts) pagination.Pager { - q, err := gophercloud.BuildQueryString(&opts) - if err != nil { - return pagination.Pager{Err: err} - } - u := rootURL(c) + q.String() - return pagination.NewPager(c, u, func(r pagination.PageResult) pagination.Page { - return RouterPage{pagination.LinkedPageBase{PageResult: r}} - }) -} - -// CreateOpts contains all the values needed to create a new router. There are -// no required values. -type CreateOpts struct { - Name string - AdminStateUp *bool - TenantID string - GatewayInfo *GatewayInfo -} - -// Create accepts a CreateOpts struct and uses the values to create a new -// logical router. When it is created, the router does not have an internal -// interface - it is not associated to any subnet. -// -// You can optionally specify an external gateway for a router using the -// GatewayInfo struct. The external gateway for the router must be plugged into -// an external network (it is external if its `router:external' field is set to -// true). -func Create(c *gophercloud.ServiceClient, opts CreateOpts) CreateResult { - type router struct { - Name *string `json:"name,omitempty"` - AdminStateUp *bool `json:"admin_state_up,omitempty"` - TenantID *string `json:"tenant_id,omitempty"` - GatewayInfo *GatewayInfo `json:"external_gateway_info,omitempty"` - } - - type request struct { - Router router `json:"router"` - } - - reqBody := request{Router: router{ - Name: gophercloud.MaybeString(opts.Name), - AdminStateUp: opts.AdminStateUp, - TenantID: gophercloud.MaybeString(opts.TenantID), - }} - - if opts.GatewayInfo != nil { - reqBody.Router.GatewayInfo = opts.GatewayInfo - } - - var res CreateResult - _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil) - return res -} - -// Get retrieves a particular router based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) GetResult { - var res GetResult - _, res.Err = c.Get(resourceURL(c, id), &res.Body, nil) - return res -} - -// UpdateOpts contains the values used when updating a router. -type UpdateOpts struct { - Name string - AdminStateUp *bool - GatewayInfo *GatewayInfo -} - -// Update allows routers to be updated. You can update the name, administrative -// state, and the external gateway. For more information about how to set the -// external gateway for a router, see Create. This operation does not enable -// the update of router interfaces. To do this, use the AddInterface and -// RemoveInterface functions. -func Update(c *gophercloud.ServiceClient, id string, opts UpdateOpts) UpdateResult { - type router struct { - Name *string `json:"name,omitempty"` - AdminStateUp *bool `json:"admin_state_up,omitempty"` - GatewayInfo *GatewayInfo `json:"external_gateway_info,omitempty"` - } - - type request struct { - Router router `json:"router"` - } - - reqBody := request{Router: router{ - Name: gophercloud.MaybeString(opts.Name), - AdminStateUp: opts.AdminStateUp, - }} - - if opts.GatewayInfo != nil { - reqBody.Router.GatewayInfo = opts.GatewayInfo - } - - // Send request to API - var res UpdateResult - _, res.Err = c.Put(resourceURL(c, id), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - - return res -} - -// Delete will permanently delete a particular router based on its unique ID. -func Delete(c *gophercloud.ServiceClient, id string) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(resourceURL(c, id), nil) - return res -} - -var errInvalidInterfaceOpts = errors.New("When adding a router interface you must provide either a subnet ID or a port ID") - -// InterfaceOpts allow you to work with operations that either add or remote -// an internal interface from a router. -type InterfaceOpts struct { - SubnetID string - PortID string -} - -// AddInterface attaches a subnet to an internal router interface. You must -// specify either a SubnetID or PortID in the request body. If you specify both, -// the operation will fail and an error will be returned. -// -// If you specify a SubnetID, the gateway IP address for that particular subnet -// is used to create the router interface. Alternatively, if you specify a -// PortID, the IP address associated with the port is used to create the router -// interface. -// -// If you reference a port that is associated with multiple IP addresses, or -// if the port is associated with zero IP addresses, the operation will fail and -// a 400 Bad Request error will be returned. -// -// If you reference a port already in use, the operation will fail and a 409 -// Conflict error will be returned. -// -// The PortID that is returned after using Extract() on the result of this -// operation can either be the same PortID passed in or, on the other hand, the -// identifier of a new port created by this operation. After the operation -// completes, the device ID of the port is set to the router ID, and the -// device owner attribute is set to `network:router_interface'. -func AddInterface(c *gophercloud.ServiceClient, id string, opts InterfaceOpts) InterfaceResult { - var res InterfaceResult - - // Validate - if (opts.SubnetID == "" && opts.PortID == "") || (opts.SubnetID != "" && opts.PortID != "") { - res.Err = errInvalidInterfaceOpts - return res - } - - type request struct { - SubnetID string `json:"subnet_id,omitempty"` - PortID string `json:"port_id,omitempty"` - } - - body := request{SubnetID: opts.SubnetID, PortID: opts.PortID} - - _, res.Err = c.Put(addInterfaceURL(c, id), body, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - - return res -} - -// RemoveInterface removes an internal router interface, which detaches a -// subnet from the router. You must specify either a SubnetID or PortID, since -// these values are used to identify the router interface to remove. -// -// Unlike AddInterface, you can also specify both a SubnetID and PortID. If you -// choose to specify both, the subnet ID must correspond to the subnet ID of -// the first IP address on the port specified by the port ID. Otherwise, the -// operation will fail and return a 409 Conflict error. -// -// If the router, subnet or port which are referenced do not exist or are not -// visible to you, the operation will fail and a 404 Not Found error will be -// returned. After this operation completes, the port connecting the router -// with the subnet is removed from the subnet for the network. -func RemoveInterface(c *gophercloud.ServiceClient, id string, opts InterfaceOpts) InterfaceResult { - var res InterfaceResult - - type request struct { - SubnetID string `json:"subnet_id,omitempty"` - PortID string `json:"port_id,omitempty"` - } - - body := request{SubnetID: opts.SubnetID, PortID: opts.PortID} - - _, res.Err = c.Put(removeInterfaceURL(c, id), body, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers/results.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers/results.go deleted file mode 100644 index bdad4cb2fd..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers/results.go +++ /dev/null @@ -1,161 +0,0 @@ -package routers - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// GatewayInfo represents the information of an external gateway for any -// particular network router. -type GatewayInfo struct { - NetworkID string `json:"network_id" mapstructure:"network_id"` -} - -// Router represents a Neutron router. A router is a logical entity that -// forwards packets across internal subnets and NATs (network address -// translation) them on external networks through an appropriate gateway. -// -// A router has an interface for each subnet with which it is associated. By -// default, the IP address of such interface is the subnet's gateway IP. Also, -// whenever a router is associated with a subnet, a port for that router -// interface is added to the subnet's network. -type Router struct { - // Indicates whether or not a router is currently operational. - Status string `json:"status" mapstructure:"status"` - - // Information on external gateway for the router. - GatewayInfo GatewayInfo `json:"external_gateway_info" mapstructure:"external_gateway_info"` - - // Administrative state of the router. - AdminStateUp bool `json:"admin_state_up" mapstructure:"admin_state_up"` - - // Human readable name for the router. Does not have to be unique. - Name string `json:"name" mapstructure:"name"` - - // Unique identifier for the router. - ID string `json:"id" mapstructure:"id"` - - // Owner of the router. Only admin users can specify a tenant identifier - // other than its own. - TenantID string `json:"tenant_id" mapstructure:"tenant_id"` -} - -// RouterPage is the page returned by a pager when traversing over a -// collection of routers. -type RouterPage struct { - pagination.LinkedPageBase -} - -// NextPageURL is invoked when a paginated collection of routers has reached -// the end of a page and the pager seeks to traverse over a new one. In order -// to do this, it needs to construct the next page's URL. -func (p RouterPage) NextPageURL() (string, error) { - type resp struct { - Links []gophercloud.Link `mapstructure:"routers_links"` - } - - var r resp - err := mapstructure.Decode(p.Body, &r) - if err != nil { - return "", err - } - - return gophercloud.ExtractNextURL(r.Links) -} - -// IsEmpty checks whether a RouterPage struct is empty. -func (p RouterPage) IsEmpty() (bool, error) { - is, err := ExtractRouters(p) - if err != nil { - return true, nil - } - return len(is) == 0, nil -} - -// ExtractRouters accepts a Page struct, specifically a RouterPage struct, -// and extracts the elements into a slice of Router structs. In other words, -// a generic collection is mapped into a relevant slice. -func ExtractRouters(page pagination.Page) ([]Router, error) { - var resp struct { - Routers []Router `mapstructure:"routers" json:"routers"` - } - - err := mapstructure.Decode(page.(RouterPage).Body, &resp) - - return resp.Routers, err -} - -type commonResult struct { - gophercloud.Result -} - -// Extract is a function that accepts a result and extracts a router. -func (r commonResult) Extract() (*Router, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Router *Router `json:"router"` - } - - err := mapstructure.Decode(r.Body, &res) - - return res.Router, err -} - -// CreateResult represents the result of a create operation. -type CreateResult struct { - commonResult -} - -// GetResult represents the result of a get operation. -type GetResult struct { - commonResult -} - -// UpdateResult represents the result of an update operation. -type UpdateResult struct { - commonResult -} - -// DeleteResult represents the result of a delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} - -// InterfaceInfo represents information about a particular router interface. As -// mentioned above, in order for a router to forward to a subnet, it needs an -// interface. -type InterfaceInfo struct { - // The ID of the subnet which this interface is associated with. - SubnetID string `json:"subnet_id" mapstructure:"subnet_id"` - - // The ID of the port that is a part of the subnet. - PortID string `json:"port_id" mapstructure:"port_id"` - - // The UUID of the interface. - ID string `json:"id" mapstructure:"id"` - - // Owner of the interface. - TenantID string `json:"tenant_id" mapstructure:"tenant_id"` -} - -// InterfaceResult represents the result of interface operations, such as -// AddInterface() and RemoveInterface(). -type InterfaceResult struct { - gophercloud.Result -} - -// Extract is a function that accepts a result and extracts an information struct. -func (r InterfaceResult) Extract() (*InterfaceInfo, error) { - if r.Err != nil { - return nil, r.Err - } - - var res *InterfaceInfo - err := mapstructure.Decode(r.Body, &res) - - return res, err -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers/urls.go deleted file mode 100644 index bc22c2a8a8..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers/urls.go +++ /dev/null @@ -1,21 +0,0 @@ -package routers - -import "github.com/rackspace/gophercloud" - -const resourcePath = "routers" - -func rootURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(resourcePath) -} - -func resourceURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(resourcePath, id) -} - -func addInterfaceURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(resourcePath, id, "add_router_interface") -} - -func removeInterfaceURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(resourcePath, id, "remove_router_interface") -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/doc.go deleted file mode 100644 index bc1fc282f4..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package lbaas provides information and interaction with the Load Balancer -// as a Service extension for the OpenStack Networking service. -package lbaas diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/members/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/members/requests.go deleted file mode 100644 index 848938f983..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/members/requests.go +++ /dev/null @@ -1,123 +0,0 @@ -package members - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// ListOpts allows the filtering and sorting of paginated collections through -// the API. Filtering is achieved by passing in struct field values that map to -// the floating IP attributes you want to see returned. SortKey allows you to -// sort by a particular network attribute. SortDir sets the direction, and is -// either `asc' or `desc'. Marker and Limit are used for pagination. -type ListOpts struct { - Status string `q:"status"` - Weight int `q:"weight"` - AdminStateUp *bool `q:"admin_state_up"` - TenantID string `q:"tenant_id"` - PoolID string `q:"pool_id"` - Address string `q:"address"` - ProtocolPort int `q:"protocol_port"` - ID string `q:"id"` - Limit int `q:"limit"` - Marker string `q:"marker"` - SortKey string `q:"sort_key"` - SortDir string `q:"sort_dir"` -} - -// List returns a Pager which allows you to iterate over a collection of -// pools. It accepts a ListOpts struct, which allows you to filter and sort -// the returned collection for greater efficiency. -// -// Default policy settings return only those pools that are owned by the -// tenant who submits the request, unless an admin user submits the request. -func List(c *gophercloud.ServiceClient, opts ListOpts) pagination.Pager { - q, err := gophercloud.BuildQueryString(&opts) - if err != nil { - return pagination.Pager{Err: err} - } - u := rootURL(c) + q.String() - return pagination.NewPager(c, u, func(r pagination.PageResult) pagination.Page { - return MemberPage{pagination.LinkedPageBase{PageResult: r}} - }) -} - -// CreateOpts contains all the values needed to create a new pool member. -type CreateOpts struct { - // Only required if the caller has an admin role and wants to create a pool - // for another tenant. - TenantID string - - // Required. The IP address of the member. - Address string - - // Required. The port on which the application is hosted. - ProtocolPort int - - // Required. The pool to which this member will belong. - PoolID string -} - -// Create accepts a CreateOpts struct and uses the values to create a new -// load balancer pool member. -func Create(c *gophercloud.ServiceClient, opts CreateOpts) CreateResult { - type member struct { - TenantID string `json:"tenant_id,omitempty"` - ProtocolPort int `json:"protocol_port"` - Address string `json:"address"` - PoolID string `json:"pool_id"` - } - type request struct { - Member member `json:"member"` - } - - reqBody := request{Member: member{ - Address: opts.Address, - TenantID: opts.TenantID, - ProtocolPort: opts.ProtocolPort, - PoolID: opts.PoolID, - }} - - var res CreateResult - _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil) - return res -} - -// Get retrieves a particular pool member based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) GetResult { - var res GetResult - _, res.Err = c.Get(resourceURL(c, id), &res.Body, nil) - return res -} - -// UpdateOpts contains the values used when updating a pool member. -type UpdateOpts struct { - // The administrative state of the member, which is up (true) or down (false). - AdminStateUp bool -} - -// Update allows members to be updated. -func Update(c *gophercloud.ServiceClient, id string, opts UpdateOpts) UpdateResult { - type member struct { - AdminStateUp bool `json:"admin_state_up"` - } - type request struct { - Member member `json:"member"` - } - - reqBody := request{Member: member{AdminStateUp: opts.AdminStateUp}} - - // Send request to API - var res UpdateResult - _, res.Err = c.Put(resourceURL(c, id), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200, 201, 202}, - }) - return res -} - -// Delete will permanently delete a particular member based on its unique ID. -func Delete(c *gophercloud.ServiceClient, id string) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(resourceURL(c, id), nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/members/results.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/members/results.go deleted file mode 100644 index 3cad339b77..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/members/results.go +++ /dev/null @@ -1,122 +0,0 @@ -package members - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// Member represents the application running on a backend server. -type Member struct { - // The status of the member. Indicates whether the member is operational. - Status string - - // Weight of member. - Weight int - - // The administrative state of the member, which is up (true) or down (false). - AdminStateUp bool `json:"admin_state_up" mapstructure:"admin_state_up"` - - // Owner of the member. Only an administrative user can specify a tenant ID - // other than its own. - TenantID string `json:"tenant_id" mapstructure:"tenant_id"` - - // The pool to which the member belongs. - PoolID string `json:"pool_id" mapstructure:"pool_id"` - - // The IP address of the member. - Address string - - // The port on which the application is hosted. - ProtocolPort int `json:"protocol_port" mapstructure:"protocol_port"` - - // The unique ID for the member. - ID string -} - -// MemberPage is the page returned by a pager when traversing over a -// collection of pool members. -type MemberPage struct { - pagination.LinkedPageBase -} - -// NextPageURL is invoked when a paginated collection of members has reached -// the end of a page and the pager seeks to traverse over a new one. In order -// to do this, it needs to construct the next page's URL. -func (p MemberPage) NextPageURL() (string, error) { - type resp struct { - Links []gophercloud.Link `mapstructure:"members_links"` - } - - var r resp - err := mapstructure.Decode(p.Body, &r) - if err != nil { - return "", err - } - - return gophercloud.ExtractNextURL(r.Links) -} - -// IsEmpty checks whether a MemberPage struct is empty. -func (p MemberPage) IsEmpty() (bool, error) { - is, err := ExtractMembers(p) - if err != nil { - return true, nil - } - return len(is) == 0, nil -} - -// ExtractMembers accepts a Page struct, specifically a MemberPage struct, -// and extracts the elements into a slice of Member structs. In other words, -// a generic collection is mapped into a relevant slice. -func ExtractMembers(page pagination.Page) ([]Member, error) { - var resp struct { - Members []Member `mapstructure:"members" json:"members"` - } - - err := mapstructure.Decode(page.(MemberPage).Body, &resp) - if err != nil { - return nil, err - } - - return resp.Members, nil -} - -type commonResult struct { - gophercloud.Result -} - -// Extract is a function that accepts a result and extracts a router. -func (r commonResult) Extract() (*Member, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Member *Member `json:"member"` - } - - err := mapstructure.Decode(r.Body, &res) - - return res.Member, err -} - -// CreateResult represents the result of a create operation. -type CreateResult struct { - commonResult -} - -// GetResult represents the result of a get operation. -type GetResult struct { - commonResult -} - -// UpdateResult represents the result of an update operation. -type UpdateResult struct { - commonResult -} - -// DeleteResult represents the result of a delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/members/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/members/urls.go deleted file mode 100644 index 94b57e4c58..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/members/urls.go +++ /dev/null @@ -1,16 +0,0 @@ -package members - -import "github.com/rackspace/gophercloud" - -const ( - rootPath = "lb" - resourcePath = "members" -) - -func rootURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(rootPath, resourcePath) -} - -func resourceURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(rootPath, resourcePath, id) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/monitors/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/monitors/requests.go deleted file mode 100644 index 71b21ef16e..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/monitors/requests.go +++ /dev/null @@ -1,265 +0,0 @@ -package monitors - -import ( - "fmt" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// ListOpts allows the filtering and sorting of paginated collections through -// the API. Filtering is achieved by passing in struct field values that map to -// the floating IP attributes you want to see returned. SortKey allows you to -// sort by a particular network attribute. SortDir sets the direction, and is -// either `asc' or `desc'. Marker and Limit are used for pagination. -type ListOpts struct { - ID string `q:"id"` - TenantID string `q:"tenant_id"` - Type string `q:"type"` - Delay int `q:"delay"` - Timeout int `q:"timeout"` - MaxRetries int `q:"max_retries"` - HTTPMethod string `q:"http_method"` - URLPath string `q:"url_path"` - ExpectedCodes string `q:"expected_codes"` - AdminStateUp *bool `q:"admin_state_up"` - Status string `q:"status"` - Limit int `q:"limit"` - Marker string `q:"marker"` - SortKey string `q:"sort_key"` - SortDir string `q:"sort_dir"` -} - -// List returns a Pager which allows you to iterate over a collection of -// routers. It accepts a ListOpts struct, which allows you to filter and sort -// the returned collection for greater efficiency. -// -// Default policy settings return only those routers that are owned by the -// tenant who submits the request, unless an admin user submits the request. -func List(c *gophercloud.ServiceClient, opts ListOpts) pagination.Pager { - q, err := gophercloud.BuildQueryString(&opts) - if err != nil { - return pagination.Pager{Err: err} - } - u := rootURL(c) + q.String() - - return pagination.NewPager(c, u, func(r pagination.PageResult) pagination.Page { - return MonitorPage{pagination.LinkedPageBase{PageResult: r}} - }) -} - -// Constants that represent approved monitoring types. -const ( - TypePING = "PING" - TypeTCP = "TCP" - TypeHTTP = "HTTP" - TypeHTTPS = "HTTPS" -) - -var ( - errValidTypeRequired = fmt.Errorf("A valid Type is required. Supported values are PING, TCP, HTTP and HTTPS") - errDelayRequired = fmt.Errorf("Delay is required") - errTimeoutRequired = fmt.Errorf("Timeout is required") - errMaxRetriesRequired = fmt.Errorf("MaxRetries is required") - errURLPathRequired = fmt.Errorf("URL path is required") - errExpectedCodesRequired = fmt.Errorf("ExpectedCodes is required") - errDelayMustGETimeout = fmt.Errorf("Delay must be greater than or equal to timeout") -) - -// CreateOpts contains all the values needed to create a new health monitor. -type CreateOpts struct { - // Required for admins. Indicates the owner of the VIP. - TenantID string - - // Required. The type of probe, which is PING, TCP, HTTP, or HTTPS, that is - // sent by the load balancer to verify the member state. - Type string - - // Required. The time, in seconds, between sending probes to members. - Delay int - - // Required. Maximum number of seconds for a monitor to wait for a ping reply - // before it times out. The value must be less than the delay value. - Timeout int - - // Required. Number of permissible ping failures before changing the member's - // status to INACTIVE. Must be a number between 1 and 10. - MaxRetries int - - // Required for HTTP(S) types. URI path that will be accessed if monitor type - // is HTTP or HTTPS. - URLPath string - - // Required for HTTP(S) types. The HTTP method used for requests by the - // monitor. If this attribute is not specified, it defaults to "GET". - HTTPMethod string - - // Required for HTTP(S) types. Expected HTTP codes for a passing HTTP(S) - // monitor. You can either specify a single status like "200", or a range - // like "200-202". - ExpectedCodes string - - AdminStateUp *bool -} - -// Create is an operation which provisions a new health monitor. There are -// different types of monitor you can provision: PING, TCP or HTTP(S). Below -// are examples of how to create each one. -// -// Here is an example config struct to use when creating a PING or TCP monitor: -// -// CreateOpts{Type: TypePING, Delay: 20, Timeout: 10, MaxRetries: 3} -// CreateOpts{Type: TypeTCP, Delay: 20, Timeout: 10, MaxRetries: 3} -// -// Here is an example config struct to use when creating a HTTP(S) monitor: -// -// CreateOpts{Type: TypeHTTP, Delay: 20, Timeout: 10, MaxRetries: 3, -// HttpMethod: "HEAD", ExpectedCodes: "200"} -// -func Create(c *gophercloud.ServiceClient, opts CreateOpts) CreateResult { - var res CreateResult - - // Validate inputs - allowed := map[string]bool{TypeHTTP: true, TypeHTTPS: true, TypeTCP: true, TypePING: true} - if opts.Type == "" || allowed[opts.Type] == false { - res.Err = errValidTypeRequired - } - if opts.Delay == 0 { - res.Err = errDelayRequired - } - if opts.Timeout == 0 { - res.Err = errTimeoutRequired - } - if opts.MaxRetries == 0 { - res.Err = errMaxRetriesRequired - } - if opts.Type == TypeHTTP || opts.Type == TypeHTTPS { - if opts.URLPath == "" { - res.Err = errURLPathRequired - } - if opts.ExpectedCodes == "" { - res.Err = errExpectedCodesRequired - } - } - if opts.Delay < opts.Timeout { - res.Err = errDelayMustGETimeout - } - if res.Err != nil { - return res - } - - type monitor struct { - Type string `json:"type"` - Delay int `json:"delay"` - Timeout int `json:"timeout"` - MaxRetries int `json:"max_retries"` - TenantID *string `json:"tenant_id,omitempty"` - URLPath *string `json:"url_path,omitempty"` - ExpectedCodes *string `json:"expected_codes,omitempty"` - HTTPMethod *string `json:"http_method,omitempty"` - AdminStateUp *bool `json:"admin_state_up,omitempty"` - } - - type request struct { - Monitor monitor `json:"health_monitor"` - } - - reqBody := request{Monitor: monitor{ - Type: opts.Type, - Delay: opts.Delay, - Timeout: opts.Timeout, - MaxRetries: opts.MaxRetries, - TenantID: gophercloud.MaybeString(opts.TenantID), - URLPath: gophercloud.MaybeString(opts.URLPath), - ExpectedCodes: gophercloud.MaybeString(opts.ExpectedCodes), - HTTPMethod: gophercloud.MaybeString(opts.HTTPMethod), - AdminStateUp: opts.AdminStateUp, - }} - - _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil) - return res -} - -// Get retrieves a particular health monitor based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) GetResult { - var res GetResult - _, res.Err = c.Get(resourceURL(c, id), &res.Body, nil) - return res -} - -// UpdateOpts contains all the values needed to update an existing virtual IP. -// Attributes not listed here but appear in CreateOpts are immutable and cannot -// be updated. -type UpdateOpts struct { - // Required. The time, in seconds, between sending probes to members. - Delay int - - // Required. Maximum number of seconds for a monitor to wait for a ping reply - // before it times out. The value must be less than the delay value. - Timeout int - - // Required. Number of permissible ping failures before changing the member's - // status to INACTIVE. Must be a number between 1 and 10. - MaxRetries int - - // Required for HTTP(S) types. URI path that will be accessed if monitor type - // is HTTP or HTTPS. - URLPath string - - // Required for HTTP(S) types. The HTTP method used for requests by the - // monitor. If this attribute is not specified, it defaults to "GET". - HTTPMethod string - - // Required for HTTP(S) types. Expected HTTP codes for a passing HTTP(S) - // monitor. You can either specify a single status like "200", or a range - // like "200-202". - ExpectedCodes string - - AdminStateUp *bool -} - -// Update is an operation which modifies the attributes of the specified monitor. -func Update(c *gophercloud.ServiceClient, id string, opts UpdateOpts) UpdateResult { - var res UpdateResult - - if opts.Delay > 0 && opts.Timeout > 0 && opts.Delay < opts.Timeout { - res.Err = errDelayMustGETimeout - } - - type monitor struct { - Delay int `json:"delay"` - Timeout int `json:"timeout"` - MaxRetries int `json:"max_retries"` - URLPath *string `json:"url_path,omitempty"` - ExpectedCodes *string `json:"expected_codes,omitempty"` - HTTPMethod *string `json:"http_method,omitempty"` - AdminStateUp *bool `json:"admin_state_up,omitempty"` - } - - type request struct { - Monitor monitor `json:"health_monitor"` - } - - reqBody := request{Monitor: monitor{ - Delay: opts.Delay, - Timeout: opts.Timeout, - MaxRetries: opts.MaxRetries, - URLPath: gophercloud.MaybeString(opts.URLPath), - ExpectedCodes: gophercloud.MaybeString(opts.ExpectedCodes), - HTTPMethod: gophercloud.MaybeString(opts.HTTPMethod), - AdminStateUp: opts.AdminStateUp, - }} - - _, res.Err = c.Put(resourceURL(c, id), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200, 202}, - }) - - return res -} - -// Delete will permanently delete a particular monitor based on its unique ID. -func Delete(c *gophercloud.ServiceClient, id string) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(resourceURL(c, id), nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/monitors/results.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/monitors/results.go deleted file mode 100644 index d595abd540..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/monitors/results.go +++ /dev/null @@ -1,147 +0,0 @@ -package monitors - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// Monitor represents a load balancer health monitor. A health monitor is used -// to determine whether or not back-end members of the VIP's pool are usable -// for processing a request. A pool can have several health monitors associated -// with it. There are different types of health monitors supported: -// -// PING: used to ping the members using ICMP. -// TCP: used to connect to the members using TCP. -// HTTP: used to send an HTTP request to the member. -// HTTPS: used to send a secure HTTP request to the member. -// -// When a pool has several monitors associated with it, each member of the pool -// is monitored by all these monitors. If any monitor declares the member as -// unhealthy, then the member status is changed to INACTIVE and the member -// won't participate in its pool's load balancing. In other words, ALL monitors -// must declare the member to be healthy for it to stay ACTIVE. -type Monitor struct { - // The unique ID for the VIP. - ID string - - // Owner of the VIP. Only an administrative user can specify a tenant ID - // other than its own. - TenantID string `json:"tenant_id" mapstructure:"tenant_id"` - - // The type of probe sent by the load balancer to verify the member state, - // which is PING, TCP, HTTP, or HTTPS. - Type string - - // The time, in seconds, between sending probes to members. - Delay int - - // The maximum number of seconds for a monitor to wait for a connection to be - // established before it times out. This value must be less than the delay value. - Timeout int - - // Number of allowed connection failures before changing the status of the - // member to INACTIVE. A valid value is from 1 to 10. - MaxRetries int `json:"max_retries" mapstructure:"max_retries"` - - // The HTTP method that the monitor uses for requests. - HTTPMethod string `json:"http_method" mapstructure:"http_method"` - - // The HTTP path of the request sent by the monitor to test the health of a - // member. Must be a string beginning with a forward slash (/). - URLPath string `json:"url_path" mapstructure:"url_path"` - - // Expected HTTP codes for a passing HTTP(S) monitor. - ExpectedCodes string `json:"expected_codes" mapstructure:"expected_codes"` - - // The administrative state of the health monitor, which is up (true) or down (false). - AdminStateUp bool `json:"admin_state_up" mapstructure:"admin_state_up"` - - // The status of the health monitor. Indicates whether the health monitor is - // operational. - Status string -} - -// MonitorPage is the page returned by a pager when traversing over a -// collection of health monitors. -type MonitorPage struct { - pagination.LinkedPageBase -} - -// NextPageURL is invoked when a paginated collection of monitors has reached -// the end of a page and the pager seeks to traverse over a new one. In order -// to do this, it needs to construct the next page's URL. -func (p MonitorPage) NextPageURL() (string, error) { - type resp struct { - Links []gophercloud.Link `mapstructure:"health_monitors_links"` - } - - var r resp - err := mapstructure.Decode(p.Body, &r) - if err != nil { - return "", err - } - - return gophercloud.ExtractNextURL(r.Links) -} - -// IsEmpty checks whether a PoolPage struct is empty. -func (p MonitorPage) IsEmpty() (bool, error) { - is, err := ExtractMonitors(p) - if err != nil { - return true, nil - } - return len(is) == 0, nil -} - -// ExtractMonitors accepts a Page struct, specifically a MonitorPage struct, -// and extracts the elements into a slice of Monitor structs. In other words, -// a generic collection is mapped into a relevant slice. -func ExtractMonitors(page pagination.Page) ([]Monitor, error) { - var resp struct { - Monitors []Monitor `mapstructure:"health_monitors" json:"health_monitors"` - } - - err := mapstructure.Decode(page.(MonitorPage).Body, &resp) - - return resp.Monitors, err -} - -type commonResult struct { - gophercloud.Result -} - -// Extract is a function that accepts a result and extracts a monitor. -func (r commonResult) Extract() (*Monitor, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Monitor *Monitor `json:"health_monitor" mapstructure:"health_monitor"` - } - - err := mapstructure.Decode(r.Body, &res) - - return res.Monitor, err -} - -// CreateResult represents the result of a create operation. -type CreateResult struct { - commonResult -} - -// GetResult represents the result of a get operation. -type GetResult struct { - commonResult -} - -// UpdateResult represents the result of an update operation. -type UpdateResult struct { - commonResult -} - -// DeleteResult represents the result of a delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/monitors/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/monitors/urls.go deleted file mode 100644 index 46e84bbf52..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/monitors/urls.go +++ /dev/null @@ -1,16 +0,0 @@ -package monitors - -import "github.com/rackspace/gophercloud" - -const ( - rootPath = "lb" - resourcePath = "health_monitors" -) - -func rootURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(rootPath, resourcePath) -} - -func resourceURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(rootPath, resourcePath, id) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/pools/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/pools/requests.go deleted file mode 100644 index 2bb0acc447..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/pools/requests.go +++ /dev/null @@ -1,181 +0,0 @@ -package pools - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// ListOpts allows the filtering and sorting of paginated collections through -// the API. Filtering is achieved by passing in struct field values that map to -// the floating IP attributes you want to see returned. SortKey allows you to -// sort by a particular network attribute. SortDir sets the direction, and is -// either `asc' or `desc'. Marker and Limit are used for pagination. -type ListOpts struct { - Status string `q:"status"` - LBMethod string `q:"lb_method"` - Protocol string `q:"protocol"` - SubnetID string `q:"subnet_id"` - TenantID string `q:"tenant_id"` - AdminStateUp *bool `q:"admin_state_up"` - Name string `q:"name"` - ID string `q:"id"` - VIPID string `q:"vip_id"` - Limit int `q:"limit"` - Marker string `q:"marker"` - SortKey string `q:"sort_key"` - SortDir string `q:"sort_dir"` -} - -// List returns a Pager which allows you to iterate over a collection of -// pools. It accepts a ListOpts struct, which allows you to filter and sort -// the returned collection for greater efficiency. -// -// Default policy settings return only those pools that are owned by the -// tenant who submits the request, unless an admin user submits the request. -func List(c *gophercloud.ServiceClient, opts ListOpts) pagination.Pager { - q, err := gophercloud.BuildQueryString(&opts) - if err != nil { - return pagination.Pager{Err: err} - } - u := rootURL(c) + q.String() - return pagination.NewPager(c, u, func(r pagination.PageResult) pagination.Page { - return PoolPage{pagination.LinkedPageBase{PageResult: r}} - }) -} - -// Supported attributes for create/update operations. -const ( - LBMethodRoundRobin = "ROUND_ROBIN" - LBMethodLeastConnections = "LEAST_CONNECTIONS" - - ProtocolTCP = "TCP" - ProtocolHTTP = "HTTP" - ProtocolHTTPS = "HTTPS" -) - -// CreateOpts contains all the values needed to create a new pool. -type CreateOpts struct { - // Only required if the caller has an admin role and wants to create a pool - // for another tenant. - TenantID string - - // Required. Name of the pool. - Name string - - // Required. The protocol used by the pool members, you can use either - // ProtocolTCP, ProtocolHTTP, or ProtocolHTTPS. - Protocol string - - // The network on which the members of the pool will be located. Only members - // that are on this network can be added to the pool. - SubnetID string - - // The algorithm used to distribute load between the members of the pool. The - // current specification supports LBMethodRoundRobin and - // LBMethodLeastConnections as valid values for this attribute. - LBMethod string -} - -// Create accepts a CreateOpts struct and uses the values to create a new -// load balancer pool. -func Create(c *gophercloud.ServiceClient, opts CreateOpts) CreateResult { - type pool struct { - Name string `json:"name"` - TenantID string `json:"tenant_id,omitempty"` - Protocol string `json:"protocol"` - SubnetID string `json:"subnet_id"` - LBMethod string `json:"lb_method"` - } - type request struct { - Pool pool `json:"pool"` - } - - reqBody := request{Pool: pool{ - Name: opts.Name, - TenantID: opts.TenantID, - Protocol: opts.Protocol, - SubnetID: opts.SubnetID, - LBMethod: opts.LBMethod, - }} - - var res CreateResult - _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil) - return res -} - -// Get retrieves a particular pool based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) GetResult { - var res GetResult - _, res.Err = c.Get(resourceURL(c, id), &res.Body, nil) - return res -} - -// UpdateOpts contains the values used when updating a pool. -type UpdateOpts struct { - // Required. Name of the pool. - Name string - - // The algorithm used to distribute load between the members of the pool. The - // current specification supports LBMethodRoundRobin and - // LBMethodLeastConnections as valid values for this attribute. - LBMethod string -} - -// Update allows pools to be updated. -func Update(c *gophercloud.ServiceClient, id string, opts UpdateOpts) UpdateResult { - type pool struct { - Name string `json:"name,"` - LBMethod string `json:"lb_method"` - } - type request struct { - Pool pool `json:"pool"` - } - - reqBody := request{Pool: pool{ - Name: opts.Name, - LBMethod: opts.LBMethod, - }} - - // Send request to API - var res UpdateResult - _, res.Err = c.Put(resourceURL(c, id), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - return res -} - -// Delete will permanently delete a particular pool based on its unique ID. -func Delete(c *gophercloud.ServiceClient, id string) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(resourceURL(c, id), nil) - return res -} - -// AssociateMonitor will associate a health monitor with a particular pool. -// Once associated, the health monitor will start monitoring the members of the -// pool and will deactivate these members if they are deemed unhealthy. A -// member can be deactivated (status set to INACTIVE) if any of health monitors -// finds it unhealthy. -func AssociateMonitor(c *gophercloud.ServiceClient, poolID, monitorID string) AssociateResult { - type hm struct { - ID string `json:"id"` - } - type request struct { - Monitor hm `json:"health_monitor"` - } - - reqBody := request{hm{ID: monitorID}} - - var res AssociateResult - _, res.Err = c.Post(associateURL(c, poolID), reqBody, &res.Body, nil) - return res -} - -// DisassociateMonitor will disassociate a health monitor with a particular -// pool. When dissociation is successful, the health monitor will no longer -// check for the health of the members of the pool. -func DisassociateMonitor(c *gophercloud.ServiceClient, poolID, monitorID string) AssociateResult { - var res AssociateResult - _, res.Err = c.Delete(disassociateURL(c, poolID, monitorID), nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/pools/results.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/pools/results.go deleted file mode 100644 index 07ec85eda4..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/pools/results.go +++ /dev/null @@ -1,146 +0,0 @@ -package pools - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// Pool represents a logical set of devices, such as web servers, that you -// group together to receive and process traffic. The load balancing function -// chooses a member of the pool according to the configured load balancing -// method to handle the new requests or connections received on the VIP address. -// There is only one pool per virtual IP. -type Pool struct { - // The status of the pool. Indicates whether the pool is operational. - Status string - - // The load-balancer algorithm, which is round-robin, least-connections, and - // so on. This value, which must be supported, is dependent on the provider. - // Round-robin must be supported. - LBMethod string `json:"lb_method" mapstructure:"lb_method"` - - // The protocol of the pool, which is TCP, HTTP, or HTTPS. - Protocol string - - // Description for the pool. - Description string - - // The IDs of associated monitors which check the health of the pool members. - MonitorIDs []string `json:"health_monitors" mapstructure:"health_monitors"` - - // The network on which the members of the pool will be located. Only members - // that are on this network can be added to the pool. - SubnetID string `json:"subnet_id" mapstructure:"subnet_id"` - - // Owner of the pool. Only an administrative user can specify a tenant ID - // other than its own. - TenantID string `json:"tenant_id" mapstructure:"tenant_id"` - - // The administrative state of the pool, which is up (true) or down (false). - AdminStateUp bool `json:"admin_state_up" mapstructure:"admin_state_up"` - - // Pool name. Does not have to be unique. - Name string - - // List of member IDs that belong to the pool. - MemberIDs []string `json:"members" mapstructure:"members"` - - // The unique ID for the pool. - ID string - - // The ID of the virtual IP associated with this pool - VIPID string `json:"vip_id" mapstructure:"vip_id"` - - // The provider - Provider string -} - -// PoolPage is the page returned by a pager when traversing over a -// collection of pools. -type PoolPage struct { - pagination.LinkedPageBase -} - -// NextPageURL is invoked when a paginated collection of pools has reached -// the end of a page and the pager seeks to traverse over a new one. In order -// to do this, it needs to construct the next page's URL. -func (p PoolPage) NextPageURL() (string, error) { - type resp struct { - Links []gophercloud.Link `mapstructure:"pools_links"` - } - - var r resp - err := mapstructure.Decode(p.Body, &r) - if err != nil { - return "", err - } - - return gophercloud.ExtractNextURL(r.Links) -} - -// IsEmpty checks whether a PoolPage struct is empty. -func (p PoolPage) IsEmpty() (bool, error) { - is, err := ExtractPools(p) - if err != nil { - return true, nil - } - return len(is) == 0, nil -} - -// ExtractPools accepts a Page struct, specifically a RouterPage struct, -// and extracts the elements into a slice of Router structs. In other words, -// a generic collection is mapped into a relevant slice. -func ExtractPools(page pagination.Page) ([]Pool, error) { - var resp struct { - Pools []Pool `mapstructure:"pools" json:"pools"` - } - - err := mapstructure.Decode(page.(PoolPage).Body, &resp) - - return resp.Pools, err -} - -type commonResult struct { - gophercloud.Result -} - -// Extract is a function that accepts a result and extracts a router. -func (r commonResult) Extract() (*Pool, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Pool *Pool `json:"pool"` - } - - err := mapstructure.Decode(r.Body, &res) - - return res.Pool, err -} - -// CreateResult represents the result of a create operation. -type CreateResult struct { - commonResult -} - -// GetResult represents the result of a get operation. -type GetResult struct { - commonResult -} - -// UpdateResult represents the result of an update operation. -type UpdateResult struct { - commonResult -} - -// DeleteResult represents the result of a delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} - -// AssociateResult represents the result of an association operation. -type AssociateResult struct { - commonResult -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/pools/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/pools/urls.go deleted file mode 100644 index 6cd15b0026..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/pools/urls.go +++ /dev/null @@ -1,25 +0,0 @@ -package pools - -import "github.com/rackspace/gophercloud" - -const ( - rootPath = "lb" - resourcePath = "pools" - monitorPath = "health_monitors" -) - -func rootURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(rootPath, resourcePath) -} - -func resourceURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(rootPath, resourcePath, id) -} - -func associateURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(rootPath, resourcePath, id, monitorPath) -} - -func disassociateURL(c *gophercloud.ServiceClient, poolID, monitorID string) string { - return c.ServiceURL(rootPath, resourcePath, poolID, monitorPath, monitorID) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/vips/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/vips/requests.go deleted file mode 100644 index 6216f873e3..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/vips/requests.go +++ /dev/null @@ -1,256 +0,0 @@ -package vips - -import ( - "fmt" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// AdminState gives users a solid type to work with for create and update -// operations. It is recommended that users use the `Up` and `Down` enums. -type AdminState *bool - -// Convenience vars for AdminStateUp values. -var ( - iTrue = true - iFalse = false - - Up AdminState = &iTrue - Down AdminState = &iFalse -) - -// ListOpts allows the filtering and sorting of paginated collections through -// the API. Filtering is achieved by passing in struct field values that map to -// the floating IP attributes you want to see returned. SortKey allows you to -// sort by a particular network attribute. SortDir sets the direction, and is -// either `asc' or `desc'. Marker and Limit are used for pagination. -type ListOpts struct { - ID string `q:"id"` - Name string `q:"name"` - AdminStateUp *bool `q:"admin_state_up"` - Status string `q:"status"` - TenantID string `q:"tenant_id"` - SubnetID string `q:"subnet_id"` - Address string `q:"address"` - PortID string `q:"port_id"` - Protocol string `q:"protocol"` - ProtocolPort int `q:"protocol_port"` - ConnectionLimit int `q:"connection_limit"` - Limit int `q:"limit"` - Marker string `q:"marker"` - SortKey string `q:"sort_key"` - SortDir string `q:"sort_dir"` -} - -// List returns a Pager which allows you to iterate over a collection of -// routers. It accepts a ListOpts struct, which allows you to filter and sort -// the returned collection for greater efficiency. -// -// Default policy settings return only those routers that are owned by the -// tenant who submits the request, unless an admin user submits the request. -func List(c *gophercloud.ServiceClient, opts ListOpts) pagination.Pager { - q, err := gophercloud.BuildQueryString(&opts) - if err != nil { - return pagination.Pager{Err: err} - } - u := rootURL(c) + q.String() - return pagination.NewPager(c, u, func(r pagination.PageResult) pagination.Page { - return VIPPage{pagination.LinkedPageBase{PageResult: r}} - }) -} - -var ( - errNameRequired = fmt.Errorf("Name is required") - errSubnetIDRequried = fmt.Errorf("SubnetID is required") - errProtocolRequired = fmt.Errorf("Protocol is required") - errProtocolPortRequired = fmt.Errorf("Protocol port is required") - errPoolIDRequired = fmt.Errorf("PoolID is required") -) - -// CreateOpts contains all the values needed to create a new virtual IP. -type CreateOpts struct { - // Required. Human-readable name for the VIP. Does not have to be unique. - Name string - - // Required. The network on which to allocate the VIP's address. A tenant can - // only create VIPs on networks authorized by policy (e.g. networks that - // belong to them or networks that are shared). - SubnetID string - - // Required. The protocol - can either be TCP, HTTP or HTTPS. - Protocol string - - // Required. The port on which to listen for client traffic. - ProtocolPort int - - // Required. The ID of the pool with which the VIP is associated. - PoolID string - - // Required for admins. Indicates the owner of the VIP. - TenantID string - - // Optional. The IP address of the VIP. - Address string - - // Optional. Human-readable description for the VIP. - Description string - - // Optional. Omit this field to prevent session persistence. - Persistence *SessionPersistence - - // Optional. The maximum number of connections allowed for the VIP. - ConnLimit *int - - // Optional. The administrative state of the VIP. A valid value is true (UP) - // or false (DOWN). - AdminStateUp *bool -} - -// Create is an operation which provisions a new virtual IP based on the -// configuration defined in the CreateOpts struct. Once the request is -// validated and progress has started on the provisioning process, a -// CreateResult will be returned. -// -// Please note that the PoolID should refer to a pool that is not already -// associated with another vip. If the pool is already used by another vip, -// then the operation will fail with a 409 Conflict error will be returned. -// -// Users with an admin role can create VIPs on behalf of other tenants by -// specifying a TenantID attribute different than their own. -func Create(c *gophercloud.ServiceClient, opts CreateOpts) CreateResult { - var res CreateResult - - // Validate required opts - if opts.Name == "" { - res.Err = errNameRequired - return res - } - if opts.SubnetID == "" { - res.Err = errSubnetIDRequried - return res - } - if opts.Protocol == "" { - res.Err = errProtocolRequired - return res - } - if opts.ProtocolPort == 0 { - res.Err = errProtocolPortRequired - return res - } - if opts.PoolID == "" { - res.Err = errPoolIDRequired - return res - } - - type vip struct { - Name string `json:"name"` - SubnetID string `json:"subnet_id"` - Protocol string `json:"protocol"` - ProtocolPort int `json:"protocol_port"` - PoolID string `json:"pool_id"` - Description *string `json:"description,omitempty"` - TenantID *string `json:"tenant_id,omitempty"` - Address *string `json:"address,omitempty"` - Persistence *SessionPersistence `json:"session_persistence,omitempty"` - ConnLimit *int `json:"connection_limit,omitempty"` - AdminStateUp *bool `json:"admin_state_up,omitempty"` - } - - type request struct { - VirtualIP vip `json:"vip"` - } - - reqBody := request{VirtualIP: vip{ - Name: opts.Name, - SubnetID: opts.SubnetID, - Protocol: opts.Protocol, - ProtocolPort: opts.ProtocolPort, - PoolID: opts.PoolID, - Description: gophercloud.MaybeString(opts.Description), - TenantID: gophercloud.MaybeString(opts.TenantID), - Address: gophercloud.MaybeString(opts.Address), - ConnLimit: opts.ConnLimit, - AdminStateUp: opts.AdminStateUp, - }} - - if opts.Persistence != nil { - reqBody.VirtualIP.Persistence = opts.Persistence - } - - _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil) - return res -} - -// Get retrieves a particular virtual IP based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) GetResult { - var res GetResult - _, res.Err = c.Get(resourceURL(c, id), &res.Body, nil) - return res -} - -// UpdateOpts contains all the values needed to update an existing virtual IP. -// Attributes not listed here but appear in CreateOpts are immutable and cannot -// be updated. -type UpdateOpts struct { - // Human-readable name for the VIP. Does not have to be unique. - Name string - - // Required. The ID of the pool with which the VIP is associated. - PoolID string - - // Optional. Human-readable description for the VIP. - Description string - - // Optional. Omit this field to prevent session persistence. - Persistence *SessionPersistence - - // Optional. The maximum number of connections allowed for the VIP. - ConnLimit *int - - // Optional. The administrative state of the VIP. A valid value is true (UP) - // or false (DOWN). - AdminStateUp *bool -} - -// Update is an operation which modifies the attributes of the specified VIP. -func Update(c *gophercloud.ServiceClient, id string, opts UpdateOpts) UpdateResult { - type vip struct { - Name string `json:"name,omitempty"` - PoolID string `json:"pool_id,omitempty"` - Description *string `json:"description,omitempty"` - Persistence *SessionPersistence `json:"session_persistence,omitempty"` - ConnLimit *int `json:"connection_limit,omitempty"` - AdminStateUp *bool `json:"admin_state_up,omitempty"` - } - - type request struct { - VirtualIP vip `json:"vip"` - } - - reqBody := request{VirtualIP: vip{ - Name: opts.Name, - PoolID: opts.PoolID, - Description: gophercloud.MaybeString(opts.Description), - ConnLimit: opts.ConnLimit, - AdminStateUp: opts.AdminStateUp, - }} - - if opts.Persistence != nil { - reqBody.VirtualIP.Persistence = opts.Persistence - } - - var res UpdateResult - _, res.Err = c.Put(resourceURL(c, id), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200, 202}, - }) - - return res -} - -// Delete will permanently delete a particular virtual IP based on its unique ID. -func Delete(c *gophercloud.ServiceClient, id string) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(resourceURL(c, id), nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/vips/results.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/vips/results.go deleted file mode 100644 index e1092e780e..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/vips/results.go +++ /dev/null @@ -1,166 +0,0 @@ -package vips - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// SessionPersistence represents the session persistence feature of the load -// balancing service. It attempts to force connections or requests in the same -// session to be processed by the same member as long as it is ative. Three -// types of persistence are supported: -// -// SOURCE_IP: With this mode, all connections originating from the same source -// IP address, will be handled by the same member of the pool. -// HTTP_COOKIE: With this persistence mode, the load balancing function will -// create a cookie on the first request from a client. Subsequent -// requests containing the same cookie value will be handled by -// the same member of the pool. -// APP_COOKIE: With this persistence mode, the load balancing function will -// rely on a cookie established by the backend application. All -// requests carrying the same cookie value will be handled by the -// same member of the pool. -type SessionPersistence struct { - // The type of persistence mode - Type string `mapstructure:"type" json:"type"` - - // Name of cookie if persistence mode is set appropriately - CookieName string `mapstructure:"cookie_name" json:"cookie_name,omitempty"` -} - -// VirtualIP is the primary load balancing configuration object that specifies -// the virtual IP address and port on which client traffic is received, as well -// as other details such as the load balancing method to be use, protocol, etc. -// This entity is sometimes known in LB products under the name of a "virtual -// server", a "vserver" or a "listener". -type VirtualIP struct { - // The unique ID for the VIP. - ID string `mapstructure:"id" json:"id"` - - // Owner of the VIP. Only an admin user can specify a tenant ID other than its own. - TenantID string `mapstructure:"tenant_id" json:"tenant_id"` - - // Human-readable name for the VIP. Does not have to be unique. - Name string `mapstructure:"name" json:"name"` - - // Human-readable description for the VIP. - Description string `mapstructure:"description" json:"description"` - - // The ID of the subnet on which to allocate the VIP address. - SubnetID string `mapstructure:"subnet_id" json:"subnet_id"` - - // The IP address of the VIP. - Address string `mapstructure:"address" json:"address"` - - // The protocol of the VIP address. A valid value is TCP, HTTP, or HTTPS. - Protocol string `mapstructure:"protocol" json:"protocol"` - - // The port on which to listen to client traffic that is associated with the - // VIP address. A valid value is from 0 to 65535. - ProtocolPort int `mapstructure:"protocol_port" json:"protocol_port"` - - // The ID of the pool with which the VIP is associated. - PoolID string `mapstructure:"pool_id" json:"pool_id"` - - // The ID of the port which belongs to the load balancer - PortID string `mapstructure:"port_id" json:"port_id"` - - // Indicates whether connections in the same session will be processed by the - // same pool member or not. - Persistence SessionPersistence `mapstructure:"session_persistence" json:"session_persistence"` - - // The maximum number of connections allowed for the VIP. Default is -1, - // meaning no limit. - ConnLimit int `mapstructure:"connection_limit" json:"connection_limit"` - - // The administrative state of the VIP. A valid value is true (UP) or false (DOWN). - AdminStateUp bool `mapstructure:"admin_state_up" json:"admin_state_up"` - - // The status of the VIP. Indicates whether the VIP is operational. - Status string `mapstructure:"status" json:"status"` -} - -// VIPPage is the page returned by a pager when traversing over a -// collection of routers. -type VIPPage struct { - pagination.LinkedPageBase -} - -// NextPageURL is invoked when a paginated collection of routers has reached -// the end of a page and the pager seeks to traverse over a new one. In order -// to do this, it needs to construct the next page's URL. -func (p VIPPage) NextPageURL() (string, error) { - type resp struct { - Links []gophercloud.Link `mapstructure:"vips_links"` - } - - var r resp - err := mapstructure.Decode(p.Body, &r) - if err != nil { - return "", err - } - - return gophercloud.ExtractNextURL(r.Links) -} - -// IsEmpty checks whether a RouterPage struct is empty. -func (p VIPPage) IsEmpty() (bool, error) { - is, err := ExtractVIPs(p) - if err != nil { - return true, nil - } - return len(is) == 0, nil -} - -// ExtractVIPs accepts a Page struct, specifically a VIPPage struct, -// and extracts the elements into a slice of VirtualIP structs. In other words, -// a generic collection is mapped into a relevant slice. -func ExtractVIPs(page pagination.Page) ([]VirtualIP, error) { - var resp struct { - VIPs []VirtualIP `mapstructure:"vips" json:"vips"` - } - - err := mapstructure.Decode(page.(VIPPage).Body, &resp) - - return resp.VIPs, err -} - -type commonResult struct { - gophercloud.Result -} - -// Extract is a function that accepts a result and extracts a router. -func (r commonResult) Extract() (*VirtualIP, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - VirtualIP *VirtualIP `mapstructure:"vip" json:"vip"` - } - - err := mapstructure.Decode(r.Body, &res) - - return res.VirtualIP, err -} - -// CreateResult represents the result of a create operation. -type CreateResult struct { - commonResult -} - -// GetResult represents the result of a get operation. -type GetResult struct { - commonResult -} - -// UpdateResult represents the result of an update operation. -type UpdateResult struct { - commonResult -} - -// DeleteResult represents the result of a delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/vips/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/vips/urls.go deleted file mode 100644 index 2b6f67e71d..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/vips/urls.go +++ /dev/null @@ -1,16 +0,0 @@ -package vips - -import "github.com/rackspace/gophercloud" - -const ( - rootPath = "lb" - resourcePath = "vips" -) - -func rootURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(rootPath, resourcePath) -} - -func resourceURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(rootPath, resourcePath, id) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/provider/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/provider/doc.go deleted file mode 100644 index 373da44f84..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/provider/doc.go +++ /dev/null @@ -1,21 +0,0 @@ -// Package provider gives access to the provider Neutron plugin, allowing -// network extended attributes. The provider extended attributes for networks -// enable administrative users to specify how network objects map to the -// underlying networking infrastructure. These extended attributes also appear -// when administrative users query networks. -// -// For more information about extended attributes, see the NetworkExtAttrs -// struct. The actual semantics of these attributes depend on the technology -// back end of the particular plug-in. See the plug-in documentation and the -// OpenStack Cloud Administrator Guide to understand which values should be -// specific for each of these attributes when OpenStack Networking is deployed -// with a particular plug-in. The examples shown in this chapter refer to the -// Open vSwitch plug-in. -// -// The default policy settings enable only users with administrative rights to -// specify these parameters in requests and to see their values in responses. By -// default, the provider network extension attributes are completely hidden from -// regular tenants. As a rule of thumb, if these attributes are not visible in a -// GET /networks/ operation, this implies the user submitting the -// request is not authorized to view or manipulate provider network attributes. -package provider diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/provider/results.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/provider/results.go deleted file mode 100644 index f07d6285db..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/provider/results.go +++ /dev/null @@ -1,124 +0,0 @@ -package provider - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud/openstack/networking/v2/networks" - "github.com/rackspace/gophercloud/pagination" -) - -// AdminState gives users a solid type to work with for create and update -// operations. It is recommended that users use the `Up` and `Down` enums. -type AdminState *bool - -// Convenience vars for AdminStateUp values. -var ( - iTrue = true - iFalse = false - - Up AdminState = &iTrue - Down AdminState = &iFalse -) - -// NetworkExtAttrs represents an extended form of a Network with additional fields. -type NetworkExtAttrs struct { - // UUID for the network - ID string `mapstructure:"id" json:"id"` - - // Human-readable name for the network. Might not be unique. - Name string `mapstructure:"name" json:"name"` - - // The administrative state of network. If false (down), the network does not forward packets. - AdminStateUp bool `mapstructure:"admin_state_up" json:"admin_state_up"` - - // Indicates whether network is currently operational. Possible values include - // `ACTIVE', `DOWN', `BUILD', or `ERROR'. Plug-ins might define additional values. - Status string `mapstructure:"status" json:"status"` - - // Subnets associated with this network. - Subnets []string `mapstructure:"subnets" json:"subnets"` - - // Owner of network. Only admin users can specify a tenant_id other than its own. - TenantID string `mapstructure:"tenant_id" json:"tenant_id"` - - // Specifies whether the network resource can be accessed by any tenant or not. - Shared bool `mapstructure:"shared" json:"shared"` - - // Specifies the nature of the physical network mapped to this network - // resource. Examples are flat, vlan, or gre. - NetworkType string `json:"provider:network_type" mapstructure:"provider:network_type"` - - // Identifies the physical network on top of which this network object is - // being implemented. The OpenStack Networking API does not expose any facility - // for retrieving the list of available physical networks. As an example, in - // the Open vSwitch plug-in this is a symbolic name which is then mapped to - // specific bridges on each compute host through the Open vSwitch plug-in - // configuration file. - PhysicalNetwork string `json:"provider:physical_network" mapstructure:"provider:physical_network"` - - // Identifies an isolated segment on the physical network; the nature of the - // segment depends on the segmentation model defined by network_type. For - // instance, if network_type is vlan, then this is a vlan identifier; - // otherwise, if network_type is gre, then this will be a gre key. - SegmentationID string `json:"provider:segmentation_id" mapstructure:"provider:segmentation_id"` -} - -// ExtractGet decorates a GetResult struct returned from a networks.Get() -// function with extended attributes. -func ExtractGet(r networks.GetResult) (*NetworkExtAttrs, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Network *NetworkExtAttrs `json:"network"` - } - - err := mapstructure.WeakDecode(r.Body, &res) - - return res.Network, err -} - -// ExtractCreate decorates a CreateResult struct returned from a networks.Create() -// function with extended attributes. -func ExtractCreate(r networks.CreateResult) (*NetworkExtAttrs, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Network *NetworkExtAttrs `json:"network"` - } - - err := mapstructure.WeakDecode(r.Body, &res) - - return res.Network, err -} - -// ExtractUpdate decorates a UpdateResult struct returned from a -// networks.Update() function with extended attributes. -func ExtractUpdate(r networks.UpdateResult) (*NetworkExtAttrs, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Network *NetworkExtAttrs `json:"network"` - } - - err := mapstructure.WeakDecode(r.Body, &res) - - return res.Network, err -} - -// ExtractList accepts a Page struct, specifically a NetworkPage struct, and -// extracts the elements into a slice of NetworkExtAttrs structs. In other -// words, a generic collection is mapped into a relevant slice. -func ExtractList(page pagination.Page) ([]NetworkExtAttrs, error) { - var resp struct { - Networks []NetworkExtAttrs `mapstructure:"networks" json:"networks"` - } - - err := mapstructure.WeakDecode(page.(networks.NetworkPage).Body, &resp) - - return resp.Networks, err -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/doc.go deleted file mode 100644 index 31f744ccd7..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/doc.go +++ /dev/null @@ -1,32 +0,0 @@ -// Package security contains functionality to work with security group and -// security group rules Neutron resources. -// -// Security groups and security group rules allows administrators and tenants -// the ability to specify the type of traffic and direction (ingress/egress) -// that is allowed to pass through a port. A security group is a container for -// security group rules. -// -// When a port is created in Networking it is associated with a security group. -// If a security group is not specified the port is associated with a 'default' -// security group. By default, this group drops all ingress traffic and allows -// all egress. Rules can be added to this group in order to change the behaviour. -// -// The basic characteristics of Neutron Security Groups are: -// -// For ingress traffic (to an instance) -// - Only traffic matched with security group rules are allowed. -// - When there is no rule defined, all traffic is dropped. -// -// For egress traffic (from an instance) -// - Only traffic matched with security group rules are allowed. -// - When there is no rule defined, all egress traffic are dropped. -// - When a new security group is created, rules to allow all egress traffic -// is automatically added. -// -// "default security group" is defined for each tenant. -// - For the default security group a rule which allows intercommunication -// among hosts associated with the default security group is defined by default. -// - As a result, all egress traffic and intercommunication in the default -// group are allowed and all ingress from outside of the default group is -// dropped by default (in the default security group). -package security diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/groups/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/groups/requests.go deleted file mode 100644 index 55e4b3b804..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/groups/requests.go +++ /dev/null @@ -1,93 +0,0 @@ -package groups - -import ( - "fmt" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// ListOpts allows the filtering and sorting of paginated collections through -// the API. Filtering is achieved by passing in struct field values that map to -// the floating IP attributes you want to see returned. SortKey allows you to -// sort by a particular network attribute. SortDir sets the direction, and is -// either `asc' or `desc'. Marker and Limit are used for pagination. -type ListOpts struct { - ID string `q:"id"` - Name string `q:"name"` - TenantID string `q:"tenant_id"` - Limit int `q:"limit"` - Marker string `q:"marker"` - SortKey string `q:"sort_key"` - SortDir string `q:"sort_dir"` -} - -// List returns a Pager which allows you to iterate over a collection of -// security groups. It accepts a ListOpts struct, which allows you to filter -// and sort the returned collection for greater efficiency. -func List(c *gophercloud.ServiceClient, opts ListOpts) pagination.Pager { - q, err := gophercloud.BuildQueryString(&opts) - if err != nil { - return pagination.Pager{Err: err} - } - u := rootURL(c) + q.String() - return pagination.NewPager(c, u, func(r pagination.PageResult) pagination.Page { - return SecGroupPage{pagination.LinkedPageBase{PageResult: r}} - }) -} - -var ( - errNameRequired = fmt.Errorf("Name is required") -) - -// CreateOpts contains all the values needed to create a new security group. -type CreateOpts struct { - // Required. Human-readable name for the VIP. Does not have to be unique. - Name string - - // Optional. Describes the security group. - Description string -} - -// Create is an operation which provisions a new security group with default -// security group rules for the IPv4 and IPv6 ether types. -func Create(c *gophercloud.ServiceClient, opts CreateOpts) CreateResult { - var res CreateResult - - // Validate required opts - if opts.Name == "" { - res.Err = errNameRequired - return res - } - - type secgroup struct { - Name string `json:"name"` - Description string `json:"description,omitempty"` - } - - type request struct { - SecGroup secgroup `json:"security_group"` - } - - reqBody := request{SecGroup: secgroup{ - Name: opts.Name, - Description: opts.Description, - }} - - _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil) - return res -} - -// Get retrieves a particular security group based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) GetResult { - var res GetResult - _, res.Err = c.Get(resourceURL(c, id), &res.Body, nil) - return res -} - -// Delete will permanently delete a particular security group based on its unique ID. -func Delete(c *gophercloud.ServiceClient, id string) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(resourceURL(c, id), nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/groups/results.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/groups/results.go deleted file mode 100644 index 49db261c22..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/groups/results.go +++ /dev/null @@ -1,108 +0,0 @@ -package groups - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/rules" - "github.com/rackspace/gophercloud/pagination" -) - -// SecGroup represents a container for security group rules. -type SecGroup struct { - // The UUID for the security group. - ID string - - // Human-readable name for the security group. Might not be unique. Cannot be - // named "default" as that is automatically created for a tenant. - Name string - - // The security group description. - Description string - - // A slice of security group rules that dictate the permitted behaviour for - // traffic entering and leaving the group. - Rules []rules.SecGroupRule `json:"security_group_rules" mapstructure:"security_group_rules"` - - // Owner of the security group. Only admin users can specify a TenantID - // other than their own. - TenantID string `json:"tenant_id" mapstructure:"tenant_id"` -} - -// SecGroupPage is the page returned by a pager when traversing over a -// collection of security groups. -type SecGroupPage struct { - pagination.LinkedPageBase -} - -// NextPageURL is invoked when a paginated collection of security groups has -// reached the end of a page and the pager seeks to traverse over a new one. In -// order to do this, it needs to construct the next page's URL. -func (p SecGroupPage) NextPageURL() (string, error) { - type resp struct { - Links []gophercloud.Link `mapstructure:"security_groups_links"` - } - - var r resp - err := mapstructure.Decode(p.Body, &r) - if err != nil { - return "", err - } - - return gophercloud.ExtractNextURL(r.Links) -} - -// IsEmpty checks whether a SecGroupPage struct is empty. -func (p SecGroupPage) IsEmpty() (bool, error) { - is, err := ExtractGroups(p) - if err != nil { - return true, nil - } - return len(is) == 0, nil -} - -// ExtractGroups accepts a Page struct, specifically a SecGroupPage struct, -// and extracts the elements into a slice of SecGroup structs. In other words, -// a generic collection is mapped into a relevant slice. -func ExtractGroups(page pagination.Page) ([]SecGroup, error) { - var resp struct { - SecGroups []SecGroup `mapstructure:"security_groups" json:"security_groups"` - } - - err := mapstructure.Decode(page.(SecGroupPage).Body, &resp) - - return resp.SecGroups, err -} - -type commonResult struct { - gophercloud.Result -} - -// Extract is a function that accepts a result and extracts a security group. -func (r commonResult) Extract() (*SecGroup, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - SecGroup *SecGroup `mapstructure:"security_group" json:"security_group"` - } - - err := mapstructure.Decode(r.Body, &res) - - return res.SecGroup, err -} - -// CreateResult represents the result of a create operation. -type CreateResult struct { - commonResult -} - -// GetResult represents the result of a get operation. -type GetResult struct { - commonResult -} - -// DeleteResult represents the result of a delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/groups/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/groups/urls.go deleted file mode 100644 index 84f7324f09..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/groups/urls.go +++ /dev/null @@ -1,13 +0,0 @@ -package groups - -import "github.com/rackspace/gophercloud" - -const rootPath = "security-groups" - -func rootURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(rootPath) -} - -func resourceURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(rootPath, id) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/rules/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/rules/requests.go deleted file mode 100644 index 0b2d10b0ef..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/rules/requests.go +++ /dev/null @@ -1,169 +0,0 @@ -package rules - -import ( - "fmt" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// ListOpts allows the filtering and sorting of paginated collections through -// the API. Filtering is achieved by passing in struct field values that map to -// the security group attributes you want to see returned. SortKey allows you to -// sort by a particular network attribute. SortDir sets the direction, and is -// either `asc' or `desc'. Marker and Limit are used for pagination. -type ListOpts struct { - Direction string `q:"direction"` - EtherType string `q:"ethertype"` - ID string `q:"id"` - PortRangeMax int `q:"port_range_max"` - PortRangeMin int `q:"port_range_min"` - Protocol string `q:"protocol"` - RemoteGroupID string `q:"remote_group_id"` - RemoteIPPrefix string `q:"remote_ip_prefix"` - SecGroupID string `q:"security_group_id"` - TenantID string `q:"tenant_id"` - Limit int `q:"limit"` - Marker string `q:"marker"` - SortKey string `q:"sort_key"` - SortDir string `q:"sort_dir"` -} - -// List returns a Pager which allows you to iterate over a collection of -// security group rules. It accepts a ListOpts struct, which allows you to filter -// and sort the returned collection for greater efficiency. -func List(c *gophercloud.ServiceClient, opts ListOpts) pagination.Pager { - q, err := gophercloud.BuildQueryString(&opts) - if err != nil { - return pagination.Pager{Err: err} - } - u := rootURL(c) + q.String() - return pagination.NewPager(c, u, func(r pagination.PageResult) pagination.Page { - return SecGroupRulePage{pagination.LinkedPageBase{PageResult: r}} - }) -} - -// Errors -var ( - errValidDirectionRequired = fmt.Errorf("A valid Direction is required") - errValidEtherTypeRequired = fmt.Errorf("A valid EtherType is required") - errSecGroupIDRequired = fmt.Errorf("A valid SecGroupID is required") - errValidProtocolRequired = fmt.Errorf("A valid Protocol is required") -) - -// Constants useful for CreateOpts -const ( - DirIngress = "ingress" - DirEgress = "egress" - Ether4 = "IPv4" - Ether6 = "IPv6" - ProtocolTCP = "tcp" - ProtocolUDP = "udp" - ProtocolICMP = "icmp" -) - -// CreateOpts contains all the values needed to create a new security group rule. -type CreateOpts struct { - // Required. Must be either "ingress" or "egress": the direction in which the - // security group rule is applied. - Direction string - - // Required. Must be "IPv4" or "IPv6", and addresses represented in CIDR must - // match the ingress or egress rules. - EtherType string - - // Required. The security group ID to associate with this security group rule. - SecGroupID string - - // Optional. The maximum port number in the range that is matched by the - // security group rule. The PortRangeMin attribute constrains the PortRangeMax - // attribute. If the protocol is ICMP, this value must be an ICMP type. - PortRangeMax int - - // Optional. The minimum port number in the range that is matched by the - // security group rule. If the protocol is TCP or UDP, this value must be - // less than or equal to the value of the PortRangeMax attribute. If the - // protocol is ICMP, this value must be an ICMP type. - PortRangeMin int - - // Optional. The protocol that is matched by the security group rule. Valid - // values are "tcp", "udp", "icmp" or an empty string. - Protocol string - - // Optional. The remote group ID to be associated with this security group - // rule. You can specify either RemoteGroupID or RemoteIPPrefix. - RemoteGroupID string - - // Optional. The remote IP prefix to be associated with this security group - // rule. You can specify either RemoteGroupID or RemoteIPPrefix. This - // attribute matches the specified IP prefix as the source IP address of the - // IP packet. - RemoteIPPrefix string -} - -// Create is an operation which provisions a new security group with default -// security group rules for the IPv4 and IPv6 ether types. -func Create(c *gophercloud.ServiceClient, opts CreateOpts) CreateResult { - var res CreateResult - - // Validate required opts - if opts.Direction != DirIngress && opts.Direction != DirEgress { - res.Err = errValidDirectionRequired - return res - } - if opts.EtherType != Ether4 && opts.EtherType != Ether6 { - res.Err = errValidEtherTypeRequired - return res - } - if opts.SecGroupID == "" { - res.Err = errSecGroupIDRequired - return res - } - if opts.Protocol != "" && opts.Protocol != ProtocolTCP && opts.Protocol != ProtocolUDP && opts.Protocol != ProtocolICMP { - res.Err = errValidProtocolRequired - return res - } - - type secrule struct { - Direction string `json:"direction"` - EtherType string `json:"ethertype"` - SecGroupID string `json:"security_group_id"` - PortRangeMax int `json:"port_range_max,omitempty"` - PortRangeMin int `json:"port_range_min,omitempty"` - Protocol string `json:"protocol,omitempty"` - RemoteGroupID string `json:"remote_group_id,omitempty"` - RemoteIPPrefix string `json:"remote_ip_prefix,omitempty"` - } - - type request struct { - SecRule secrule `json:"security_group_rule"` - } - - reqBody := request{SecRule: secrule{ - Direction: opts.Direction, - EtherType: opts.EtherType, - SecGroupID: opts.SecGroupID, - PortRangeMax: opts.PortRangeMax, - PortRangeMin: opts.PortRangeMin, - Protocol: opts.Protocol, - RemoteGroupID: opts.RemoteGroupID, - RemoteIPPrefix: opts.RemoteIPPrefix, - }} - - _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil) - return res -} - -// Get retrieves a particular security group based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) GetResult { - var res GetResult - _, res.Err = c.Get(resourceURL(c, id), &res.Body, nil) - return res -} - -// Delete will permanently delete a particular security group based on its unique ID. -func Delete(c *gophercloud.ServiceClient, id string) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(resourceURL(c, id), nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/rules/results.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/rules/results.go deleted file mode 100644 index 6e13857689..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/rules/results.go +++ /dev/null @@ -1,133 +0,0 @@ -package rules - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// SecGroupRule represents a rule to dictate the behaviour of incoming or -// outgoing traffic for a particular security group. -type SecGroupRule struct { - // The UUID for this security group rule. - ID string - - // The direction in which the security group rule is applied. The only values - // allowed are "ingress" or "egress". For a compute instance, an ingress - // security group rule is applied to incoming (ingress) traffic for that - // instance. An egress rule is applied to traffic leaving the instance. - Direction string - - // Must be IPv4 or IPv6, and addresses represented in CIDR must match the - // ingress or egress rules. - EtherType string `json:"ethertype" mapstructure:"ethertype"` - - // The security group ID to associate with this security group rule. - SecGroupID string `json:"security_group_id" mapstructure:"security_group_id"` - - // The minimum port number in the range that is matched by the security group - // rule. If the protocol is TCP or UDP, this value must be less than or equal - // to the value of the PortRangeMax attribute. If the protocol is ICMP, this - // value must be an ICMP type. - PortRangeMin int `json:"port_range_min" mapstructure:"port_range_min"` - - // The maximum port number in the range that is matched by the security group - // rule. The PortRangeMin attribute constrains the PortRangeMax attribute. If - // the protocol is ICMP, this value must be an ICMP type. - PortRangeMax int `json:"port_range_max" mapstructure:"port_range_max"` - - // The protocol that is matched by the security group rule. Valid values are - // "tcp", "udp", "icmp" or an empty string. - Protocol string - - // The remote group ID to be associated with this security group rule. You - // can specify either RemoteGroupID or RemoteIPPrefix. - RemoteGroupID string `json:"remote_group_id" mapstructure:"remote_group_id"` - - // The remote IP prefix to be associated with this security group rule. You - // can specify either RemoteGroupID or RemoteIPPrefix . This attribute - // matches the specified IP prefix as the source IP address of the IP packet. - RemoteIPPrefix string `json:"remote_ip_prefix" mapstructure:"remote_ip_prefix"` - - // The owner of this security group rule. - TenantID string `json:"tenant_id" mapstructure:"tenant_id"` -} - -// SecGroupRulePage is the page returned by a pager when traversing over a -// collection of security group rules. -type SecGroupRulePage struct { - pagination.LinkedPageBase -} - -// NextPageURL is invoked when a paginated collection of security group rules has -// reached the end of a page and the pager seeks to traverse over a new one. In -// order to do this, it needs to construct the next page's URL. -func (p SecGroupRulePage) NextPageURL() (string, error) { - type resp struct { - Links []gophercloud.Link `mapstructure:"security_group_rules_links"` - } - - var r resp - err := mapstructure.Decode(p.Body, &r) - if err != nil { - return "", err - } - - return gophercloud.ExtractNextURL(r.Links) -} - -// IsEmpty checks whether a SecGroupRulePage struct is empty. -func (p SecGroupRulePage) IsEmpty() (bool, error) { - is, err := ExtractRules(p) - if err != nil { - return true, nil - } - return len(is) == 0, nil -} - -// ExtractRules accepts a Page struct, specifically a SecGroupRulePage struct, -// and extracts the elements into a slice of SecGroupRule structs. In other words, -// a generic collection is mapped into a relevant slice. -func ExtractRules(page pagination.Page) ([]SecGroupRule, error) { - var resp struct { - SecGroupRules []SecGroupRule `mapstructure:"security_group_rules" json:"security_group_rules"` - } - - err := mapstructure.Decode(page.(SecGroupRulePage).Body, &resp) - - return resp.SecGroupRules, err -} - -type commonResult struct { - gophercloud.Result -} - -// Extract is a function that accepts a result and extracts a security rule. -func (r commonResult) Extract() (*SecGroupRule, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - SecGroupRule *SecGroupRule `mapstructure:"security_group_rule" json:"security_group_rule"` - } - - err := mapstructure.Decode(r.Body, &res) - - return res.SecGroupRule, err -} - -// CreateResult represents the result of a create operation. -type CreateResult struct { - commonResult -} - -// GetResult represents the result of a get operation. -type GetResult struct { - commonResult -} - -// DeleteResult represents the result of a delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/rules/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/rules/urls.go deleted file mode 100644 index 8e2b2bb28d..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/rules/urls.go +++ /dev/null @@ -1,13 +0,0 @@ -package rules - -import "github.com/rackspace/gophercloud" - -const rootPath = "security-group-rules" - -func rootURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(rootPath) -} - -func resourceURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(rootPath, id) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/doc.go deleted file mode 100644 index 43e8296c7f..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/doc.go +++ /dev/null @@ -1,10 +0,0 @@ -// Package subnets contains functionality for working with Neutron subnet -// resources. A subnet represents an IP address block that can be used to -// assign IP addresses to virtual instances. Each subnet must have a CIDR and -// must be associated with a network. IPs can either be selected from the whole -// subnet CIDR or from allocation pools specified by the user. -// -// A subnet can also have a gateway, a list of DNS name servers, and host routes. -// This information is pushed to instances whose interfaces are associated with -// the subnet. -package subnets diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/errors.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/errors.go deleted file mode 100644 index 0db0a6e604..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/errors.go +++ /dev/null @@ -1,13 +0,0 @@ -package subnets - -import "fmt" - -func err(str string) error { - return fmt.Errorf("%s", str) -} - -var ( - errNetworkIDRequired = err("A network ID is required") - errCIDRRequired = err("A valid CIDR is required") - errInvalidIPType = err("An IP type must either be 4 or 6") -) diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/requests.go deleted file mode 100644 index 6e01f059d7..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/requests.go +++ /dev/null @@ -1,236 +0,0 @@ -package subnets - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// AdminState gives users a solid type to work with for create and update -// operations. It is recommended that users use the `Up` and `Down` enums. -type AdminState *bool - -// Convenience vars for AdminStateUp values. -var ( - iTrue = true - iFalse = false - - Up AdminState = &iTrue - Down AdminState = &iFalse -) - -// ListOptsBuilder allows extensions to add additional parameters to the -// List request. -type ListOptsBuilder interface { - ToSubnetListQuery() (string, error) -} - -// ListOpts allows the filtering and sorting of paginated collections through -// the API. Filtering is achieved by passing in struct field values that map to -// the subnet attributes you want to see returned. SortKey allows you to sort -// by a particular subnet attribute. SortDir sets the direction, and is either -// `asc' or `desc'. Marker and Limit are used for pagination. -type ListOpts struct { - Name string `q:"name"` - EnableDHCP *bool `q:"enable_dhcp"` - NetworkID string `q:"network_id"` - TenantID string `q:"tenant_id"` - IPVersion int `q:"ip_version"` - GatewayIP string `q:"gateway_ip"` - CIDR string `q:"cidr"` - ID string `q:"id"` - Limit int `q:"limit"` - Marker string `q:"marker"` - SortKey string `q:"sort_key"` - SortDir string `q:"sort_dir"` -} - -// ToSubnetListQuery formats a ListOpts into a query string. -func (opts ListOpts) ToSubnetListQuery() (string, error) { - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return "", err - } - return q.String(), nil -} - -// List returns a Pager which allows you to iterate over a collection of -// subnets. It accepts a ListOpts struct, which allows you to filter and sort -// the returned collection for greater efficiency. -// -// Default policy settings return only those subnets that are owned by the tenant -// who submits the request, unless the request is submitted by a user with -// administrative rights. -func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { - url := listURL(c) - if opts != nil { - query, err := opts.ToSubnetListQuery() - if err != nil { - return pagination.Pager{Err: err} - } - url += query - } - - return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page { - return SubnetPage{pagination.LinkedPageBase{PageResult: r}} - }) -} - -// Get retrieves a specific subnet based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) GetResult { - var res GetResult - _, res.Err = c.Get(getURL(c, id), &res.Body, nil) - return res -} - -// Valid IP types -const ( - IPv4 = 4 - IPv6 = 6 -) - -// CreateOptsBuilder is the interface options structs have to satisfy in order -// to be used in the main Create operation in this package. Since many -// extensions decorate or modify the common logic, it is useful for them to -// satisfy a basic interface in order for them to be used. -type CreateOptsBuilder interface { - ToSubnetCreateMap() (map[string]interface{}, error) -} - -// CreateOpts represents the attributes used when creating a new subnet. -type CreateOpts struct { - // Required - NetworkID string - CIDR string - // Optional - Name string - TenantID string - AllocationPools []AllocationPool - GatewayIP string - IPVersion int - EnableDHCP *bool - DNSNameservers []string - HostRoutes []HostRoute -} - -// ToSubnetCreateMap casts a CreateOpts struct to a map. -func (opts CreateOpts) ToSubnetCreateMap() (map[string]interface{}, error) { - s := make(map[string]interface{}) - - if opts.NetworkID == "" { - return nil, errNetworkIDRequired - } - if opts.CIDR == "" { - return nil, errCIDRRequired - } - if opts.IPVersion != 0 && opts.IPVersion != IPv4 && opts.IPVersion != IPv6 { - return nil, errInvalidIPType - } - - s["network_id"] = opts.NetworkID - s["cidr"] = opts.CIDR - - if opts.EnableDHCP != nil { - s["enable_dhcp"] = &opts.EnableDHCP - } - if opts.Name != "" { - s["name"] = opts.Name - } - if opts.GatewayIP != "" { - s["gateway_ip"] = opts.GatewayIP - } - if opts.TenantID != "" { - s["tenant_id"] = opts.TenantID - } - if opts.IPVersion != 0 { - s["ip_version"] = opts.IPVersion - } - if len(opts.AllocationPools) != 0 { - s["allocation_pools"] = opts.AllocationPools - } - if len(opts.DNSNameservers) != 0 { - s["dns_nameservers"] = opts.DNSNameservers - } - if len(opts.HostRoutes) != 0 { - s["host_routes"] = opts.HostRoutes - } - - return map[string]interface{}{"subnet": s}, nil -} - -// Create accepts a CreateOpts struct and creates a new subnet using the values -// provided. You must remember to provide a valid NetworkID, CIDR and IP version. -func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult { - var res CreateResult - - reqBody, err := opts.ToSubnetCreateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = c.Post(createURL(c), reqBody, &res.Body, nil) - return res -} - -// UpdateOptsBuilder allows extensions to add additional parameters to the -// Update request. -type UpdateOptsBuilder interface { - ToSubnetUpdateMap() (map[string]interface{}, error) -} - -// UpdateOpts represents the attributes used when updating an existing subnet. -type UpdateOpts struct { - Name string - GatewayIP string - DNSNameservers []string - HostRoutes []HostRoute - EnableDHCP *bool -} - -// ToSubnetUpdateMap casts an UpdateOpts struct to a map. -func (opts UpdateOpts) ToSubnetUpdateMap() (map[string]interface{}, error) { - s := make(map[string]interface{}) - - if opts.EnableDHCP != nil { - s["enable_dhcp"] = &opts.EnableDHCP - } - if opts.Name != "" { - s["name"] = opts.Name - } - if opts.GatewayIP != "" { - s["gateway_ip"] = opts.GatewayIP - } - if len(opts.DNSNameservers) != 0 { - s["dns_nameservers"] = opts.DNSNameservers - } - if len(opts.HostRoutes) != 0 { - s["host_routes"] = opts.HostRoutes - } - - return map[string]interface{}{"subnet": s}, nil -} - -// Update accepts a UpdateOpts struct and updates an existing subnet using the -// values provided. -func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) UpdateResult { - var res UpdateResult - - reqBody, err := opts.ToSubnetUpdateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = c.Put(updateURL(c, id), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200, 201}, - }) - - return res -} - -// Delete accepts a unique ID and deletes the subnet associated with it. -func Delete(c *gophercloud.ServiceClient, id string) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(deleteURL(c, id), nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/results.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/results.go deleted file mode 100644 index 1910f17dd9..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/results.go +++ /dev/null @@ -1,132 +0,0 @@ -package subnets - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -type commonResult struct { - gophercloud.Result -} - -// Extract is a function that accepts a result and extracts a subnet resource. -func (r commonResult) Extract() (*Subnet, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Subnet *Subnet `json:"subnet"` - } - - err := mapstructure.Decode(r.Body, &res) - - return res.Subnet, err -} - -// CreateResult represents the result of a create operation. -type CreateResult struct { - commonResult -} - -// GetResult represents the result of a get operation. -type GetResult struct { - commonResult -} - -// UpdateResult represents the result of an update operation. -type UpdateResult struct { - commonResult -} - -// DeleteResult represents the result of a delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} - -// AllocationPool represents a sub-range of cidr available for dynamic -// allocation to ports, e.g. {Start: "10.0.0.2", End: "10.0.0.254"} -type AllocationPool struct { - Start string `json:"start"` - End string `json:"end"` -} - -// HostRoute represents a route that should be used by devices with IPs from -// a subnet (not including local subnet route). -type HostRoute struct { - DestinationCIDR string `json:"destination"` - NextHop string `json:"nexthop"` -} - -// Subnet represents a subnet. See package documentation for a top-level -// description of what this is. -type Subnet struct { - // UUID representing the subnet - ID string `mapstructure:"id" json:"id"` - // UUID of the parent network - NetworkID string `mapstructure:"network_id" json:"network_id"` - // Human-readable name for the subnet. Might not be unique. - Name string `mapstructure:"name" json:"name"` - // IP version, either `4' or `6' - IPVersion int `mapstructure:"ip_version" json:"ip_version"` - // CIDR representing IP range for this subnet, based on IP version - CIDR string `mapstructure:"cidr" json:"cidr"` - // Default gateway used by devices in this subnet - GatewayIP string `mapstructure:"gateway_ip" json:"gateway_ip"` - // DNS name servers used by hosts in this subnet. - DNSNameservers []string `mapstructure:"dns_nameservers" json:"dns_nameservers"` - // Sub-ranges of CIDR available for dynamic allocation to ports. See AllocationPool. - AllocationPools []AllocationPool `mapstructure:"allocation_pools" json:"allocation_pools"` - // Routes that should be used by devices with IPs from this subnet (not including local subnet route). - HostRoutes []HostRoute `mapstructure:"host_routes" json:"host_routes"` - // Specifies whether DHCP is enabled for this subnet or not. - EnableDHCP bool `mapstructure:"enable_dhcp" json:"enable_dhcp"` - // Owner of network. Only admin users can specify a tenant_id other than its own. - TenantID string `mapstructure:"tenant_id" json:"tenant_id"` -} - -// SubnetPage is the page returned by a pager when traversing over a collection -// of subnets. -type SubnetPage struct { - pagination.LinkedPageBase -} - -// NextPageURL is invoked when a paginated collection of subnets has reached -// the end of a page and the pager seeks to traverse over a new one. In order -// to do this, it needs to construct the next page's URL. -func (p SubnetPage) NextPageURL() (string, error) { - type resp struct { - Links []gophercloud.Link `mapstructure:"subnets_links"` - } - - var r resp - err := mapstructure.Decode(p.Body, &r) - if err != nil { - return "", err - } - - return gophercloud.ExtractNextURL(r.Links) -} - -// IsEmpty checks whether a SubnetPage struct is empty. -func (p SubnetPage) IsEmpty() (bool, error) { - is, err := ExtractSubnets(p) - if err != nil { - return true, nil - } - return len(is) == 0, nil -} - -// ExtractSubnets accepts a Page struct, specifically a SubnetPage struct, -// and extracts the elements into a slice of Subnet structs. In other words, -// a generic collection is mapped into a relevant slice. -func ExtractSubnets(page pagination.Page) ([]Subnet, error) { - var resp struct { - Subnets []Subnet `mapstructure:"subnets" json:"subnets"` - } - - err := mapstructure.Decode(page.(SubnetPage).Body, &resp) - - return resp.Subnets, err -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/urls.go deleted file mode 100644 index 0d02368941..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/urls.go +++ /dev/null @@ -1,31 +0,0 @@ -package subnets - -import "github.com/rackspace/gophercloud" - -func resourceURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL("subnets", id) -} - -func rootURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL("subnets") -} - -func listURL(c *gophercloud.ServiceClient) string { - return rootURL(c) -} - -func getURL(c *gophercloud.ServiceClient, id string) string { - return resourceURL(c, id) -} - -func createURL(c *gophercloud.ServiceClient) string { - return rootURL(c) -} - -func updateURL(c *gophercloud.ServiceClient, id string) string { - return resourceURL(c, id) -} - -func deleteURL(c *gophercloud.ServiceClient, id string) string { - return resourceURL(c, id) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts/doc.go deleted file mode 100644 index f5f894a9e5..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts/doc.go +++ /dev/null @@ -1,8 +0,0 @@ -// Package accounts contains functionality for working with Object Storage -// account resources. An account is the top-level resource the object storage -// hierarchy: containers belong to accounts, objects belong to containers. -// -// Another way of thinking of an account is like a namespace for all your -// resources. It is synonymous with a project or tenant in other OpenStack -// services. -package accounts diff --git a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts/fixtures.go deleted file mode 100644 index f22b687005..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts/fixtures.go +++ /dev/null @@ -1,38 +0,0 @@ -// +build fixtures - -package accounts - -import ( - "net/http" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -// HandleGetAccountSuccessfully creates an HTTP handler at `/` on the test handler mux that -// responds with a `Get` response. -func HandleGetAccountSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "HEAD") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Set("X-Account-Container-Count", "2") - w.Header().Set("X-Account-Bytes-Used", "14") - w.Header().Set("X-Account-Meta-Subject", "books") - - w.WriteHeader(http.StatusNoContent) - }) -} - -// HandleUpdateAccountSuccessfully creates an HTTP handler at `/` on the test handler mux that -// responds with a `Update` response. -func HandleUpdateAccountSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "X-Account-Meta-Gophercloud-Test", "accounts") - - w.WriteHeader(http.StatusNoContent) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts/requests.go deleted file mode 100644 index a645115705..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts/requests.go +++ /dev/null @@ -1,103 +0,0 @@ -package accounts - -import "github.com/rackspace/gophercloud" - -// GetOptsBuilder allows extensions to add additional headers to the Get -// request. -type GetOptsBuilder interface { - ToAccountGetMap() (map[string]string, error) -} - -// GetOpts is a structure that contains parameters for getting an account's -// metadata. -type GetOpts struct { - Newest bool `h:"X-Newest"` -} - -// ToAccountGetMap formats a GetOpts into a map[string]string of headers. -func (opts GetOpts) ToAccountGetMap() (map[string]string, error) { - return gophercloud.BuildHeaders(opts) -} - -// Get is a function that retrieves an account's metadata. To extract just the -// custom metadata, call the ExtractMetadata method on the GetResult. To extract -// all the headers that are returned (including the metadata), call the -// ExtractHeader method on the GetResult. -func Get(c *gophercloud.ServiceClient, opts GetOptsBuilder) GetResult { - var res GetResult - h := c.AuthenticatedHeaders() - - if opts != nil { - headers, err := opts.ToAccountGetMap() - if err != nil { - res.Err = err - return res - } - - for k, v := range headers { - h[k] = v - } - } - - resp, err := c.Request("HEAD", getURL(c), gophercloud.RequestOpts{ - MoreHeaders: h, - OkCodes: []int{204}, - }) - res.Header = resp.Header - res.Err = err - return res -} - -// UpdateOptsBuilder allows extensions to add additional headers to the Update -// request. -type UpdateOptsBuilder interface { - ToAccountUpdateMap() (map[string]string, error) -} - -// UpdateOpts is a structure that contains parameters for updating, creating, or -// deleting an account's metadata. -type UpdateOpts struct { - Metadata map[string]string - ContentType string `h:"Content-Type"` - DetectContentType bool `h:"X-Detect-Content-Type"` - TempURLKey string `h:"X-Account-Meta-Temp-URL-Key"` - TempURLKey2 string `h:"X-Account-Meta-Temp-URL-Key-2"` -} - -// ToAccountUpdateMap formats an UpdateOpts into a map[string]string of headers. -func (opts UpdateOpts) ToAccountUpdateMap() (map[string]string, error) { - headers, err := gophercloud.BuildHeaders(opts) - if err != nil { - return nil, err - } - for k, v := range opts.Metadata { - headers["X-Account-Meta-"+k] = v - } - return headers, err -} - -// Update is a function that creates, updates, or deletes an account's metadata. -// To extract the headers returned, call the Extract method on the UpdateResult. -func Update(c *gophercloud.ServiceClient, opts UpdateOptsBuilder) UpdateResult { - var res UpdateResult - h := make(map[string]string) - - if opts != nil { - headers, err := opts.ToAccountUpdateMap() - if err != nil { - res.Err = err - return res - } - for k, v := range headers { - h[k] = v - } - } - - resp, err := c.Request("POST", updateURL(c), gophercloud.RequestOpts{ - MoreHeaders: h, - OkCodes: []int{201, 202, 204}, - }) - res.Header = resp.Header - res.Err = err - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts/results.go b/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts/results.go deleted file mode 100644 index 6ab1a23061..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts/results.go +++ /dev/null @@ -1,102 +0,0 @@ -package accounts - -import ( - "strings" - "time" - - "github.com/rackspace/gophercloud" -) - -// UpdateResult is returned from a call to the Update function. -type UpdateResult struct { - gophercloud.HeaderResult -} - -// UpdateHeader represents the headers returned in the response from an Update request. -type UpdateHeader struct { - ContentLength string `mapstructure:"Content-Length"` - ContentType string `mapstructure:"Content-Type"` - Date time.Time `mapstructure:"-"` - TransID string `mapstructure:"X-Trans-Id"` -} - -// Extract will return a struct of headers returned from a call to Get. To obtain -// a map of headers, call the ExtractHeader method on the GetResult. -func (ur UpdateResult) Extract() (UpdateHeader, error) { - var uh UpdateHeader - if ur.Err != nil { - return uh, ur.Err - } - - if err := gophercloud.DecodeHeader(ur.Header, &uh); err != nil { - return uh, err - } - - if date, ok := ur.Header["Date"]; ok && len(date) > 0 { - t, err := time.Parse(time.RFC1123, ur.Header["Date"][0]) - if err != nil { - return uh, err - } - uh.Date = t - } - - return uh, nil -} - -// GetHeader represents the headers returned in the response from a Get request. -type GetHeader struct { - BytesUsed int64 `mapstructure:"X-Account-Bytes-Used"` - ContainerCount int `mapstructure:"X-Account-Container-Count"` - ContentLength int64 `mapstructure:"Content-Length"` - ContentType string `mapstructure:"Content-Type"` - Date time.Time `mapstructure:"-"` - ObjectCount int64 `mapstructure:"X-Account-Object-Count"` - TransID string `mapstructure:"X-Trans-Id"` - TempURLKey string `mapstructure:"X-Account-Meta-Temp-URL-Key"` - TempURLKey2 string `mapstructure:"X-Account-Meta-Temp-URL-Key-2"` -} - -// GetResult is returned from a call to the Get function. -type GetResult struct { - gophercloud.HeaderResult -} - -// Extract will return a struct of headers returned from a call to Get. To obtain -// a map of headers, call the ExtractHeader method on the GetResult. -func (gr GetResult) Extract() (GetHeader, error) { - var gh GetHeader - if gr.Err != nil { - return gh, gr.Err - } - - if err := gophercloud.DecodeHeader(gr.Header, &gh); err != nil { - return gh, err - } - - if date, ok := gr.Header["Date"]; ok && len(date) > 0 { - t, err := time.Parse(time.RFC1123, gr.Header["Date"][0]) - if err != nil { - return gh, err - } - gh.Date = t - } - - return gh, nil -} - -// ExtractMetadata is a function that takes a GetResult (of type *http.Response) -// and returns the custom metatdata associated with the account. -func (gr GetResult) ExtractMetadata() (map[string]string, error) { - if gr.Err != nil { - return nil, gr.Err - } - - metadata := make(map[string]string) - for k, v := range gr.Header { - if strings.HasPrefix(k, "X-Account-Meta-") { - key := strings.TrimPrefix(k, "X-Account-Meta-") - metadata[key] = v[0] - } - } - return metadata, nil -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts/urls.go deleted file mode 100644 index 9952fe4345..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts/urls.go +++ /dev/null @@ -1,11 +0,0 @@ -package accounts - -import "github.com/rackspace/gophercloud" - -func getURL(c *gophercloud.ServiceClient) string { - return c.Endpoint -} - -func updateURL(c *gophercloud.ServiceClient) string { - return getURL(c) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers/doc.go deleted file mode 100644 index 5fed5537f1..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers/doc.go +++ /dev/null @@ -1,8 +0,0 @@ -// Package containers contains functionality for working with Object Storage -// container resources. A container serves as a logical namespace for objects -// that are placed inside it - an object with the same name in two different -// containers represents two different objects. -// -// In addition to containing objects, you can also use the container to control -// access to objects by using an access control list (ACL). -package containers diff --git a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers/fixtures.go deleted file mode 100644 index e60735248f..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers/fixtures.go +++ /dev/null @@ -1,143 +0,0 @@ -// +build fixtures - -package containers - -import ( - "fmt" - "net/http" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -// ExpectedListInfo is the result expected from a call to `List` when full -// info is requested. -var ExpectedListInfo = []Container{ - Container{ - Count: 0, - Bytes: 0, - Name: "janeausten", - }, - Container{ - Count: 1, - Bytes: 14, - Name: "marktwain", - }, -} - -// ExpectedListNames is the result expected from a call to `List` when just -// container names are requested. -var ExpectedListNames = []string{"janeausten", "marktwain"} - -// HandleListContainerInfoSuccessfully creates an HTTP handler at `/` on the test handler mux that -// responds with a `List` response when full info is requested. -func HandleListContainerInfoSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - w.Header().Set("Content-Type", "application/json") - r.ParseForm() - marker := r.Form.Get("marker") - switch marker { - case "": - fmt.Fprintf(w, `[ - { - "count": 0, - "bytes": 0, - "name": "janeausten" - }, - { - "count": 1, - "bytes": 14, - "name": "marktwain" - } - ]`) - case "janeausten": - fmt.Fprintf(w, `[ - { - "count": 1, - "bytes": 14, - "name": "marktwain" - } - ]`) - case "marktwain": - fmt.Fprintf(w, `[]`) - default: - t.Fatalf("Unexpected marker: [%s]", marker) - } - }) -} - -// HandleListContainerNamesSuccessfully creates an HTTP handler at `/` on the test handler mux that -// responds with a `ListNames` response when only container names are requested. -func HandleListContainerNamesSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "text/plain") - - w.Header().Set("Content-Type", "text/plain") - r.ParseForm() - marker := r.Form.Get("marker") - switch marker { - case "": - fmt.Fprintf(w, "janeausten\nmarktwain\n") - case "janeausten": - fmt.Fprintf(w, "marktwain\n") - case "marktwain": - fmt.Fprintf(w, ``) - default: - t.Fatalf("Unexpected marker: [%s]", marker) - } - }) -} - -// HandleCreateContainerSuccessfully creates an HTTP handler at `/testContainer` on the test handler mux that -// responds with a `Create` response. -func HandleCreateContainerSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/testContainer", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PUT") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - w.Header().Add("X-Container-Meta-Foo", "bar") - w.Header().Add("X-Trans-Id", "1234567") - w.WriteHeader(http.StatusNoContent) - }) -} - -// HandleDeleteContainerSuccessfully creates an HTTP handler at `/testContainer` on the test handler mux that -// responds with a `Delete` response. -func HandleDeleteContainerSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/testContainer", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - w.WriteHeader(http.StatusNoContent) - }) -} - -// HandleUpdateContainerSuccessfully creates an HTTP handler at `/testContainer` on the test handler mux that -// responds with a `Update` response. -func HandleUpdateContainerSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/testContainer", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - w.WriteHeader(http.StatusNoContent) - }) -} - -// HandleGetContainerSuccessfully creates an HTTP handler at `/testContainer` on the test handler mux that -// responds with a `Get` response. -func HandleGetContainerSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/testContainer", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "HEAD") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - w.WriteHeader(http.StatusNoContent) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers/requests.go deleted file mode 100644 index bbf8cdb952..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers/requests.go +++ /dev/null @@ -1,199 +0,0 @@ -package containers - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// ListOptsBuilder allows extensions to add additional parameters to the List -// request. -type ListOptsBuilder interface { - ToContainerListParams() (bool, string, error) -} - -// ListOpts is a structure that holds options for listing containers. -type ListOpts struct { - Full bool - Limit int `q:"limit"` - Marker string `q:"marker"` - EndMarker string `q:"end_marker"` - Format string `q:"format"` - Prefix string `q:"prefix"` - Delimiter string `q:"delimiter"` -} - -// ToContainerListParams formats a ListOpts into a query string and boolean -// representing whether to list complete information for each container. -func (opts ListOpts) ToContainerListParams() (bool, string, error) { - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return false, "", err - } - return opts.Full, q.String(), nil -} - -// List is a function that retrieves containers associated with the account as -// well as account metadata. It returns a pager which can be iterated with the -// EachPage function. -func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { - headers := map[string]string{"Accept": "text/plain", "Content-Type": "text/plain"} - - url := listURL(c) - if opts != nil { - full, query, err := opts.ToContainerListParams() - if err != nil { - return pagination.Pager{Err: err} - } - url += query - - if full { - headers = map[string]string{"Accept": "application/json", "Content-Type": "application/json"} - } - } - - createPage := func(r pagination.PageResult) pagination.Page { - p := ContainerPage{pagination.MarkerPageBase{PageResult: r}} - p.MarkerPageBase.Owner = p - return p - } - - pager := pagination.NewPager(c, url, createPage) - pager.Headers = headers - return pager -} - -// CreateOptsBuilder allows extensions to add additional parameters to the -// Create request. -type CreateOptsBuilder interface { - ToContainerCreateMap() (map[string]string, error) -} - -// CreateOpts is a structure that holds parameters for creating a container. -type CreateOpts struct { - Metadata map[string]string - ContainerRead string `h:"X-Container-Read"` - ContainerSyncTo string `h:"X-Container-Sync-To"` - ContainerSyncKey string `h:"X-Container-Sync-Key"` - ContainerWrite string `h:"X-Container-Write"` - ContentType string `h:"Content-Type"` - DetectContentType bool `h:"X-Detect-Content-Type"` - IfNoneMatch string `h:"If-None-Match"` - VersionsLocation string `h:"X-Versions-Location"` -} - -// ToContainerCreateMap formats a CreateOpts into a map of headers. -func (opts CreateOpts) ToContainerCreateMap() (map[string]string, error) { - h, err := gophercloud.BuildHeaders(opts) - if err != nil { - return nil, err - } - for k, v := range opts.Metadata { - h["X-Container-Meta-"+k] = v - } - return h, nil -} - -// Create is a function that creates a new container. -func Create(c *gophercloud.ServiceClient, containerName string, opts CreateOptsBuilder) CreateResult { - var res CreateResult - h := c.AuthenticatedHeaders() - - if opts != nil { - headers, err := opts.ToContainerCreateMap() - if err != nil { - res.Err = err - return res - } - - for k, v := range headers { - h[k] = v - } - } - - resp, err := c.Request("PUT", createURL(c, containerName), gophercloud.RequestOpts{ - MoreHeaders: h, - OkCodes: []int{201, 202, 204}, - }) - res.Header = resp.Header - res.Err = err - return res -} - -// Delete is a function that deletes a container. -func Delete(c *gophercloud.ServiceClient, containerName string) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(deleteURL(c, containerName), nil) - return res -} - -// UpdateOptsBuilder allows extensions to add additional parameters to the -// Update request. -type UpdateOptsBuilder interface { - ToContainerUpdateMap() (map[string]string, error) -} - -// UpdateOpts is a structure that holds parameters for updating, creating, or -// deleting a container's metadata. -type UpdateOpts struct { - Metadata map[string]string - ContainerRead string `h:"X-Container-Read"` - ContainerSyncTo string `h:"X-Container-Sync-To"` - ContainerSyncKey string `h:"X-Container-Sync-Key"` - ContainerWrite string `h:"X-Container-Write"` - ContentType string `h:"Content-Type"` - DetectContentType bool `h:"X-Detect-Content-Type"` - RemoveVersionsLocation string `h:"X-Remove-Versions-Location"` - VersionsLocation string `h:"X-Versions-Location"` -} - -// ToContainerUpdateMap formats a CreateOpts into a map of headers. -func (opts UpdateOpts) ToContainerUpdateMap() (map[string]string, error) { - h, err := gophercloud.BuildHeaders(opts) - if err != nil { - return nil, err - } - for k, v := range opts.Metadata { - h["X-Container-Meta-"+k] = v - } - return h, nil -} - -// Update is a function that creates, updates, or deletes a container's -// metadata. -func Update(c *gophercloud.ServiceClient, containerName string, opts UpdateOptsBuilder) UpdateResult { - var res UpdateResult - h := c.AuthenticatedHeaders() - - if opts != nil { - headers, err := opts.ToContainerUpdateMap() - if err != nil { - res.Err = err - return res - } - - for k, v := range headers { - h[k] = v - } - } - - resp, err := c.Request("POST", updateURL(c, containerName), gophercloud.RequestOpts{ - MoreHeaders: h, - OkCodes: []int{201, 202, 204}, - }) - res.Header = resp.Header - res.Err = err - return res -} - -// Get is a function that retrieves the metadata of a container. To extract just -// the custom metadata, pass the GetResult response to the ExtractMetadata -// function. -func Get(c *gophercloud.ServiceClient, containerName string) GetResult { - var res GetResult - resp, err := c.Request("HEAD", getURL(c, containerName), gophercloud.RequestOpts{ - OkCodes: []int{200, 204}, - }) - res.Header = resp.Header - res.Err = err - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers/results.go b/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers/results.go deleted file mode 100644 index e682b8dccb..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers/results.go +++ /dev/null @@ -1,270 +0,0 @@ -package containers - -import ( - "fmt" - "strings" - "time" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" - - "github.com/mitchellh/mapstructure" -) - -// Container represents a container resource. -type Container struct { - // The total number of bytes stored in the container. - Bytes int `json:"bytes" mapstructure:"bytes"` - - // The total number of objects stored in the container. - Count int `json:"count" mapstructure:"count"` - - // The name of the container. - Name string `json:"name" mapstructure:"name"` -} - -// ContainerPage is the page returned by a pager when traversing over a -// collection of containers. -type ContainerPage struct { - pagination.MarkerPageBase -} - -// IsEmpty returns true if a ListResult contains no container names. -func (r ContainerPage) IsEmpty() (bool, error) { - names, err := ExtractNames(r) - if err != nil { - return true, err - } - return len(names) == 0, nil -} - -// LastMarker returns the last container name in a ListResult. -func (r ContainerPage) LastMarker() (string, error) { - names, err := ExtractNames(r) - if err != nil { - return "", err - } - if len(names) == 0 { - return "", nil - } - return names[len(names)-1], nil -} - -// ExtractInfo is a function that takes a ListResult and returns the containers' information. -func ExtractInfo(page pagination.Page) ([]Container, error) { - untyped := page.(ContainerPage).Body.([]interface{}) - results := make([]Container, len(untyped)) - for index, each := range untyped { - container := each.(map[string]interface{}) - err := mapstructure.Decode(container, &results[index]) - if err != nil { - return results, err - } - } - return results, nil -} - -// ExtractNames is a function that takes a ListResult and returns the containers' names. -func ExtractNames(page pagination.Page) ([]string, error) { - casted := page.(ContainerPage) - ct := casted.Header.Get("Content-Type") - - switch { - case strings.HasPrefix(ct, "application/json"): - parsed, err := ExtractInfo(page) - if err != nil { - return nil, err - } - - names := make([]string, 0, len(parsed)) - for _, container := range parsed { - names = append(names, container.Name) - } - return names, nil - case strings.HasPrefix(ct, "text/plain"): - names := make([]string, 0, 50) - - body := string(page.(ContainerPage).Body.([]uint8)) - for _, name := range strings.Split(body, "\n") { - if len(name) > 0 { - names = append(names, name) - } - } - - return names, nil - default: - return nil, fmt.Errorf("Cannot extract names from response with content-type: [%s]", ct) - } -} - -// GetHeader represents the headers returned in the response from a Get request. -type GetHeader struct { - AcceptRanges string `mapstructure:"Accept-Ranges"` - BytesUsed int64 `mapstructure:"X-Account-Bytes-Used"` - ContentLength int64 `mapstructure:"Content-Length"` - ContentType string `mapstructure:"Content-Type"` - Date time.Time `mapstructure:"-"` - ObjectCount int64 `mapstructure:"X-Container-Object-Count"` - Read string `mapstructure:"X-Container-Read"` - TransID string `mapstructure:"X-Trans-Id"` - VersionsLocation string `mapstructure:"X-Versions-Location"` - Write string `mapstructure:"X-Container-Write"` -} - -// GetResult represents the result of a get operation. -type GetResult struct { - gophercloud.HeaderResult -} - -// Extract will return a struct of headers returned from a call to Get. To obtain -// a map of headers, call the ExtractHeader method on the GetResult. -func (gr GetResult) Extract() (GetHeader, error) { - var gh GetHeader - if gr.Err != nil { - return gh, gr.Err - } - - if err := gophercloud.DecodeHeader(gr.Header, &gh); err != nil { - return gh, err - } - - if date, ok := gr.Header["Date"]; ok && len(date) > 0 { - t, err := time.Parse(time.RFC1123, gr.Header["Date"][0]) - if err != nil { - return gh, err - } - gh.Date = t - } - - return gh, nil -} - -// ExtractMetadata is a function that takes a GetResult (of type *http.Response) -// and returns the custom metadata associated with the container. -func (gr GetResult) ExtractMetadata() (map[string]string, error) { - if gr.Err != nil { - return nil, gr.Err - } - metadata := make(map[string]string) - for k, v := range gr.Header { - if strings.HasPrefix(k, "X-Container-Meta-") { - key := strings.TrimPrefix(k, "X-Container-Meta-") - metadata[key] = v[0] - } - } - return metadata, nil -} - -// CreateHeader represents the headers returned in the response from a Create request. -type CreateHeader struct { - ContentLength int64 `mapstructure:"Content-Length"` - ContentType string `mapstructure:"Content-Type"` - Date time.Time `mapstructure:"-"` - TransID string `mapstructure:"X-Trans-Id"` -} - -// CreateResult represents the result of a create operation. To extract the -// the headers from the HTTP response, you can invoke the 'ExtractHeader' -// method on the result struct. -type CreateResult struct { - gophercloud.HeaderResult -} - -// Extract will return a struct of headers returned from a call to Create. To obtain -// a map of headers, call the ExtractHeader method on the CreateResult. -func (cr CreateResult) Extract() (CreateHeader, error) { - var ch CreateHeader - if cr.Err != nil { - return ch, cr.Err - } - - if err := gophercloud.DecodeHeader(cr.Header, &ch); err != nil { - return ch, err - } - - if date, ok := cr.Header["Date"]; ok && len(date) > 0 { - t, err := time.Parse(time.RFC1123, cr.Header["Date"][0]) - if err != nil { - return ch, err - } - ch.Date = t - } - - return ch, nil -} - -// UpdateHeader represents the headers returned in the response from a Update request. -type UpdateHeader struct { - ContentLength int64 `mapstructure:"Content-Length"` - ContentType string `mapstructure:"Content-Type"` - Date time.Time `mapstructure:"-"` - TransID string `mapstructure:"X-Trans-Id"` -} - -// UpdateResult represents the result of an update operation. To extract the -// the headers from the HTTP response, you can invoke the 'ExtractHeader' -// method on the result struct. -type UpdateResult struct { - gophercloud.HeaderResult -} - -// Extract will return a struct of headers returned from a call to Update. To obtain -// a map of headers, call the ExtractHeader method on the UpdateResult. -func (ur UpdateResult) Extract() (UpdateHeader, error) { - var uh UpdateHeader - if ur.Err != nil { - return uh, ur.Err - } - - if err := gophercloud.DecodeHeader(ur.Header, &uh); err != nil { - return uh, err - } - - if date, ok := ur.Header["Date"]; ok && len(date) > 0 { - t, err := time.Parse(time.RFC1123, ur.Header["Date"][0]) - if err != nil { - return uh, err - } - uh.Date = t - } - - return uh, nil -} - -// DeleteHeader represents the headers returned in the response from a Delete request. -type DeleteHeader struct { - ContentLength int64 `mapstructure:"Content-Length"` - ContentType string `mapstructure:"Content-Type"` - Date time.Time `mapstructure:"-"` - TransID string `mapstructure:"X-Trans-Id"` -} - -// DeleteResult represents the result of a delete operation. To extract the -// the headers from the HTTP response, you can invoke the 'ExtractHeader' -// method on the result struct. -type DeleteResult struct { - gophercloud.HeaderResult -} - -// Extract will return a struct of headers returned from a call to Delete. To obtain -// a map of headers, call the ExtractHeader method on the DeleteResult. -func (dr DeleteResult) Extract() (DeleteHeader, error) { - var dh DeleteHeader - if dr.Err != nil { - return dh, dr.Err - } - - if err := gophercloud.DecodeHeader(dr.Header, &dh); err != nil { - return dh, err - } - - if date, ok := dr.Header["Date"]; ok && len(date) > 0 { - t, err := time.Parse(time.RFC1123, dr.Header["Date"][0]) - if err != nil { - return dh, err - } - dh.Date = t - } - - return dh, nil -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers/urls.go deleted file mode 100644 index f864f846eb..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers/urls.go +++ /dev/null @@ -1,23 +0,0 @@ -package containers - -import "github.com/rackspace/gophercloud" - -func listURL(c *gophercloud.ServiceClient) string { - return c.Endpoint -} - -func createURL(c *gophercloud.ServiceClient, container string) string { - return c.ServiceURL(container) -} - -func getURL(c *gophercloud.ServiceClient, container string) string { - return createURL(c, container) -} - -func deleteURL(c *gophercloud.ServiceClient, container string) string { - return createURL(c, container) -} - -func updateURL(c *gophercloud.ServiceClient, container string) string { - return createURL(c, container) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects/doc.go deleted file mode 100644 index 30a9adde1c..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -// Package objects contains functionality for working with Object Storage -// object resources. An object is a resource that represents and contains data -// - such as documents, images, and so on. You can also store custom metadata -// with an object. -package objects diff --git a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects/fixtures.go deleted file mode 100644 index ec616371a3..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects/fixtures.go +++ /dev/null @@ -1,182 +0,0 @@ -// +build fixtures - -package objects - -import ( - "fmt" - "net/http" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -// HandleDownloadObjectSuccessfully creates an HTTP handler at `/testContainer/testObject` on the test handler mux that -// responds with a `Download` response. -func HandleDownloadObjectSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/testContainer/testObject", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, "Successful download with Gophercloud") - }) -} - -// ExpectedListInfo is the result expected from a call to `List` when full -// info is requested. -var ExpectedListInfo = []Object{ - Object{ - Hash: "451e372e48e0f6b1114fa0724aa79fa1", - LastModified: "2009-11-10 23:00:00 +0000 UTC", - Bytes: 14, - Name: "goodbye", - ContentType: "application/octet-stream", - }, - Object{ - Hash: "451e372e48e0f6b1114fa0724aa79fa1", - LastModified: "2009-11-10 23:00:00 +0000 UTC", - Bytes: 14, - Name: "hello", - ContentType: "application/octet-stream", - }, -} - -// ExpectedListNames is the result expected from a call to `List` when just -// object names are requested. -var ExpectedListNames = []string{"hello", "goodbye"} - -// HandleListObjectsInfoSuccessfully creates an HTTP handler at `/testContainer` on the test handler mux that -// responds with a `List` response when full info is requested. -func HandleListObjectsInfoSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/testContainer", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - w.Header().Set("Content-Type", "application/json") - r.ParseForm() - marker := r.Form.Get("marker") - switch marker { - case "": - fmt.Fprintf(w, `[ - { - "hash": "451e372e48e0f6b1114fa0724aa79fa1", - "last_modified": "2009-11-10 23:00:00 +0000 UTC", - "bytes": 14, - "name": "goodbye", - "content_type": "application/octet-stream" - }, - { - "hash": "451e372e48e0f6b1114fa0724aa79fa1", - "last_modified": "2009-11-10 23:00:00 +0000 UTC", - "bytes": 14, - "name": "hello", - "content_type": "application/octet-stream" - } - ]`) - case "hello": - fmt.Fprintf(w, `[]`) - default: - t.Fatalf("Unexpected marker: [%s]", marker) - } - }) -} - -// HandleListObjectNamesSuccessfully creates an HTTP handler at `/testContainer` on the test handler mux that -// responds with a `List` response when only object names are requested. -func HandleListObjectNamesSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/testContainer", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "text/plain") - - w.Header().Set("Content-Type", "text/plain") - r.ParseForm() - marker := r.Form.Get("marker") - switch marker { - case "": - fmt.Fprintf(w, "hello\ngoodbye\n") - case "goodbye": - fmt.Fprintf(w, "") - default: - t.Fatalf("Unexpected marker: [%s]", marker) - } - }) -} - -// HandleCreateTextObjectSuccessfully creates an HTTP handler at `/testContainer/testObject` on the test handler mux -// that responds with a `Create` response. A Content-Type of "text/plain" is expected. -func HandleCreateTextObjectSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/testContainer/testObject", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PUT") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Content-Type", "text/plain") - th.TestHeader(t, r, "Accept", "application/json") - w.WriteHeader(http.StatusCreated) - }) -} - -// HandleCreateTypelessObjectSuccessfully creates an HTTP handler at `/testContainer/testObject` on the test handler -// mux that responds with a `Create` response. No Content-Type header may be present in the request, so that server- -// side content-type detection will be triggered properly. -func HandleCreateTypelessObjectSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/testContainer/testObject", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PUT") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - if contentType, present := r.Header["Content-Type"]; present { - t.Errorf("Expected Content-Type header to be omitted, but was %#v", contentType) - } - - w.WriteHeader(http.StatusCreated) - }) -} - -// HandleCopyObjectSuccessfully creates an HTTP handler at `/testContainer/testObject` on the test handler mux that -// responds with a `Copy` response. -func HandleCopyObjectSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/testContainer/testObject", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "COPY") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - th.TestHeader(t, r, "Destination", "/newTestContainer/newTestObject") - w.WriteHeader(http.StatusCreated) - }) -} - -// HandleDeleteObjectSuccessfully creates an HTTP handler at `/testContainer/testObject` on the test handler mux that -// responds with a `Delete` response. -func HandleDeleteObjectSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/testContainer/testObject", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - w.WriteHeader(http.StatusNoContent) - }) -} - -// HandleUpdateObjectSuccessfully creates an HTTP handler at `/testContainer/testObject` on the test handler mux that -// responds with a `Update` response. -func HandleUpdateObjectSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/testContainer/testObject", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - th.TestHeader(t, r, "X-Object-Meta-Gophercloud-Test", "objects") - w.WriteHeader(http.StatusAccepted) - }) -} - -// HandleGetObjectSuccessfully creates an HTTP handler at `/testContainer/testObject` on the test handler mux that -// responds with a `Get` response. -func HandleGetObjectSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/testContainer/testObject", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "HEAD") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - w.Header().Add("X-Object-Meta-Gophercloud-Test", "objects") - w.WriteHeader(http.StatusNoContent) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects/requests.go deleted file mode 100644 index 7eedde2550..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects/requests.go +++ /dev/null @@ -1,464 +0,0 @@ -package objects - -import ( - "crypto/hmac" - "crypto/sha1" - "fmt" - "io" - "strings" - "time" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts" - "github.com/rackspace/gophercloud/pagination" -) - -// ListOptsBuilder allows extensions to add additional parameters to the List -// request. -type ListOptsBuilder interface { - ToObjectListParams() (bool, string, error) -} - -// ListOpts is a structure that holds parameters for listing objects. -type ListOpts struct { - // Full is a true/false value that represents the amount of object information - // returned. If Full is set to true, then the content-type, number of bytes, hash - // date last modified, and name are returned. If set to false or not set, then - // only the object names are returned. - Full bool - Limit int `q:"limit"` - Marker string `q:"marker"` - EndMarker string `q:"end_marker"` - Format string `q:"format"` - Prefix string `q:"prefix"` - Delimiter string `q:"delimiter"` - Path string `q:"path"` -} - -// ToObjectListParams formats a ListOpts into a query string and boolean -// representing whether to list complete information for each object. -func (opts ListOpts) ToObjectListParams() (bool, string, error) { - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return false, "", err - } - return opts.Full, q.String(), nil -} - -// List is a function that retrieves all objects in a container. It also returns the details -// for the container. To extract only the object information or names, pass the ListResult -// response to the ExtractInfo or ExtractNames function, respectively. -func List(c *gophercloud.ServiceClient, containerName string, opts ListOptsBuilder) pagination.Pager { - headers := map[string]string{"Accept": "text/plain", "Content-Type": "text/plain"} - - url := listURL(c, containerName) - if opts != nil { - full, query, err := opts.ToObjectListParams() - if err != nil { - return pagination.Pager{Err: err} - } - url += query - - if full { - headers = map[string]string{"Accept": "application/json", "Content-Type": "application/json"} - } - } - - createPage := func(r pagination.PageResult) pagination.Page { - p := ObjectPage{pagination.MarkerPageBase{PageResult: r}} - p.MarkerPageBase.Owner = p - return p - } - - pager := pagination.NewPager(c, url, createPage) - pager.Headers = headers - return pager -} - -// DownloadOptsBuilder allows extensions to add additional parameters to the -// Download request. -type DownloadOptsBuilder interface { - ToObjectDownloadParams() (map[string]string, string, error) -} - -// DownloadOpts is a structure that holds parameters for downloading an object. -type DownloadOpts struct { - IfMatch string `h:"If-Match"` - IfModifiedSince time.Time `h:"If-Modified-Since"` - IfNoneMatch string `h:"If-None-Match"` - IfUnmodifiedSince time.Time `h:"If-Unmodified-Since"` - Range string `h:"Range"` - Expires string `q:"expires"` - MultipartManifest string `q:"multipart-manifest"` - Signature string `q:"signature"` -} - -// ToObjectDownloadParams formats a DownloadOpts into a query string and map of -// headers. -func (opts DownloadOpts) ToObjectDownloadParams() (map[string]string, string, error) { - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return nil, "", err - } - h, err := gophercloud.BuildHeaders(opts) - if err != nil { - return nil, q.String(), err - } - return h, q.String(), nil -} - -// Download is a function that retrieves the content and metadata for an object. -// To extract just the content, pass the DownloadResult response to the -// ExtractContent function. -func Download(c *gophercloud.ServiceClient, containerName, objectName string, opts DownloadOptsBuilder) DownloadResult { - var res DownloadResult - - url := downloadURL(c, containerName, objectName) - h := c.AuthenticatedHeaders() - - if opts != nil { - headers, query, err := opts.ToObjectDownloadParams() - if err != nil { - res.Err = err - return res - } - - for k, v := range headers { - h[k] = v - } - - url += query - } - - resp, err := c.Request("GET", url, gophercloud.RequestOpts{ - MoreHeaders: h, - OkCodes: []int{200, 304}, - }) - - res.Body = resp.Body - res.Err = err - res.Header = resp.Header - - return res -} - -// CreateOptsBuilder allows extensions to add additional parameters to the -// Create request. -type CreateOptsBuilder interface { - ToObjectCreateParams() (map[string]string, string, error) -} - -// CreateOpts is a structure that holds parameters for creating an object. -type CreateOpts struct { - Metadata map[string]string - ContentDisposition string `h:"Content-Disposition"` - ContentEncoding string `h:"Content-Encoding"` - ContentLength int64 `h:"Content-Length"` - ContentType string `h:"Content-Type"` - CopyFrom string `h:"X-Copy-From"` - DeleteAfter int `h:"X-Delete-After"` - DeleteAt int `h:"X-Delete-At"` - DetectContentType string `h:"X-Detect-Content-Type"` - ETag string `h:"ETag"` - IfNoneMatch string `h:"If-None-Match"` - ObjectManifest string `h:"X-Object-Manifest"` - TransferEncoding string `h:"Transfer-Encoding"` - Expires string `q:"expires"` - MultipartManifest string `q:"multiple-manifest"` - Signature string `q:"signature"` -} - -// ToObjectCreateParams formats a CreateOpts into a query string and map of -// headers. -func (opts CreateOpts) ToObjectCreateParams() (map[string]string, string, error) { - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return nil, "", err - } - h, err := gophercloud.BuildHeaders(opts) - if err != nil { - return nil, q.String(), err - } - - for k, v := range opts.Metadata { - h["X-Object-Meta-"+k] = v - } - - return h, q.String(), nil -} - -// Create is a function that creates a new object or replaces an existing object. -func Create(c *gophercloud.ServiceClient, containerName, objectName string, content io.Reader, opts CreateOptsBuilder) CreateResult { - var res CreateResult - - url := createURL(c, containerName, objectName) - h := make(map[string]string) - - if opts != nil { - headers, query, err := opts.ToObjectCreateParams() - if err != nil { - res.Err = err - return res - } - - for k, v := range headers { - h[k] = v - } - - url += query - } - - ropts := gophercloud.RequestOpts{ - RawBody: content, - MoreHeaders: h, - } - - resp, err := c.Request("PUT", url, ropts) - res.Header = resp.Header - res.Err = err - return res -} - -// CopyOptsBuilder allows extensions to add additional parameters to the -// Copy request. -type CopyOptsBuilder interface { - ToObjectCopyMap() (map[string]string, error) -} - -// CopyOpts is a structure that holds parameters for copying one object to -// another. -type CopyOpts struct { - Metadata map[string]string - ContentDisposition string `h:"Content-Disposition"` - ContentEncoding string `h:"Content-Encoding"` - ContentType string `h:"Content-Type"` - Destination string `h:"Destination,required"` -} - -// ToObjectCopyMap formats a CopyOpts into a map of headers. -func (opts CopyOpts) ToObjectCopyMap() (map[string]string, error) { - if opts.Destination == "" { - return nil, fmt.Errorf("Required CopyOpts field 'Destination' not set.") - } - h, err := gophercloud.BuildHeaders(opts) - if err != nil { - return nil, err - } - for k, v := range opts.Metadata { - h["X-Object-Meta-"+k] = v - } - return h, nil -} - -// Copy is a function that copies one object to another. -func Copy(c *gophercloud.ServiceClient, containerName, objectName string, opts CopyOptsBuilder) CopyResult { - var res CopyResult - h := c.AuthenticatedHeaders() - - headers, err := opts.ToObjectCopyMap() - if err != nil { - res.Err = err - return res - } - - for k, v := range headers { - h[k] = v - } - - url := copyURL(c, containerName, objectName) - resp, err := c.Request("COPY", url, gophercloud.RequestOpts{ - MoreHeaders: h, - OkCodes: []int{201}, - }) - res.Header = resp.Header - res.Err = err - return res -} - -// DeleteOptsBuilder allows extensions to add additional parameters to the -// Delete request. -type DeleteOptsBuilder interface { - ToObjectDeleteQuery() (string, error) -} - -// DeleteOpts is a structure that holds parameters for deleting an object. -type DeleteOpts struct { - MultipartManifest string `q:"multipart-manifest"` -} - -// ToObjectDeleteQuery formats a DeleteOpts into a query string. -func (opts DeleteOpts) ToObjectDeleteQuery() (string, error) { - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return "", err - } - return q.String(), nil -} - -// Delete is a function that deletes an object. -func Delete(c *gophercloud.ServiceClient, containerName, objectName string, opts DeleteOptsBuilder) DeleteResult { - var res DeleteResult - url := deleteURL(c, containerName, objectName) - - if opts != nil { - query, err := opts.ToObjectDeleteQuery() - if err != nil { - res.Err = err - return res - } - url += query - } - - resp, err := c.Delete(url, nil) - res.Header = resp.Header - res.Err = err - return res -} - -// GetOptsBuilder allows extensions to add additional parameters to the -// Get request. -type GetOptsBuilder interface { - ToObjectGetQuery() (string, error) -} - -// GetOpts is a structure that holds parameters for getting an object's metadata. -type GetOpts struct { - Expires string `q:"expires"` - Signature string `q:"signature"` -} - -// ToObjectGetQuery formats a GetOpts into a query string. -func (opts GetOpts) ToObjectGetQuery() (string, error) { - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return "", err - } - return q.String(), nil -} - -// Get is a function that retrieves the metadata of an object. To extract just the custom -// metadata, pass the GetResult response to the ExtractMetadata function. -func Get(c *gophercloud.ServiceClient, containerName, objectName string, opts GetOptsBuilder) GetResult { - var res GetResult - url := getURL(c, containerName, objectName) - - if opts != nil { - query, err := opts.ToObjectGetQuery() - if err != nil { - res.Err = err - return res - } - url += query - } - - resp, err := c.Request("HEAD", url, gophercloud.RequestOpts{ - OkCodes: []int{200, 204}, - }) - res.Header = resp.Header - res.Err = err - return res -} - -// UpdateOptsBuilder allows extensions to add additional parameters to the -// Update request. -type UpdateOptsBuilder interface { - ToObjectUpdateMap() (map[string]string, error) -} - -// UpdateOpts is a structure that holds parameters for updating, creating, or deleting an -// object's metadata. -type UpdateOpts struct { - Metadata map[string]string - ContentDisposition string `h:"Content-Disposition"` - ContentEncoding string `h:"Content-Encoding"` - ContentType string `h:"Content-Type"` - DeleteAfter int `h:"X-Delete-After"` - DeleteAt int `h:"X-Delete-At"` - DetectContentType bool `h:"X-Detect-Content-Type"` -} - -// ToObjectUpdateMap formats a UpdateOpts into a map of headers. -func (opts UpdateOpts) ToObjectUpdateMap() (map[string]string, error) { - h, err := gophercloud.BuildHeaders(opts) - if err != nil { - return nil, err - } - for k, v := range opts.Metadata { - h["X-Object-Meta-"+k] = v - } - return h, nil -} - -// Update is a function that creates, updates, or deletes an object's metadata. -func Update(c *gophercloud.ServiceClient, containerName, objectName string, opts UpdateOptsBuilder) UpdateResult { - var res UpdateResult - h := c.AuthenticatedHeaders() - - if opts != nil { - headers, err := opts.ToObjectUpdateMap() - if err != nil { - res.Err = err - return res - } - - for k, v := range headers { - h[k] = v - } - } - - url := updateURL(c, containerName, objectName) - resp, err := c.Request("POST", url, gophercloud.RequestOpts{ - MoreHeaders: h, - }) - res.Header = resp.Header - res.Err = err - return res -} - -// HTTPMethod represents an HTTP method string (e.g. "GET"). -type HTTPMethod string - -var ( - // GET represents an HTTP "GET" method. - GET HTTPMethod = "GET" - // POST represents an HTTP "POST" method. - POST HTTPMethod = "POST" -) - -// CreateTempURLOpts are options for creating a temporary URL for an object. -type CreateTempURLOpts struct { - // (REQUIRED) Method is the HTTP method to allow for users of the temp URL. Valid values - // are "GET" and "POST". - Method HTTPMethod - // (REQUIRED) TTL is the number of seconds the temp URL should be active. - TTL int - // (Optional) Split is the string on which to split the object URL. Since only - // the object path is used in the hash, the object URL needs to be parsed. If - // empty, the default OpenStack URL split point will be used ("/v1/"). - Split string -} - -// CreateTempURL is a function for creating a temporary URL for an object. It -// allows users to have "GET" or "POST" access to a particular tenant's object -// for a limited amount of time. -func CreateTempURL(c *gophercloud.ServiceClient, containerName, objectName string, opts CreateTempURLOpts) (string, error) { - if opts.Split == "" { - opts.Split = "/v1/" - } - duration := time.Duration(opts.TTL) * time.Second - expiry := time.Now().Add(duration).Unix() - getHeader, err := accounts.Get(c, nil).Extract() - if err != nil { - return "", err - } - secretKey := []byte(getHeader.TempURLKey) - url := getURL(c, containerName, objectName) - splitPath := strings.Split(url, opts.Split) - baseURL, objectPath := splitPath[0], splitPath[1] - objectPath = opts.Split + objectPath - body := fmt.Sprintf("%s\n%d\n%s", opts.Method, expiry, objectPath) - hash := hmac.New(sha1.New, secretKey) - hash.Write([]byte(body)) - hexsum := fmt.Sprintf("%x", hash.Sum(nil)) - return fmt.Sprintf("%s%s?temp_url_sig=%s&temp_url_expires=%d", baseURL, objectPath, hexsum, expiry), nil -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects/results.go b/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects/results.go deleted file mode 100644 index ecb2c54582..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects/results.go +++ /dev/null @@ -1,438 +0,0 @@ -package objects - -import ( - "fmt" - "io" - "io/ioutil" - "strconv" - "strings" - "time" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" - - "github.com/mitchellh/mapstructure" -) - -// Object is a structure that holds information related to a storage object. -type Object struct { - // Bytes is the total number of bytes that comprise the object. - Bytes int64 `json:"bytes" mapstructure:"bytes"` - - // ContentType is the content type of the object. - ContentType string `json:"content_type" mapstructure:"content_type"` - - // Hash represents the MD5 checksum value of the object's content. - Hash string `json:"hash" mapstructure:"hash"` - - // LastModified is the RFC3339Milli time the object was last modified, represented - // as a string. For any given object (obj), this value may be parsed to a time.Time: - // lastModified, err := time.Parse(gophercloud.RFC3339Milli, obj.LastModified) - LastModified string `json:"last_modified" mapstructure:"last_modified"` - - // Name is the unique name for the object. - Name string `json:"name" mapstructure:"name"` -} - -// ObjectPage is a single page of objects that is returned from a call to the -// List function. -type ObjectPage struct { - pagination.MarkerPageBase -} - -// IsEmpty returns true if a ListResult contains no object names. -func (r ObjectPage) IsEmpty() (bool, error) { - names, err := ExtractNames(r) - if err != nil { - return true, err - } - return len(names) == 0, nil -} - -// LastMarker returns the last object name in a ListResult. -func (r ObjectPage) LastMarker() (string, error) { - names, err := ExtractNames(r) - if err != nil { - return "", err - } - if len(names) == 0 { - return "", nil - } - return names[len(names)-1], nil -} - -// ExtractInfo is a function that takes a page of objects and returns their full information. -func ExtractInfo(page pagination.Page) ([]Object, error) { - untyped := page.(ObjectPage).Body.([]interface{}) - results := make([]Object, len(untyped)) - for index, each := range untyped { - object := each.(map[string]interface{}) - err := mapstructure.Decode(object, &results[index]) - if err != nil { - return results, err - } - } - return results, nil -} - -// ExtractNames is a function that takes a page of objects and returns only their names. -func ExtractNames(page pagination.Page) ([]string, error) { - casted := page.(ObjectPage) - ct := casted.Header.Get("Content-Type") - switch { - case strings.HasPrefix(ct, "application/json"): - parsed, err := ExtractInfo(page) - if err != nil { - return nil, err - } - - names := make([]string, 0, len(parsed)) - for _, object := range parsed { - names = append(names, object.Name) - } - - return names, nil - case strings.HasPrefix(ct, "text/plain"): - names := make([]string, 0, 50) - - body := string(page.(ObjectPage).Body.([]uint8)) - for _, name := range strings.Split(body, "\n") { - if len(name) > 0 { - names = append(names, name) - } - } - - return names, nil - case strings.HasPrefix(ct, "text/html"): - return []string{}, nil - default: - return nil, fmt.Errorf("Cannot extract names from response with content-type: [%s]", ct) - } -} - -// DownloadHeader represents the headers returned in the response from a Download request. -type DownloadHeader struct { - AcceptRanges string `mapstructure:"Accept-Ranges"` - ContentDisposition string `mapstructure:"Content-Disposition"` - ContentEncoding string `mapstructure:"Content-Encoding"` - ContentLength int64 `mapstructure:"Content-Length"` - ContentType string `mapstructure:"Content-Type"` - Date time.Time `mapstructure:"-"` - DeleteAt time.Time `mapstructure:"-"` - ETag string `mapstructure:"Etag"` - LastModified time.Time `mapstructure:"-"` - ObjectManifest string `mapstructure:"X-Object-Manifest"` - StaticLargeObject bool `mapstructure:"X-Static-Large-Object"` - TransID string `mapstructure:"X-Trans-Id"` -} - -// DownloadResult is a *http.Response that is returned from a call to the Download function. -type DownloadResult struct { - gophercloud.HeaderResult - Body io.ReadCloser -} - -// Extract will return a struct of headers returned from a call to Download. To obtain -// a map of headers, call the ExtractHeader method on the DownloadResult. -func (dr DownloadResult) Extract() (DownloadHeader, error) { - var dh DownloadHeader - if dr.Err != nil { - return dh, dr.Err - } - - if err := gophercloud.DecodeHeader(dr.Header, &dh); err != nil { - return dh, err - } - - if date, ok := dr.Header["Date"]; ok && len(date) > 0 { - t, err := time.Parse(time.RFC1123, date[0]) - if err != nil { - return dh, err - } - dh.Date = t - } - - if date, ok := dr.Header["Last-Modified"]; ok && len(date) > 0 { - t, err := time.Parse(time.RFC1123, date[0]) - if err != nil { - return dh, err - } - dh.LastModified = t - } - - if date, ok := dr.Header["X-Delete-At"]; ok && len(date) > 0 { - unix, err := strconv.ParseInt(date[0], 10, 64) - if err != nil { - return dh, err - } - dh.DeleteAt = time.Unix(unix, 0) - } - - return dh, nil -} - -// ExtractContent is a function that takes a DownloadResult's io.Reader body -// and reads all available data into a slice of bytes. Please be aware that due -// the nature of io.Reader is forward-only - meaning that it can only be read -// once and not rewound. You can recreate a reader from the output of this -// function by using bytes.NewReader(downloadBytes) -func (dr DownloadResult) ExtractContent() ([]byte, error) { - if dr.Err != nil { - return nil, dr.Err - } - body, err := ioutil.ReadAll(dr.Body) - if err != nil { - return nil, err - } - dr.Body.Close() - return body, nil -} - -// GetHeader represents the headers returned in the response from a Get request. -type GetHeader struct { - ContentDisposition string `mapstructure:"Content-Disposition"` - ContentEncoding string `mapstructure:"Content-Encoding"` - ContentLength int64 `mapstructure:"Content-Length"` - ContentType string `mapstructure:"Content-Type"` - Date time.Time `mapstructure:"-"` - DeleteAt time.Time `mapstructure:"-"` - ETag string `mapstructure:"Etag"` - LastModified time.Time `mapstructure:"-"` - ObjectManifest string `mapstructure:"X-Object-Manifest"` - StaticLargeObject bool `mapstructure:"X-Static-Large-Object"` - TransID string `mapstructure:"X-Trans-Id"` -} - -// GetResult is a *http.Response that is returned from a call to the Get function. -type GetResult struct { - gophercloud.HeaderResult -} - -// Extract will return a struct of headers returned from a call to Get. To obtain -// a map of headers, call the ExtractHeader method on the GetResult. -func (gr GetResult) Extract() (GetHeader, error) { - var gh GetHeader - if gr.Err != nil { - return gh, gr.Err - } - - if err := gophercloud.DecodeHeader(gr.Header, &gh); err != nil { - return gh, err - } - - if date, ok := gr.Header["Date"]; ok && len(date) > 0 { - t, err := time.Parse(time.RFC1123, gr.Header["Date"][0]) - if err != nil { - return gh, err - } - gh.Date = t - } - - if date, ok := gr.Header["Last-Modified"]; ok && len(date) > 0 { - t, err := time.Parse(time.RFC1123, gr.Header["Last-Modified"][0]) - if err != nil { - return gh, err - } - gh.LastModified = t - } - - if date, ok := gr.Header["X-Delete-At"]; ok && len(date) > 0 { - unix, err := strconv.ParseInt(date[0], 10, 64) - if err != nil { - return gh, err - } - gh.DeleteAt = time.Unix(unix, 0) - } - - return gh, nil -} - -// ExtractMetadata is a function that takes a GetResult (of type *http.Response) -// and returns the custom metadata associated with the object. -func (gr GetResult) ExtractMetadata() (map[string]string, error) { - if gr.Err != nil { - return nil, gr.Err - } - metadata := make(map[string]string) - for k, v := range gr.Header { - if strings.HasPrefix(k, "X-Object-Meta-") { - key := strings.TrimPrefix(k, "X-Object-Meta-") - metadata[key] = v[0] - } - } - return metadata, nil -} - -// CreateHeader represents the headers returned in the response from a Create request. -type CreateHeader struct { - ContentLength int64 `mapstructure:"Content-Length"` - ContentType string `mapstructure:"Content-Type"` - Date time.Time `mapstructure:"-"` - ETag string `mapstructure:"Etag"` - LastModified time.Time `mapstructure:"-"` - TransID string `mapstructure:"X-Trans-Id"` -} - -// CreateResult represents the result of a create operation. -type CreateResult struct { - gophercloud.HeaderResult -} - -// Extract will return a struct of headers returned from a call to Create. To obtain -// a map of headers, call the ExtractHeader method on the CreateResult. -func (cr CreateResult) Extract() (CreateHeader, error) { - var ch CreateHeader - if cr.Err != nil { - return ch, cr.Err - } - - if err := gophercloud.DecodeHeader(cr.Header, &ch); err != nil { - return ch, err - } - - if date, ok := cr.Header["Date"]; ok && len(date) > 0 { - t, err := time.Parse(time.RFC1123, cr.Header["Date"][0]) - if err != nil { - return ch, err - } - ch.Date = t - } - - if date, ok := cr.Header["Last-Modified"]; ok && len(date) > 0 { - t, err := time.Parse(time.RFC1123, cr.Header["Last-Modified"][0]) - if err != nil { - return ch, err - } - ch.LastModified = t - } - - return ch, nil -} - -// UpdateHeader represents the headers returned in the response from a Update request. -type UpdateHeader struct { - ContentLength int64 `mapstructure:"Content-Length"` - ContentType string `mapstructure:"Content-Type"` - Date time.Time `mapstructure:"-"` - TransID string `mapstructure:"X-Trans-Id"` -} - -// UpdateResult represents the result of an update operation. -type UpdateResult struct { - gophercloud.HeaderResult -} - -// Extract will return a struct of headers returned from a call to Update. To obtain -// a map of headers, call the ExtractHeader method on the UpdateResult. -func (ur UpdateResult) Extract() (UpdateHeader, error) { - var uh UpdateHeader - if ur.Err != nil { - return uh, ur.Err - } - - if err := gophercloud.DecodeHeader(ur.Header, &uh); err != nil { - return uh, err - } - - if date, ok := ur.Header["Date"]; ok && len(date) > 0 { - t, err := time.Parse(time.RFC1123, ur.Header["Date"][0]) - if err != nil { - return uh, err - } - uh.Date = t - } - - return uh, nil -} - -// DeleteHeader represents the headers returned in the response from a Delete request. -type DeleteHeader struct { - ContentLength int64 `mapstructure:"Content-Length"` - ContentType string `mapstructure:"Content-Type"` - Date time.Time `mapstructure:"-"` - TransID string `mapstructure:"X-Trans-Id"` -} - -// DeleteResult represents the result of a delete operation. -type DeleteResult struct { - gophercloud.HeaderResult -} - -// Extract will return a struct of headers returned from a call to Delete. To obtain -// a map of headers, call the ExtractHeader method on the DeleteResult. -func (dr DeleteResult) Extract() (DeleteHeader, error) { - var dh DeleteHeader - if dr.Err != nil { - return dh, dr.Err - } - - if err := gophercloud.DecodeHeader(dr.Header, &dh); err != nil { - return dh, err - } - - if date, ok := dr.Header["Date"]; ok && len(date) > 0 { - t, err := time.Parse(time.RFC1123, dr.Header["Date"][0]) - if err != nil { - return dh, err - } - dh.Date = t - } - - return dh, nil -} - -// CopyHeader represents the headers returned in the response from a Copy request. -type CopyHeader struct { - ContentLength int64 `mapstructure:"Content-Length"` - ContentType string `mapstructure:"Content-Type"` - CopiedFrom string `mapstructure:"X-Copied-From"` - CopiedFromLastModified time.Time `mapstructure:"-"` - Date time.Time `mapstructure:"-"` - ETag string `mapstructure:"Etag"` - LastModified time.Time `mapstructure:"-"` - TransID string `mapstructure:"X-Trans-Id"` -} - -// CopyResult represents the result of a copy operation. -type CopyResult struct { - gophercloud.HeaderResult -} - -// Extract will return a struct of headers returned from a call to Copy. To obtain -// a map of headers, call the ExtractHeader method on the CopyResult. -func (cr CopyResult) Extract() (CopyHeader, error) { - var ch CopyHeader - if cr.Err != nil { - return ch, cr.Err - } - - if err := gophercloud.DecodeHeader(cr.Header, &ch); err != nil { - return ch, err - } - - if date, ok := cr.Header["Date"]; ok && len(date) > 0 { - t, err := time.Parse(time.RFC1123, cr.Header["Date"][0]) - if err != nil { - return ch, err - } - ch.Date = t - } - - if date, ok := cr.Header["Last-Modified"]; ok && len(date) > 0 { - t, err := time.Parse(time.RFC1123, cr.Header["Last-Modified"][0]) - if err != nil { - return ch, err - } - ch.LastModified = t - } - - if date, ok := cr.Header["X-Copied-From-Last-Modified"]; ok && len(date) > 0 { - t, err := time.Parse(time.RFC1123, cr.Header["X-Copied-From-Last-Modified"][0]) - if err != nil { - return ch, err - } - ch.CopiedFromLastModified = t - } - - return ch, nil -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects/urls.go deleted file mode 100644 index d2ec62cff2..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects/urls.go +++ /dev/null @@ -1,33 +0,0 @@ -package objects - -import ( - "github.com/rackspace/gophercloud" -) - -func listURL(c *gophercloud.ServiceClient, container string) string { - return c.ServiceURL(container) -} - -func copyURL(c *gophercloud.ServiceClient, container, object string) string { - return c.ServiceURL(container, object) -} - -func createURL(c *gophercloud.ServiceClient, container, object string) string { - return copyURL(c, container, object) -} - -func getURL(c *gophercloud.ServiceClient, container, object string) string { - return copyURL(c, container, object) -} - -func deleteURL(c *gophercloud.ServiceClient, container, object string) string { - return copyURL(c, container, object) -} - -func downloadURL(c *gophercloud.ServiceClient, container, object string) string { - return copyURL(c, container, object) -} - -func updateURL(c *gophercloud.ServiceClient, container, object string) string { - return copyURL(c, container, object) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/apiversions/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/apiversions/doc.go deleted file mode 100644 index f2db622d1f..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/apiversions/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -// Package apiversions provides information and interaction with the different -// API versions for the OpenStack Heat service. This functionality is not -// restricted to this particular version. -package apiversions diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/apiversions/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/apiversions/requests.go deleted file mode 100644 index f6454c8609..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/apiversions/requests.go +++ /dev/null @@ -1,13 +0,0 @@ -package apiversions - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// ListVersions lists all the Neutron API versions available to end-users -func ListVersions(c *gophercloud.ServiceClient) pagination.Pager { - return pagination.NewPager(c, apiVersionsURL(c), func(r pagination.PageResult) pagination.Page { - return APIVersionPage{pagination.SinglePageBase(r)} - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/apiversions/results.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/apiversions/results.go deleted file mode 100644 index 0700ab0afb..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/apiversions/results.go +++ /dev/null @@ -1,42 +0,0 @@ -package apiversions - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// APIVersion represents an API version for Neutron. It contains the status of -// the API, and its unique ID. -type APIVersion struct { - Status string `mapstructure:"status"` - ID string `mapstructure:"id"` - Links []gophercloud.Link `mapstructure:"links"` -} - -// APIVersionPage is the page returned by a pager when traversing over a -// collection of API versions. -type APIVersionPage struct { - pagination.SinglePageBase -} - -// IsEmpty checks whether an APIVersionPage struct is empty. -func (r APIVersionPage) IsEmpty() (bool, error) { - is, err := ExtractAPIVersions(r) - if err != nil { - return true, err - } - return len(is) == 0, nil -} - -// ExtractAPIVersions takes a collection page, extracts all of the elements, -// and returns them a slice of APIVersion structs. It is effectively a cast. -func ExtractAPIVersions(page pagination.Page) ([]APIVersion, error) { - var resp struct { - Versions []APIVersion `mapstructure:"versions"` - } - - err := mapstructure.Decode(page.(APIVersionPage).Body, &resp) - - return resp.Versions, err -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/apiversions/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/apiversions/urls.go deleted file mode 100644 index 55d6e0e7a4..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/apiversions/urls.go +++ /dev/null @@ -1,7 +0,0 @@ -package apiversions - -import "github.com/rackspace/gophercloud" - -func apiVersionsURL(c *gophercloud.ServiceClient) string { - return c.Endpoint -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo/doc.go deleted file mode 100644 index 183e8dfa76..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo/doc.go +++ /dev/null @@ -1,2 +0,0 @@ -// Package buildinfo provides build information about heat deployments. -package buildinfo diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo/fixtures.go deleted file mode 100644 index 20ea09b442..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo/fixtures.go +++ /dev/null @@ -1,45 +0,0 @@ -package buildinfo - -import ( - "fmt" - "net/http" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -// GetExpected represents the expected object from a Get request. -var GetExpected = &BuildInfo{ - API: Revision{ - Revision: "2.4.5", - }, - Engine: Revision{ - Revision: "1.2.1", - }, -} - -// GetOutput represents the response body from a Get request. -const GetOutput = ` -{ - "api": { - "revision": "2.4.5" - }, - "engine": { - "revision": "1.2.1" - } -}` - -// HandleGetSuccessfully creates an HTTP handler at `/build_info` -// on the test handler mux that responds with a `Get` response. -func HandleGetSuccessfully(t *testing.T, output string) { - th.Mux.HandleFunc("/build_info", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, output) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo/requests.go deleted file mode 100644 index 9e03e5cc85..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo/requests.go +++ /dev/null @@ -1,10 +0,0 @@ -package buildinfo - -import "github.com/rackspace/gophercloud" - -// Get retreives data for the given stack template. -func Get(c *gophercloud.ServiceClient) GetResult { - var res GetResult - _, res.Err = c.Get(getURL(c), &res.Body, nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo/results.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo/results.go deleted file mode 100644 index 683a434a05..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo/results.go +++ /dev/null @@ -1,37 +0,0 @@ -package buildinfo - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" -) - -// Revision represents the API/Engine revision of a Heat deployment. -type Revision struct { - Revision string `mapstructure:"revision"` -} - -// BuildInfo represents the build information for a Heat deployment. -type BuildInfo struct { - API Revision `mapstructure:"api"` - Engine Revision `mapstructure:"engine"` -} - -// GetResult represents the result of a Get operation. -type GetResult struct { - gophercloud.Result -} - -// Extract returns a pointer to a BuildInfo object and is called after a -// Get operation. -func (r GetResult) Extract() (*BuildInfo, error) { - if r.Err != nil { - return nil, r.Err - } - - var res BuildInfo - if err := mapstructure.Decode(r.Body, &res); err != nil { - return nil, err - } - - return &res, nil -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo/urls.go deleted file mode 100644 index 2c873d0235..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo/urls.go +++ /dev/null @@ -1,7 +0,0 @@ -package buildinfo - -import "github.com/rackspace/gophercloud" - -func getURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL("build_info") -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackevents/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackevents/doc.go deleted file mode 100644 index 51cdd97473..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackevents/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -// Package stackevents provides operations for finding, listing, and retrieving -// stack events. Stack events are events that take place on stacks such as -// updating and abandoning. -package stackevents diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackevents/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackevents/fixtures.go deleted file mode 100644 index 016ae003b3..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackevents/fixtures.go +++ /dev/null @@ -1,446 +0,0 @@ -package stackevents - -import ( - "fmt" - "net/http" - "testing" - "time" - - "github.com/rackspace/gophercloud" - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -// FindExpected represents the expected object from a Find request. -var FindExpected = []Event{ - Event{ - ResourceName: "hello_world", - Time: time.Date(2015, 2, 5, 21, 33, 11, 0, time.UTC), - Links: []gophercloud.Link{ - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/06feb26f-9298-4a9b-8749-9d770e5d577a", - Rel: "self", - }, - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", - Rel: "resource", - }, - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", - Rel: "stack", - }, - }, - LogicalResourceID: "hello_world", - ResourceStatusReason: "state changed", - ResourceStatus: "CREATE_IN_PROGRESS", - PhysicalResourceID: "", - ID: "06feb26f-9298-4a9b-8749-9d770e5d577a", - }, - Event{ - ResourceName: "hello_world", - Time: time.Date(2015, 2, 5, 21, 33, 27, 0, time.UTC), - Links: []gophercloud.Link{ - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/93940999-7d40-44ae-8de4-19624e7b8d18", - Rel: "self", - }, - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", - Rel: "resource", - }, - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", - Rel: "stack", - }, - }, - LogicalResourceID: "hello_world", - ResourceStatusReason: "state changed", - ResourceStatus: "CREATE_COMPLETE", - PhysicalResourceID: "49181cd6-169a-4130-9455-31185bbfc5bf", - ID: "93940999-7d40-44ae-8de4-19624e7b8d18", - }, -} - -// FindOutput represents the response body from a Find request. -const FindOutput = ` -{ - "events": [ - { - "resource_name": "hello_world", - "event_time": "2015-02-05T21:33:11Z", - "links": [ - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/06feb26f-9298-4a9b-8749-9d770e5d577a", - "rel": "self" - }, - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", - "rel": "resource" - }, - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", - "rel": "stack" - } - ], - "logical_resource_id": "hello_world", - "resource_status_reason": "state changed", - "resource_status": "CREATE_IN_PROGRESS", - "physical_resource_id": null, - "id": "06feb26f-9298-4a9b-8749-9d770e5d577a" - }, - { - "resource_name": "hello_world", - "event_time": "2015-02-05T21:33:27Z", - "links": [ - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/93940999-7d40-44ae-8de4-19624e7b8d18", - "rel": "self" - }, - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", - "rel": "resource" - }, - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", - "rel": "stack" - } - ], - "logical_resource_id": "hello_world", - "resource_status_reason": "state changed", - "resource_status": "CREATE_COMPLETE", - "physical_resource_id": "49181cd6-169a-4130-9455-31185bbfc5bf", - "id": "93940999-7d40-44ae-8de4-19624e7b8d18" - } - ] -}` - -// HandleFindSuccessfully creates an HTTP handler at `/stacks/postman_stack/events` -// on the test handler mux that responds with a `Find` response. -func HandleFindSuccessfully(t *testing.T, output string) { - th.Mux.HandleFunc("/stacks/postman_stack/events", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, output) - }) -} - -// ListExpected represents the expected object from a List request. -var ListExpected = []Event{ - Event{ - ResourceName: "hello_world", - Time: time.Date(2015, 2, 5, 21, 33, 11, 0, time.UTC), - Links: []gophercloud.Link{ - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/06feb26f-9298-4a9b-8749-9d770e5d577a", - Rel: "self", - }, - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", - Rel: "resource", - }, - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", - Rel: "stack", - }, - }, - LogicalResourceID: "hello_world", - ResourceStatusReason: "state changed", - ResourceStatus: "CREATE_IN_PROGRESS", - PhysicalResourceID: "", - ID: "06feb26f-9298-4a9b-8749-9d770e5d577a", - }, - Event{ - ResourceName: "hello_world", - Time: time.Date(2015, 2, 5, 21, 33, 27, 0, time.UTC), - Links: []gophercloud.Link{ - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/93940999-7d40-44ae-8de4-19624e7b8d18", - Rel: "self", - }, - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", - Rel: "resource", - }, - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", - Rel: "stack", - }, - }, - LogicalResourceID: "hello_world", - ResourceStatusReason: "state changed", - ResourceStatus: "CREATE_COMPLETE", - PhysicalResourceID: "49181cd6-169a-4130-9455-31185bbfc5bf", - ID: "93940999-7d40-44ae-8de4-19624e7b8d18", - }, -} - -// ListOutput represents the response body from a List request. -const ListOutput = ` -{ - "events": [ - { - "resource_name": "hello_world", - "event_time": "2015-02-05T21:33:11Z", - "links": [ - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/06feb26f-9298-4a9b-8749-9d770e5d577a", - "rel": "self" - }, - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", - "rel": "resource" - }, - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", - "rel": "stack" - } - ], - "logical_resource_id": "hello_world", - "resource_status_reason": "state changed", - "resource_status": "CREATE_IN_PROGRESS", - "physical_resource_id": null, - "id": "06feb26f-9298-4a9b-8749-9d770e5d577a" - }, - { - "resource_name": "hello_world", - "event_time": "2015-02-05T21:33:27Z", - "links": [ - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/93940999-7d40-44ae-8de4-19624e7b8d18", - "rel": "self" - }, - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", - "rel": "resource" - }, - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", - "rel": "stack" - } - ], - "logical_resource_id": "hello_world", - "resource_status_reason": "state changed", - "resource_status": "CREATE_COMPLETE", - "physical_resource_id": "49181cd6-169a-4130-9455-31185bbfc5bf", - "id": "93940999-7d40-44ae-8de4-19624e7b8d18" - } - ] -}` - -// HandleListSuccessfully creates an HTTP handler at `/stacks/hello_world/49181cd6-169a-4130-9455-31185bbfc5bf/events` -// on the test handler mux that responds with a `List` response. -func HandleListSuccessfully(t *testing.T, output string) { - th.Mux.HandleFunc("/stacks/hello_world/49181cd6-169a-4130-9455-31185bbfc5bf/events", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - w.Header().Set("Content-Type", "application/json") - r.ParseForm() - marker := r.Form.Get("marker") - switch marker { - case "": - fmt.Fprintf(w, output) - case "93940999-7d40-44ae-8de4-19624e7b8d18": - fmt.Fprintf(w, `{"events":[]}`) - default: - t.Fatalf("Unexpected marker: [%s]", marker) - } - }) -} - -// ListResourceEventsExpected represents the expected object from a ListResourceEvents request. -var ListResourceEventsExpected = []Event{ - Event{ - ResourceName: "hello_world", - Time: time.Date(2015, 2, 5, 21, 33, 11, 0, time.UTC), - Links: []gophercloud.Link{ - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/06feb26f-9298-4a9b-8749-9d770e5d577a", - Rel: "self", - }, - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", - Rel: "resource", - }, - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", - Rel: "stack", - }, - }, - LogicalResourceID: "hello_world", - ResourceStatusReason: "state changed", - ResourceStatus: "CREATE_IN_PROGRESS", - PhysicalResourceID: "", - ID: "06feb26f-9298-4a9b-8749-9d770e5d577a", - }, - Event{ - ResourceName: "hello_world", - Time: time.Date(2015, 2, 5, 21, 33, 27, 0, time.UTC), - Links: []gophercloud.Link{ - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/93940999-7d40-44ae-8de4-19624e7b8d18", - Rel: "self", - }, - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", - Rel: "resource", - }, - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", - Rel: "stack", - }, - }, - LogicalResourceID: "hello_world", - ResourceStatusReason: "state changed", - ResourceStatus: "CREATE_COMPLETE", - PhysicalResourceID: "49181cd6-169a-4130-9455-31185bbfc5bf", - ID: "93940999-7d40-44ae-8de4-19624e7b8d18", - }, -} - -// ListResourceEventsOutput represents the response body from a ListResourceEvents request. -const ListResourceEventsOutput = ` -{ - "events": [ - { - "resource_name": "hello_world", - "event_time": "2015-02-05T21:33:11Z", - "links": [ - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/06feb26f-9298-4a9b-8749-9d770e5d577a", - "rel": "self" - }, - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", - "rel": "resource" - }, - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", - "rel": "stack" - } - ], - "logical_resource_id": "hello_world", - "resource_status_reason": "state changed", - "resource_status": "CREATE_IN_PROGRESS", - "physical_resource_id": null, - "id": "06feb26f-9298-4a9b-8749-9d770e5d577a" - }, - { - "resource_name": "hello_world", - "event_time": "2015-02-05T21:33:27Z", - "links": [ - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/93940999-7d40-44ae-8de4-19624e7b8d18", - "rel": "self" - }, - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", - "rel": "resource" - }, - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", - "rel": "stack" - } - ], - "logical_resource_id": "hello_world", - "resource_status_reason": "state changed", - "resource_status": "CREATE_COMPLETE", - "physical_resource_id": "49181cd6-169a-4130-9455-31185bbfc5bf", - "id": "93940999-7d40-44ae-8de4-19624e7b8d18" - } - ] -}` - -// HandleListResourceEventsSuccessfully creates an HTTP handler at `/stacks/hello_world/49181cd6-169a-4130-9455-31185bbfc5bf/resources/my_resource/events` -// on the test handler mux that responds with a `ListResourceEvents` response. -func HandleListResourceEventsSuccessfully(t *testing.T, output string) { - th.Mux.HandleFunc("/stacks/hello_world/49181cd6-169a-4130-9455-31185bbfc5bf/resources/my_resource/events", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - w.Header().Set("Content-Type", "application/json") - r.ParseForm() - marker := r.Form.Get("marker") - switch marker { - case "": - fmt.Fprintf(w, output) - case "93940999-7d40-44ae-8de4-19624e7b8d18": - fmt.Fprintf(w, `{"events":[]}`) - default: - t.Fatalf("Unexpected marker: [%s]", marker) - } - }) -} - -// GetExpected represents the expected object from a Get request. -var GetExpected = &Event{ - ResourceName: "hello_world", - Time: time.Date(2015, 2, 5, 21, 33, 27, 0, time.UTC), - Links: []gophercloud.Link{ - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/93940999-7d40-44ae-8de4-19624e7b8d18", - Rel: "self", - }, - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", - Rel: "resource", - }, - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", - Rel: "stack", - }, - }, - LogicalResourceID: "hello_world", - ResourceStatusReason: "state changed", - ResourceStatus: "CREATE_COMPLETE", - PhysicalResourceID: "49181cd6-169a-4130-9455-31185bbfc5bf", - ID: "93940999-7d40-44ae-8de4-19624e7b8d18", -} - -// GetOutput represents the response body from a Get request. -const GetOutput = ` -{ - "event":{ - "resource_name": "hello_world", - "event_time": "2015-02-05T21:33:27Z", - "links": [ - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/93940999-7d40-44ae-8de4-19624e7b8d18", - "rel": "self" - }, - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", - "rel": "resource" - }, - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", - "rel": "stack" - } - ], - "logical_resource_id": "hello_world", - "resource_status_reason": "state changed", - "resource_status": "CREATE_COMPLETE", - "physical_resource_id": "49181cd6-169a-4130-9455-31185bbfc5bf", - "id": "93940999-7d40-44ae-8de4-19624e7b8d18" - } -}` - -// HandleGetSuccessfully creates an HTTP handler at `/stacks/hello_world/49181cd6-169a-4130-9455-31185bbfc5bf/resources/my_resource/events/93940999-7d40-44ae-8de4-19624e7b8d18` -// on the test handler mux that responds with a `Get` response. -func HandleGetSuccessfully(t *testing.T, output string) { - th.Mux.HandleFunc("/stacks/hello_world/49181cd6-169a-4130-9455-31185bbfc5bf/resources/my_resource/events/93940999-7d40-44ae-8de4-19624e7b8d18", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, output) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackevents/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackevents/requests.go deleted file mode 100644 index 53c3916020..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackevents/requests.go +++ /dev/null @@ -1,203 +0,0 @@ -package stackevents - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// Find retrieves stack events for the given stack name. -func Find(c *gophercloud.ServiceClient, stackName string) FindResult { - var res FindResult - - _, res.Err = c.Request("GET", findURL(c, stackName), gophercloud.RequestOpts{ - JSONResponse: &res.Body, - }) - return res -} - -// SortDir is a type for specifying in which direction to sort a list of events. -type SortDir string - -// SortKey is a type for specifying by which key to sort a list of events. -type SortKey string - -// ResourceStatus is a type for specifying by which resource status to filter a -// list of events. -type ResourceStatus string - -// ResourceAction is a type for specifying by which resource action to filter a -// list of events. -type ResourceAction string - -var ( - // ResourceStatusInProgress is used to filter a List request by the 'IN_PROGRESS' status. - ResourceStatusInProgress ResourceStatus = "IN_PROGRESS" - // ResourceStatusComplete is used to filter a List request by the 'COMPLETE' status. - ResourceStatusComplete ResourceStatus = "COMPLETE" - // ResourceStatusFailed is used to filter a List request by the 'FAILED' status. - ResourceStatusFailed ResourceStatus = "FAILED" - - // ResourceActionCreate is used to filter a List request by the 'CREATE' action. - ResourceActionCreate ResourceAction = "CREATE" - // ResourceActionDelete is used to filter a List request by the 'DELETE' action. - ResourceActionDelete ResourceAction = "DELETE" - // ResourceActionUpdate is used to filter a List request by the 'UPDATE' action. - ResourceActionUpdate ResourceAction = "UPDATE" - // ResourceActionRollback is used to filter a List request by the 'ROLLBACK' action. - ResourceActionRollback ResourceAction = "ROLLBACK" - // ResourceActionSuspend is used to filter a List request by the 'SUSPEND' action. - ResourceActionSuspend ResourceAction = "SUSPEND" - // ResourceActionResume is used to filter a List request by the 'RESUME' action. - ResourceActionResume ResourceAction = "RESUME" - // ResourceActionAbandon is used to filter a List request by the 'ABANDON' action. - ResourceActionAbandon ResourceAction = "ABANDON" - - // SortAsc is used to sort a list of stacks in ascending order. - SortAsc SortDir = "asc" - // SortDesc is used to sort a list of stacks in descending order. - SortDesc SortDir = "desc" - - // SortName is used to sort a list of stacks by name. - SortName SortKey = "name" - // SortResourceType is used to sort a list of stacks by resource type. - SortResourceType SortKey = "resource_type" - // SortCreatedAt is used to sort a list of stacks by date created. - SortCreatedAt SortKey = "created_at" -) - -// ListOptsBuilder allows extensions to add additional parameters to the -// List request. -type ListOptsBuilder interface { - ToStackEventListQuery() (string, error) -} - -// ListOpts allows the filtering and sorting of paginated collections through -// the API. Marker and Limit are used for pagination. -type ListOpts struct { - // The stack resource ID with which to start the listing. - Marker string `q:"marker"` - // Integer value for the limit of values to return. - Limit int `q:"limit"` - // Filters the event list by the specified ResourceAction. You can use this - // filter multiple times to filter by multiple resource actions: CREATE, DELETE, - // UPDATE, ROLLBACK, SUSPEND, RESUME or ADOPT. - ResourceActions []ResourceAction `q:"resource_action"` - // Filters the event list by the specified resource_status. You can use this - // filter multiple times to filter by multiple resource statuses: IN_PROGRESS, - // COMPLETE or FAILED. - ResourceStatuses []ResourceStatus `q:"resource_status"` - // Filters the event list by the specified resource_name. You can use this - // filter multiple times to filter by multiple resource names. - ResourceNames []string `q:"resource_name"` - // Filters the event list by the specified resource_type. You can use this - // filter multiple times to filter by multiple resource types: OS::Nova::Server, - // OS::Cinder::Volume, and so on. - ResourceTypes []string `q:"resource_type"` - // Sorts the event list by: resource_type or created_at. - SortKey SortKey `q:"sort_keys"` - // The sort direction of the event list. Which is asc (ascending) or desc (descending). - SortDir SortDir `q:"sort_dir"` -} - -// ToStackEventListQuery formats a ListOpts into a query string. -func (opts ListOpts) ToStackEventListQuery() (string, error) { - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return "", err - } - return q.String(), nil -} - -// List makes a request against the API to list resources for the given stack. -func List(client *gophercloud.ServiceClient, stackName, stackID string, opts ListOptsBuilder) pagination.Pager { - url := listURL(client, stackName, stackID) - - if opts != nil { - query, err := opts.ToStackEventListQuery() - if err != nil { - return pagination.Pager{Err: err} - } - url += query - } - - createPageFn := func(r pagination.PageResult) pagination.Page { - p := EventPage{pagination.MarkerPageBase{PageResult: r}} - p.MarkerPageBase.Owner = p - return p - } - - return pagination.NewPager(client, url, createPageFn) -} - -// ListResourceEventsOptsBuilder allows extensions to add additional parameters to the -// ListResourceEvents request. -type ListResourceEventsOptsBuilder interface { - ToResourceEventListQuery() (string, error) -} - -// ListResourceEventsOpts allows the filtering and sorting of paginated resource events through -// the API. Marker and Limit are used for pagination. -type ListResourceEventsOpts struct { - // The stack resource ID with which to start the listing. - Marker string `q:"marker"` - // Integer value for the limit of values to return. - Limit int `q:"limit"` - // Filters the event list by the specified ResourceAction. You can use this - // filter multiple times to filter by multiple resource actions: CREATE, DELETE, - // UPDATE, ROLLBACK, SUSPEND, RESUME or ADOPT. - ResourceActions []string `q:"resource_action"` - // Filters the event list by the specified resource_status. You can use this - // filter multiple times to filter by multiple resource statuses: IN_PROGRESS, - // COMPLETE or FAILED. - ResourceStatuses []string `q:"resource_status"` - // Filters the event list by the specified resource_name. You can use this - // filter multiple times to filter by multiple resource names. - ResourceNames []string `q:"resource_name"` - // Filters the event list by the specified resource_type. You can use this - // filter multiple times to filter by multiple resource types: OS::Nova::Server, - // OS::Cinder::Volume, and so on. - ResourceTypes []string `q:"resource_type"` - // Sorts the event list by: resource_type or created_at. - SortKey SortKey `q:"sort_keys"` - // The sort direction of the event list. Which is asc (ascending) or desc (descending). - SortDir SortDir `q:"sort_dir"` -} - -// ToResourceEventsListQuery formats a ListOpts into a query string. -func (opts ListOpts) ToResourceEventsListQuery() (string, error) { - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return "", err - } - return q.String(), nil -} - -// ListResourceEvents makes a request against the API to list resources for the given stack. -func ListResourceEvents(client *gophercloud.ServiceClient, stackName, stackID, resourceName string, opts ListResourceEventsOptsBuilder) pagination.Pager { - url := listResourceEventsURL(client, stackName, stackID, resourceName) - - if opts != nil { - query, err := opts.ToResourceEventListQuery() - if err != nil { - return pagination.Pager{Err: err} - } - url += query - } - - createPageFn := func(r pagination.PageResult) pagination.Page { - p := EventPage{pagination.MarkerPageBase{PageResult: r}} - p.MarkerPageBase.Owner = p - return p - } - - return pagination.NewPager(client, url, createPageFn) -} - -// Get retreives data for the given stack resource. -func Get(c *gophercloud.ServiceClient, stackName, stackID, resourceName, eventID string) GetResult { - var res GetResult - _, res.Err = c.Get(getURL(c, stackName, stackID, resourceName, eventID), &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackevents/results.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackevents/results.go deleted file mode 100644 index 3c8f1da491..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackevents/results.go +++ /dev/null @@ -1,172 +0,0 @@ -package stackevents - -import ( - "fmt" - "reflect" - "time" - - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// Event represents a stack event. -type Event struct { - // The name of the resource for which the event occurred. - ResourceName string `mapstructure:"resource_name"` - // The time the event occurred. - Time time.Time `mapstructure:"-"` - // The URLs to the event. - Links []gophercloud.Link `mapstructure:"links"` - // The logical ID of the stack resource. - LogicalResourceID string `mapstructure:"logical_resource_id"` - // The reason of the status of the event. - ResourceStatusReason string `mapstructure:"resource_status_reason"` - // The status of the event. - ResourceStatus string `mapstructure:"resource_status"` - // The physical ID of the stack resource. - PhysicalResourceID string `mapstructure:"physical_resource_id"` - // The event ID. - ID string `mapstructure:"id"` - // Properties of the stack resource. - ResourceProperties map[string]interface{} `mapstructure:"resource_properties"` -} - -// FindResult represents the result of a Find operation. -type FindResult struct { - gophercloud.Result -} - -// Extract returns a slice of Event objects and is called after a -// Find operation. -func (r FindResult) Extract() ([]Event, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Res []Event `mapstructure:"events"` - } - - if err := mapstructure.Decode(r.Body, &res); err != nil { - return nil, err - } - - events := r.Body.(map[string]interface{})["events"].([]interface{}) - - for i, eventRaw := range events { - event := eventRaw.(map[string]interface{}) - if date, ok := event["event_time"]; ok && date != nil { - t, err := time.Parse(time.RFC3339, date.(string)) - if err != nil { - return nil, err - } - res.Res[i].Time = t - } - } - - return res.Res, nil -} - -// EventPage abstracts the raw results of making a List() request against the API. -// As OpenStack extensions may freely alter the response bodies of structures returned to the client, you may only safely access the -// data provided through the ExtractResources call. -type EventPage struct { - pagination.MarkerPageBase -} - -// IsEmpty returns true if a page contains no Server results. -func (r EventPage) IsEmpty() (bool, error) { - events, err := ExtractEvents(r) - if err != nil { - return true, err - } - return len(events) == 0, nil -} - -// LastMarker returns the last stack ID in a ListResult. -func (r EventPage) LastMarker() (string, error) { - events, err := ExtractEvents(r) - if err != nil { - return "", err - } - if len(events) == 0 { - return "", nil - } - return events[len(events)-1].ID, nil -} - -// ExtractEvents interprets the results of a single page from a List() call, producing a slice of Event entities. -func ExtractEvents(page pagination.Page) ([]Event, error) { - casted := page.(EventPage).Body - - var res struct { - Res []Event `mapstructure:"events"` - } - - if err := mapstructure.Decode(casted, &res); err != nil { - return nil, err - } - - var events []interface{} - switch casted.(type) { - case map[string]interface{}: - events = casted.(map[string]interface{})["events"].([]interface{}) - case map[string][]interface{}: - events = casted.(map[string][]interface{})["events"] - default: - return res.Res, fmt.Errorf("Unknown type: %v", reflect.TypeOf(casted)) - } - - for i, eventRaw := range events { - event := eventRaw.(map[string]interface{}) - if date, ok := event["event_time"]; ok && date != nil { - t, err := time.Parse(time.RFC3339, date.(string)) - if err != nil { - return nil, err - } - res.Res[i].Time = t - } - } - - return res.Res, nil -} - -// ExtractResourceEvents interprets the results of a single page from a -// ListResourceEvents() call, producing a slice of Event entities. -func ExtractResourceEvents(page pagination.Page) ([]Event, error) { - return ExtractEvents(page) -} - -// GetResult represents the result of a Get operation. -type GetResult struct { - gophercloud.Result -} - -// Extract returns a pointer to an Event object and is called after a -// Get operation. -func (r GetResult) Extract() (*Event, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Res *Event `mapstructure:"event"` - } - - if err := mapstructure.Decode(r.Body, &res); err != nil { - return nil, err - } - - event := r.Body.(map[string]interface{})["event"].(map[string]interface{}) - - if date, ok := event["event_time"]; ok && date != nil { - t, err := time.Parse(time.RFC3339, date.(string)) - if err != nil { - return nil, err - } - res.Res.Time = t - } - - return res.Res, nil -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackevents/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackevents/urls.go deleted file mode 100644 index 8b5eceb170..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackevents/urls.go +++ /dev/null @@ -1,19 +0,0 @@ -package stackevents - -import "github.com/rackspace/gophercloud" - -func findURL(c *gophercloud.ServiceClient, stackName string) string { - return c.ServiceURL("stacks", stackName, "events") -} - -func listURL(c *gophercloud.ServiceClient, stackName, stackID string) string { - return c.ServiceURL("stacks", stackName, stackID, "events") -} - -func listResourceEventsURL(c *gophercloud.ServiceClient, stackName, stackID, resourceName string) string { - return c.ServiceURL("stacks", stackName, stackID, "resources", resourceName, "events") -} - -func getURL(c *gophercloud.ServiceClient, stackName, stackID, resourceName, eventID string) string { - return c.ServiceURL("stacks", stackName, stackID, "resources", resourceName, "events", eventID) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackresources/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackresources/doc.go deleted file mode 100644 index e4f8b08dcc..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackresources/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -// Package stackresources provides operations for working with stack resources. -// A resource is a template artifact that represents some component of your -// desired architecture (a Cloud Server, a group of scaled Cloud Servers, a load -// balancer, some configuration management system, and so forth). -package stackresources diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackresources/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackresources/fixtures.go deleted file mode 100644 index 0b930f4841..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackresources/fixtures.go +++ /dev/null @@ -1,451 +0,0 @@ -package stackresources - -import ( - "fmt" - "net/http" - "testing" - "time" - - "github.com/rackspace/gophercloud" - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -// FindExpected represents the expected object from a Find request. -var FindExpected = []Resource{ - Resource{ - Name: "hello_world", - Links: []gophercloud.Link{ - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", - Rel: "self", - }, - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", - Rel: "stack", - }, - }, - LogicalID: "hello_world", - StatusReason: "state changed", - UpdatedTime: time.Date(2015, 2, 5, 21, 33, 11, 0, time.UTC), - RequiredBy: []interface{}{}, - Status: "CREATE_IN_PROGRESS", - PhysicalID: "49181cd6-169a-4130-9455-31185bbfc5bf", - Type: "OS::Nova::Server", - }, -} - -// FindOutput represents the response body from a Find request. -const FindOutput = ` -{ - "resources": [ - { - "resource_name": "hello_world", - "links": [ - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", - "rel": "self" - }, - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", - "rel": "stack" - } - ], - "logical_resource_id": "hello_world", - "resource_status_reason": "state changed", - "updated_time": "2015-02-05T21:33:11Z", - "required_by": [], - "resource_status": "CREATE_IN_PROGRESS", - "physical_resource_id": "49181cd6-169a-4130-9455-31185bbfc5bf", - "resource_type": "OS::Nova::Server" - } - ] -}` - -// HandleFindSuccessfully creates an HTTP handler at `/stacks/hello_world/resources` -// on the test handler mux that responds with a `Find` response. -func HandleFindSuccessfully(t *testing.T, output string) { - th.Mux.HandleFunc("/stacks/hello_world/resources", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, output) - }) -} - -// ListExpected represents the expected object from a List request. -var ListExpected = []Resource{ - Resource{ - Name: "hello_world", - Links: []gophercloud.Link{ - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", - Rel: "self", - }, - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", - Rel: "stack", - }, - }, - LogicalID: "hello_world", - StatusReason: "state changed", - UpdatedTime: time.Date(2015, 2, 5, 21, 33, 11, 0, time.UTC), - RequiredBy: []interface{}{}, - Status: "CREATE_IN_PROGRESS", - PhysicalID: "49181cd6-169a-4130-9455-31185bbfc5bf", - Type: "OS::Nova::Server", - }, -} - -// ListOutput represents the response body from a List request. -const ListOutput = `{ - "resources": [ - { - "resource_name": "hello_world", - "links": [ - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", - "rel": "self" - }, - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", - "rel": "stack" - } - ], - "logical_resource_id": "hello_world", - "resource_status_reason": "state changed", - "updated_time": "2015-02-05T21:33:11Z", - "required_by": [], - "resource_status": "CREATE_IN_PROGRESS", - "physical_resource_id": "49181cd6-169a-4130-9455-31185bbfc5bf", - "resource_type": "OS::Nova::Server" - } -] -}` - -// HandleListSuccessfully creates an HTTP handler at `/stacks/hello_world/49181cd6-169a-4130-9455-31185bbfc5bf/resources` -// on the test handler mux that responds with a `List` response. -func HandleListSuccessfully(t *testing.T, output string) { - th.Mux.HandleFunc("/stacks/hello_world/49181cd6-169a-4130-9455-31185bbfc5bf/resources", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - w.Header().Set("Content-Type", "application/json") - r.ParseForm() - marker := r.Form.Get("marker") - switch marker { - case "": - fmt.Fprintf(w, output) - case "49181cd6-169a-4130-9455-31185bbfc5bf": - fmt.Fprintf(w, `{"resources":[]}`) - default: - t.Fatalf("Unexpected marker: [%s]", marker) - } - }) -} - -// GetExpected represents the expected object from a Get request. -var GetExpected = &Resource{ - Name: "wordpress_instance", - Links: []gophercloud.Link{ - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e/resources/wordpress_instance", - Rel: "self", - }, - gophercloud.Link{ - Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e", - Rel: "stack", - }, - }, - LogicalID: "wordpress_instance", - StatusReason: "state changed", - UpdatedTime: time.Date(2014, 12, 10, 18, 34, 35, 0, time.UTC), - RequiredBy: []interface{}{}, - Status: "CREATE_COMPLETE", - PhysicalID: "00e3a2fe-c65d-403c-9483-4db9930dd194", - Type: "OS::Nova::Server", -} - -// GetOutput represents the response body from a Get request. -const GetOutput = ` -{ - "resource": { - "resource_name": "wordpress_instance", - "description": "", - "links": [ - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e/resources/wordpress_instance", - "rel": "self" - }, - { - "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e", - "rel": "stack" - } - ], - "logical_resource_id": "wordpress_instance", - "resource_status": "CREATE_COMPLETE", - "updated_time": "2014-12-10T18:34:35Z", - "required_by": [], - "resource_status_reason": "state changed", - "physical_resource_id": "00e3a2fe-c65d-403c-9483-4db9930dd194", - "resource_type": "OS::Nova::Server" - } -}` - -// HandleGetSuccessfully creates an HTTP handler at `/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e/resources/wordpress_instance` -// on the test handler mux that responds with a `Get` response. -func HandleGetSuccessfully(t *testing.T, output string) { - th.Mux.HandleFunc("/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e/resources/wordpress_instance", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, output) - }) -} - -// MetadataExpected represents the expected object from a Metadata request. -var MetadataExpected = map[string]string{ - "number": "7", - "animal": "auk", -} - -// MetadataOutput represents the response body from a Metadata request. -const MetadataOutput = ` -{ - "metadata": { - "number": "7", - "animal": "auk" - } -}` - -// HandleMetadataSuccessfully creates an HTTP handler at `/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e/resources/wordpress_instance/metadata` -// on the test handler mux that responds with a `Metadata` response. -func HandleMetadataSuccessfully(t *testing.T, output string) { - th.Mux.HandleFunc("/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e/resources/wordpress_instance/metadata", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, output) - }) -} - -// ListTypesExpected represents the expected object from a ListTypes request. -var ListTypesExpected = []string{ - "OS::Nova::Server", - "OS::Heat::RandomString", - "OS::Swift::Container", - "OS::Trove::Instance", - "OS::Nova::FloatingIPAssociation", - "OS::Cinder::VolumeAttachment", - "OS::Nova::FloatingIP", - "OS::Nova::KeyPair", -} - -// ListTypesOutput represents the response body from a ListTypes request. -const ListTypesOutput = ` -{ - "resource_types": [ - "OS::Nova::Server", - "OS::Heat::RandomString", - "OS::Swift::Container", - "OS::Trove::Instance", - "OS::Nova::FloatingIPAssociation", - "OS::Cinder::VolumeAttachment", - "OS::Nova::FloatingIP", - "OS::Nova::KeyPair" - ] -}` - -// HandleListTypesSuccessfully creates an HTTP handler at `/resource_types` -// on the test handler mux that responds with a `ListTypes` response. -func HandleListTypesSuccessfully(t *testing.T, output string) { - th.Mux.HandleFunc("/resource_types", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, output) - }) -} - -// GetSchemaExpected represents the expected object from a Schema request. -var GetSchemaExpected = &TypeSchema{ - Attributes: map[string]interface{}{ - "an_attribute": map[string]interface{}{ - "description": "An attribute description .", - }, - }, - Properties: map[string]interface{}{ - "a_property": map[string]interface{}{ - "update_allowed": false, - "required": true, - "type": "string", - "description": "A resource description.", - }, - }, - ResourceType: "OS::Heat::AResourceName", -} - -// GetSchemaOutput represents the response body from a Schema request. -const GetSchemaOutput = ` -{ - "attributes": { - "an_attribute": { - "description": "An attribute description ." - } - }, - "properties": { - "a_property": { - "update_allowed": false, - "required": true, - "type": "string", - "description": "A resource description." - } - }, - "resource_type": "OS::Heat::AResourceName" -}` - -// HandleGetSchemaSuccessfully creates an HTTP handler at `/resource_types/OS::Heat::AResourceName` -// on the test handler mux that responds with a `Schema` response. -func HandleGetSchemaSuccessfully(t *testing.T, output string) { - th.Mux.HandleFunc("/resource_types/OS::Heat::AResourceName", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, output) - }) -} - -// GetTemplateExpected represents the expected object from a Template request. -var GetTemplateExpected = &TypeTemplate{ - HeatTemplateFormatVersion: "2012-12-12", - Outputs: map[string]interface{}{ - "private_key": map[string]interface{}{ - "Description": "The private key if it has been saved.", - "Value": "{\"Fn::GetAtt\": [\"KeyPair\", \"private_key\"]}", - }, - "public_key": map[string]interface{}{ - "Description": "The public key.", - "Value": "{\"Fn::GetAtt\": [\"KeyPair\", \"public_key\"]}", - }, - }, - Parameters: map[string]interface{}{ - "name": map[string]interface{}{ - "Description": "The name of the key pair.", - "Type": "String", - }, - "public_key": map[string]interface{}{ - "Description": "The optional public key. This allows users to supply the public key from a pre-existing key pair. If not supplied, a new key pair will be generated.", - "Type": "String", - }, - "save_private_key": map[string]interface{}{ - "AllowedValues": []string{ - "True", - "true", - "False", - "false", - }, - "Default": false, - "Description": "True if the system should remember a generated private key; False otherwise.", - "Type": "String", - }, - }, - Resources: map[string]interface{}{ - "KeyPair": map[string]interface{}{ - "Properties": map[string]interface{}{ - "name": map[string]interface{}{ - "Ref": "name", - }, - "public_key": map[string]interface{}{ - "Ref": "public_key", - }, - "save_private_key": map[string]interface{}{ - "Ref": "save_private_key", - }, - }, - "Type": "OS::Nova::KeyPair", - }, - }, -} - -// GetTemplateOutput represents the response body from a Template request. -const GetTemplateOutput = ` -{ - "HeatTemplateFormatVersion": "2012-12-12", - "Outputs": { - "private_key": { - "Description": "The private key if it has been saved.", - "Value": "{\"Fn::GetAtt\": [\"KeyPair\", \"private_key\"]}" - }, - "public_key": { - "Description": "The public key.", - "Value": "{\"Fn::GetAtt\": [\"KeyPair\", \"public_key\"]}" - } - }, - "Parameters": { - "name": { - "Description": "The name of the key pair.", - "Type": "String" - }, - "public_key": { - "Description": "The optional public key. This allows users to supply the public key from a pre-existing key pair. If not supplied, a new key pair will be generated.", - "Type": "String" - }, - "save_private_key": { - "AllowedValues": [ - "True", - "true", - "False", - "false" - ], - "Default": false, - "Description": "True if the system should remember a generated private key; False otherwise.", - "Type": "String" - } - }, - "Resources": { - "KeyPair": { - "Properties": { - "name": { - "Ref": "name" - }, - "public_key": { - "Ref": "public_key" - }, - "save_private_key": { - "Ref": "save_private_key" - } - }, - "Type": "OS::Nova::KeyPair" - } - } -}` - -// HandleGetTemplateSuccessfully creates an HTTP handler at `/resource_types/OS::Heat::AResourceName/template` -// on the test handler mux that responds with a `Template` response. -func HandleGetTemplateSuccessfully(t *testing.T, output string) { - th.Mux.HandleFunc("/resource_types/OS::Heat::AResourceName/template", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, output) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackresources/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackresources/requests.go deleted file mode 100644 index ee9c3c250c..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackresources/requests.go +++ /dev/null @@ -1,121 +0,0 @@ -package stackresources - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// Find retrieves stack resources for the given stack name. -func Find(c *gophercloud.ServiceClient, stackName string) FindResult { - var res FindResult - - // Send request to API - _, res.Err = c.Request("GET", findURL(c, stackName), gophercloud.RequestOpts{ - JSONResponse: &res.Body, - }) - return res -} - -// ListOptsBuilder allows extensions to add additional parameters to the -// List request. -type ListOptsBuilder interface { - ToStackResourceListQuery() (string, error) -} - -// ListOpts allows the filtering and sorting of paginated collections through -// the API. Marker and Limit are used for pagination. -type ListOpts struct { - // The stack resource ID with which to start the listing. - Marker string `q:"marker"` - - // Integer value for the limit of values to return. - Limit int `q:"limit"` - - // Include resources from nest stacks up to Depth levels of recursion. - Depth int `q:"nested_depth"` -} - -// ToStackResourceListQuery formats a ListOpts into a query string. -func (opts ListOpts) ToStackResourceListQuery() (string, error) { - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return "", err - } - return q.String(), nil -} - -// List makes a request against the API to list resources for the given stack. -func List(client *gophercloud.ServiceClient, stackName, stackID string, opts ListOptsBuilder) pagination.Pager { - url := listURL(client, stackName, stackID) - - if opts != nil { - query, err := opts.ToStackResourceListQuery() - if err != nil { - return pagination.Pager{Err: err} - } - url += query - } - - createPageFn := func(r pagination.PageResult) pagination.Page { - p := ResourcePage{pagination.MarkerPageBase{PageResult: r}} - p.MarkerPageBase.Owner = p - return p - } - - return pagination.NewPager(client, url, createPageFn) -} - -// Get retreives data for the given stack resource. -func Get(c *gophercloud.ServiceClient, stackName, stackID, resourceName string) GetResult { - var res GetResult - - // Send request to API - _, res.Err = c.Get(getURL(c, stackName, stackID, resourceName), &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - return res -} - -// Metadata retreives the metadata for the given stack resource. -func Metadata(c *gophercloud.ServiceClient, stackName, stackID, resourceName string) MetadataResult { - var res MetadataResult - - // Send request to API - _, res.Err = c.Get(metadataURL(c, stackName, stackID, resourceName), &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - return res -} - -// ListTypes makes a request against the API to list resource types. -func ListTypes(client *gophercloud.ServiceClient) pagination.Pager { - url := listTypesURL(client) - - createPageFn := func(r pagination.PageResult) pagination.Page { - return ResourceTypePage{pagination.SinglePageBase(r)} - } - - return pagination.NewPager(client, url, createPageFn) -} - -// Schema retreives the schema for the given resource type. -func Schema(c *gophercloud.ServiceClient, resourceType string) SchemaResult { - var res SchemaResult - - // Send request to API - _, res.Err = c.Get(schemaURL(c, resourceType), &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - return res -} - -// Template retreives the template representation for the given resource type. -func Template(c *gophercloud.ServiceClient, resourceType string) TemplateResult { - var res TemplateResult - - // Send request to API - _, res.Err = c.Get(templateURL(c, resourceType), &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackresources/results.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackresources/results.go deleted file mode 100644 index 69f21daef3..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackresources/results.go +++ /dev/null @@ -1,260 +0,0 @@ -package stackresources - -import ( - "fmt" - "reflect" - "time" - - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// Resource represents a stack resource. -type Resource struct { - Links []gophercloud.Link `mapstructure:"links"` - LogicalID string `mapstructure:"logical_resource_id"` - Name string `mapstructure:"resource_name"` - PhysicalID string `mapstructure:"physical_resource_id"` - RequiredBy []interface{} `mapstructure:"required_by"` - Status string `mapstructure:"resource_status"` - StatusReason string `mapstructure:"resource_status_reason"` - Type string `mapstructure:"resource_type"` - UpdatedTime time.Time `mapstructure:"-"` -} - -// FindResult represents the result of a Find operation. -type FindResult struct { - gophercloud.Result -} - -// Extract returns a slice of Resource objects and is called after a -// Find operation. -func (r FindResult) Extract() ([]Resource, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Res []Resource `mapstructure:"resources"` - } - - if err := mapstructure.Decode(r.Body, &res); err != nil { - return nil, err - } - - resources := r.Body.(map[string]interface{})["resources"].([]interface{}) - - for i, resourceRaw := range resources { - resource := resourceRaw.(map[string]interface{}) - if date, ok := resource["updated_time"]; ok && date != nil { - t, err := time.Parse(time.RFC3339, date.(string)) - if err != nil { - return nil, err - } - res.Res[i].UpdatedTime = t - } - } - - return res.Res, nil -} - -// ResourcePage abstracts the raw results of making a List() request against the API. -// As OpenStack extensions may freely alter the response bodies of structures returned to the client, you may only safely access the -// data provided through the ExtractResources call. -type ResourcePage struct { - pagination.MarkerPageBase -} - -// IsEmpty returns true if a page contains no Server results. -func (r ResourcePage) IsEmpty() (bool, error) { - resources, err := ExtractResources(r) - if err != nil { - return true, err - } - return len(resources) == 0, nil -} - -// LastMarker returns the last container name in a ListResult. -func (r ResourcePage) LastMarker() (string, error) { - resources, err := ExtractResources(r) - if err != nil { - return "", err - } - if len(resources) == 0 { - return "", nil - } - return resources[len(resources)-1].PhysicalID, nil -} - -// ExtractResources interprets the results of a single page from a List() call, producing a slice of Resource entities. -func ExtractResources(page pagination.Page) ([]Resource, error) { - casted := page.(ResourcePage).Body - - var response struct { - Resources []Resource `mapstructure:"resources"` - } - err := mapstructure.Decode(casted, &response) - - var resources []interface{} - switch casted.(type) { - case map[string]interface{}: - resources = casted.(map[string]interface{})["resources"].([]interface{}) - case map[string][]interface{}: - resources = casted.(map[string][]interface{})["resources"] - default: - return response.Resources, fmt.Errorf("Unknown type: %v", reflect.TypeOf(casted)) - } - - for i, resourceRaw := range resources { - resource := resourceRaw.(map[string]interface{}) - if date, ok := resource["updated_time"]; ok && date != nil { - t, err := time.Parse(time.RFC3339, date.(string)) - if err != nil { - return nil, err - } - response.Resources[i].UpdatedTime = t - } - } - - return response.Resources, err -} - -// GetResult represents the result of a Get operation. -type GetResult struct { - gophercloud.Result -} - -// Extract returns a pointer to a Resource object and is called after a -// Get operation. -func (r GetResult) Extract() (*Resource, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Res *Resource `mapstructure:"resource"` - } - - if err := mapstructure.Decode(r.Body, &res); err != nil { - return nil, err - } - - resource := r.Body.(map[string]interface{})["resource"].(map[string]interface{}) - - if date, ok := resource["updated_time"]; ok && date != nil { - t, err := time.Parse(time.RFC3339, date.(string)) - if err != nil { - return nil, err - } - res.Res.UpdatedTime = t - } - - return res.Res, nil -} - -// MetadataResult represents the result of a Metadata operation. -type MetadataResult struct { - gophercloud.Result -} - -// Extract returns a map object and is called after a -// Metadata operation. -func (r MetadataResult) Extract() (map[string]string, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Meta map[string]string `mapstructure:"metadata"` - } - - if err := mapstructure.Decode(r.Body, &res); err != nil { - return nil, err - } - - return res.Meta, nil -} - -// ResourceTypePage abstracts the raw results of making a ListTypes() request against the API. -// As OpenStack extensions may freely alter the response bodies of structures returned to the client, you may only safely access the -// data provided through the ExtractResourceTypes call. -type ResourceTypePage struct { - pagination.SinglePageBase -} - -// IsEmpty returns true if a ResourceTypePage contains no resource types. -func (r ResourceTypePage) IsEmpty() (bool, error) { - rts, err := ExtractResourceTypes(r) - if err != nil { - return true, err - } - return len(rts) == 0, nil -} - -// ExtractResourceTypes extracts and returns resource types. -func ExtractResourceTypes(page pagination.Page) ([]string, error) { - var response struct { - ResourceTypes []string `mapstructure:"resource_types"` - } - - err := mapstructure.Decode(page.(ResourceTypePage).Body, &response) - return response.ResourceTypes, err -} - -// TypeSchema represents a stack resource schema. -type TypeSchema struct { - Attributes map[string]interface{} `mapstructure:"attributes"` - Properties map[string]interface{} `mapstrucutre:"properties"` - ResourceType string `mapstructure:"resource_type"` -} - -// SchemaResult represents the result of a Schema operation. -type SchemaResult struct { - gophercloud.Result -} - -// Extract returns a pointer to a TypeSchema object and is called after a -// Schema operation. -func (r SchemaResult) Extract() (*TypeSchema, error) { - if r.Err != nil { - return nil, r.Err - } - - var res TypeSchema - - if err := mapstructure.Decode(r.Body, &res); err != nil { - return nil, err - } - - return &res, nil -} - -// TypeTemplate represents a stack resource template. -type TypeTemplate struct { - HeatTemplateFormatVersion string - Outputs map[string]interface{} - Parameters map[string]interface{} - Resources map[string]interface{} -} - -// TemplateResult represents the result of a Template operation. -type TemplateResult struct { - gophercloud.Result -} - -// Extract returns a pointer to a TypeTemplate object and is called after a -// Template operation. -func (r TemplateResult) Extract() (*TypeTemplate, error) { - if r.Err != nil { - return nil, r.Err - } - - var res TypeTemplate - - if err := mapstructure.Decode(r.Body, &res); err != nil { - return nil, err - } - - return &res, nil -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackresources/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackresources/urls.go deleted file mode 100644 index ef078d9c9b..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stackresources/urls.go +++ /dev/null @@ -1,31 +0,0 @@ -package stackresources - -import "github.com/rackspace/gophercloud" - -func findURL(c *gophercloud.ServiceClient, stackName string) string { - return c.ServiceURL("stacks", stackName, "resources") -} - -func listURL(c *gophercloud.ServiceClient, stackName, stackID string) string { - return c.ServiceURL("stacks", stackName, stackID, "resources") -} - -func getURL(c *gophercloud.ServiceClient, stackName, stackID, resourceName string) string { - return c.ServiceURL("stacks", stackName, stackID, "resources", resourceName) -} - -func metadataURL(c *gophercloud.ServiceClient, stackName, stackID, resourceName string) string { - return c.ServiceURL("stacks", stackName, stackID, "resources", resourceName, "metadata") -} - -func listTypesURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL("resource_types") -} - -func schemaURL(c *gophercloud.ServiceClient, typeName string) string { - return c.ServiceURL("resource_types", typeName) -} - -func templateURL(c *gophercloud.ServiceClient, typeName string) string { - return c.ServiceURL("resource_types", typeName, "template") -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks/doc.go deleted file mode 100644 index 19231b5137..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks/doc.go +++ /dev/null @@ -1,8 +0,0 @@ -// Package stacks provides operation for working with Heat stacks. A stack is a -// group of resources (servers, load balancers, databases, and so forth) -// combined to fulfill a useful purpose. Based on a template, Heat orchestration -// engine creates an instantiated set of resources (a stack) to run the -// application framework or component specified (in the template). A stack is a -// running instance of a template. The result of creating a stack is a deployment -// of the application framework or component. -package stacks diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks/fixtures.go deleted file mode 100644 index 6d3e9597a2..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks/fixtures.go +++ /dev/null @@ -1,374 +0,0 @@ -package stacks - -import ( - "fmt" - "net/http" - "testing" - "time" - - "github.com/rackspace/gophercloud" - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -// CreateExpected represents the expected object from a Create request. -var CreateExpected = &CreatedStack{ - ID: "16ef0584-4458-41eb-87c8-0dc8d5f66c87", - Links: []gophercloud.Link{ - gophercloud.Link{ - Href: "http://168.28.170.117:8004/v1/98606384f58drad0bhdb7d02779549ac/stacks/stackcreated/16ef0584-4458-41eb-87c8-0dc8d5f66c87", - Rel: "self", - }, - }, -} - -// CreateOutput represents the response body from a Create request. -const CreateOutput = ` -{ - "stack": { - "id": "16ef0584-4458-41eb-87c8-0dc8d5f66c87", - "links": [ - { - "href": "http://168.28.170.117:8004/v1/98606384f58drad0bhdb7d02779549ac/stacks/stackcreated/16ef0584-4458-41eb-87c8-0dc8d5f66c87", - "rel": "self" - } - ] - } -}` - -// HandleCreateSuccessfully creates an HTTP handler at `/stacks` on the test handler mux -// that responds with a `Create` response. -func HandleCreateSuccessfully(t *testing.T, output string) { - th.Mux.HandleFunc("/stacks", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - w.WriteHeader(http.StatusCreated) - fmt.Fprintf(w, output) - }) -} - -// ListExpected represents the expected object from a List request. -var ListExpected = []ListedStack{ - ListedStack{ - Description: "Simple template to test heat commands", - Links: []gophercloud.Link{ - gophercloud.Link{ - Href: "http://166.76.160.117:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87", - Rel: "self", - }, - }, - StatusReason: "Stack CREATE completed successfully", - Name: "postman_stack", - CreationTime: time.Date(2015, 2, 3, 20, 7, 39, 0, time.UTC), - Status: "CREATE_COMPLETE", - ID: "16ef0584-4458-41eb-87c8-0dc8d5f66c87", - }, - ListedStack{ - Description: "Simple template to test heat commands", - Links: []gophercloud.Link{ - gophercloud.Link{ - Href: "http://166.76.160.117:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/gophercloud-test-stack-2/db6977b2-27aa-4775-9ae7-6213212d4ada", - Rel: "self", - }, - }, - StatusReason: "Stack successfully updated", - Name: "gophercloud-test-stack-2", - CreationTime: time.Date(2014, 12, 11, 17, 39, 16, 0, time.UTC), - UpdatedTime: time.Date(2014, 12, 11, 17, 40, 37, 0, time.UTC), - Status: "UPDATE_COMPLETE", - ID: "db6977b2-27aa-4775-9ae7-6213212d4ada", - }, -} - -// FullListOutput represents the response body from a List request without a marker. -const FullListOutput = ` -{ - "stacks": [ - { - "description": "Simple template to test heat commands", - "links": [ - { - "href": "http://166.76.160.117:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87", - "rel": "self" - } - ], - "stack_status_reason": "Stack CREATE completed successfully", - "stack_name": "postman_stack", - "creation_time": "2015-02-03T20:07:39Z", - "updated_time": null, - "stack_status": "CREATE_COMPLETE", - "id": "16ef0584-4458-41eb-87c8-0dc8d5f66c87" - }, - { - "description": "Simple template to test heat commands", - "links": [ - { - "href": "http://166.76.160.117:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/gophercloud-test-stack-2/db6977b2-27aa-4775-9ae7-6213212d4ada", - "rel": "self" - } - ], - "stack_status_reason": "Stack successfully updated", - "stack_name": "gophercloud-test-stack-2", - "creation_time": "2014-12-11T17:39:16Z", - "updated_time": "2014-12-11T17:40:37Z", - "stack_status": "UPDATE_COMPLETE", - "id": "db6977b2-27aa-4775-9ae7-6213212d4ada" - } - ] -} -` - -// HandleListSuccessfully creates an HTTP handler at `/stacks` on the test handler mux -// that responds with a `List` response. -func HandleListSuccessfully(t *testing.T, output string) { - th.Mux.HandleFunc("/stacks", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - w.Header().Set("Content-Type", "application/json") - r.ParseForm() - marker := r.Form.Get("marker") - switch marker { - case "": - fmt.Fprintf(w, output) - case "db6977b2-27aa-4775-9ae7-6213212d4ada": - fmt.Fprintf(w, `[]`) - default: - t.Fatalf("Unexpected marker: [%s]", marker) - } - }) -} - -// GetExpected represents the expected object from a Get request. -var GetExpected = &RetrievedStack{ - DisableRollback: true, - Description: "Simple template to test heat commands", - Parameters: map[string]string{ - "flavor": "m1.tiny", - "OS::stack_name": "postman_stack", - "OS::stack_id": "16ef0584-4458-41eb-87c8-0dc8d5f66c87", - }, - StatusReason: "Stack CREATE completed successfully", - Name: "postman_stack", - Outputs: []map[string]interface{}{}, - CreationTime: time.Date(2015, 2, 3, 20, 7, 39, 0, time.UTC), - Links: []gophercloud.Link{ - gophercloud.Link{ - Href: "http://166.76.160.117:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87", - Rel: "self", - }, - }, - Capabilities: []interface{}{}, - NotificationTopics: []interface{}{}, - Status: "CREATE_COMPLETE", - ID: "16ef0584-4458-41eb-87c8-0dc8d5f66c87", - TemplateDescription: "Simple template to test heat commands", -} - -// GetOutput represents the response body from a Get request. -const GetOutput = ` -{ - "stack": { - "disable_rollback": true, - "description": "Simple template to test heat commands", - "parameters": { - "flavor": "m1.tiny", - "OS::stack_name": "postman_stack", - "OS::stack_id": "16ef0584-4458-41eb-87c8-0dc8d5f66c87" - }, - "stack_status_reason": "Stack CREATE completed successfully", - "stack_name": "postman_stack", - "outputs": [], - "creation_time": "2015-02-03T20:07:39Z", - "links": [ - { - "href": "http://166.76.160.117:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87", - "rel": "self" - } - ], - "capabilities": [], - "notification_topics": [], - "timeout_mins": null, - "stack_status": "CREATE_COMPLETE", - "updated_time": null, - "id": "16ef0584-4458-41eb-87c8-0dc8d5f66c87", - "template_description": "Simple template to test heat commands" - } -} -` - -// HandleGetSuccessfully creates an HTTP handler at `/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87` -// on the test handler mux that responds with a `Get` response. -func HandleGetSuccessfully(t *testing.T, output string) { - th.Mux.HandleFunc("/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, output) - }) -} - -// HandleUpdateSuccessfully creates an HTTP handler at `/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87` -// on the test handler mux that responds with an `Update` response. -func HandleUpdateSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/stacks/gophercloud-test-stack-2/db6977b2-27aa-4775-9ae7-6213212d4ada", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PUT") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusAccepted) - }) -} - -// HandleDeleteSuccessfully creates an HTTP handler at `/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87` -// on the test handler mux that responds with a `Delete` response. -func HandleDeleteSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/stacks/gophercloud-test-stack-2/db6977b2-27aa-4775-9ae7-6213212d4ada", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusNoContent) - }) -} - -// GetExpected represents the expected object from a Get request. -var PreviewExpected = &PreviewedStack{ - DisableRollback: true, - Description: "Simple template to test heat commands", - Parameters: map[string]string{ - "flavor": "m1.tiny", - "OS::stack_name": "postman_stack", - "OS::stack_id": "16ef0584-4458-41eb-87c8-0dc8d5f66c87", - }, - StatusReason: "Stack CREATE completed successfully", - Name: "postman_stack", - CreationTime: time.Date(2015, 2, 3, 20, 7, 39, 0, time.UTC), - Links: []gophercloud.Link{ - gophercloud.Link{ - Href: "http://166.76.160.117:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87", - Rel: "self", - }, - }, - Capabilities: []interface{}{}, - NotificationTopics: []interface{}{}, - Status: "CREATE_COMPLETE", - ID: "16ef0584-4458-41eb-87c8-0dc8d5f66c87", - TemplateDescription: "Simple template to test heat commands", -} - -// HandlePreviewSuccessfully creates an HTTP handler at `/stacks/preview` -// on the test handler mux that responds with a `Preview` response. -func HandlePreviewSuccessfully(t *testing.T, output string) { - th.Mux.HandleFunc("/stacks/preview", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, output) - }) -} - -// AbandonExpected represents the expected object from an Abandon request. -var AbandonExpected = &AbandonedStack{ - Status: "COMPLETE", - Name: "postman_stack", - Template: map[string]interface{}{ - "heat_template_version": "2013-05-23", - "description": "Simple template to test heat commands", - "parameters": map[string]interface{}{ - "flavor": map[string]interface{}{ - "default": "m1.tiny", - "type": "string", - }, - }, - "resources": map[string]interface{}{ - "hello_world": map[string]interface{}{ - "type": "OS::Nova::Server", - "properties": map[string]interface{}{ - "key_name": "heat_key", - "flavor": map[string]interface{}{ - "get_param": "flavor", - }, - "image": "ad091b52-742f-469e-8f3c-fd81cadf0743", - "user_data": "#!/bin/bash -xv\necho \"hello world\" > /root/hello-world.txt\n", - }, - }, - }, - }, - Action: "CREATE", - ID: "16ef0584-4458-41eb-87c8-0dc8d5f66c87", - Resources: map[string]interface{}{ - "hello_world": map[string]interface{}{ - "status": "COMPLETE", - "name": "hello_world", - "resource_id": "8a310d36-46fc-436f-8be4-37a696b8ac63", - "action": "CREATE", - "type": "OS::Nova::Server", - }, - }, -} - -// AbandonOutput represents the response body from an Abandon request. -const AbandonOutput = ` -{ - "status": "COMPLETE", - "name": "postman_stack", - "template": { - "heat_template_version": "2013-05-23", - "description": "Simple template to test heat commands", - "parameters": { - "flavor": { - "default": "m1.tiny", - "type": "string" - } - }, - "resources": { - "hello_world": { - "type": "OS::Nova::Server", - "properties": { - "key_name": "heat_key", - "flavor": { - "get_param": "flavor" - }, - "image": "ad091b52-742f-469e-8f3c-fd81cadf0743", - "user_data": "#!/bin/bash -xv\necho \"hello world\" > /root/hello-world.txt\n" - } - } - } - }, - "action": "CREATE", - "id": "16ef0584-4458-41eb-87c8-0dc8d5f66c87", - "resources": { - "hello_world": { - "status": "COMPLETE", - "name": "hello_world", - "resource_id": "8a310d36-46fc-436f-8be4-37a696b8ac63", - "action": "CREATE", - "type": "OS::Nova::Server", - } - } -}` - -// HandleAbandonSuccessfully creates an HTTP handler at `/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87/abandon` -// on the test handler mux that responds with an `Abandon` response. -func HandleAbandonSuccessfully(t *testing.T) { - th.Mux.HandleFunc("/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87/abandon", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, AbandonOutput) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks/requests.go deleted file mode 100644 index 0dd6af2cfa..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks/requests.go +++ /dev/null @@ -1,493 +0,0 @@ -package stacks - -import ( - "errors" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// Rollback is used to specify whether or not a stack can be rolled back. -type Rollback *bool - -var ( - disable = true - // Disable is used to specify that a stack cannot be rolled back. - Disable Rollback = &disable - enable = false - // Enable is used to specify that a stack can be rolled back. - Enable Rollback = &enable -) - -// CreateOptsBuilder is the interface options structs have to satisfy in order -// to be used in the main Create operation in this package. Since many -// extensions decorate or modify the common logic, it is useful for them to -// satisfy a basic interface in order for them to be used. -type CreateOptsBuilder interface { - ToStackCreateMap() (map[string]interface{}, error) -} - -// CreateOpts is the common options struct used in this package's Create -// operation. -type CreateOpts struct { - // (REQUIRED) The name of the stack. It must start with an alphabetic character. - Name string - // (OPTIONAL; REQUIRED IF Template IS EMPTY) The URL of the template to instantiate. - // This value is ignored if Template is supplied inline. - TemplateURL string - // (OPTIONAL; REQUIRED IF TemplateURL IS EMPTY) A template to instantiate. The value - // is a stringified version of the JSON/YAML template. Since the template will likely - // be located in a file, one way to set this variable is by using ioutil.ReadFile: - // import "io/ioutil" - // var opts stacks.CreateOpts - // b, err := ioutil.ReadFile("path/to/you/template/file.json") - // if err != nil { - // // handle error... - // } - // opts.Template = string(b) - Template string - // (OPTIONAL) Enables or disables deletion of all stack resources when a stack - // creation fails. Default is true, meaning all resources are not deleted when - // stack creation fails. - DisableRollback Rollback - // (OPTIONAL) A stringified JSON environment for the stack. - Environment string - // (OPTIONAL) A map that maps file names to file contents. It can also be used - // to pass provider template contents. Example: - // Files: `{"myfile": "#!/bin/bash\necho 'Hello world' > /root/testfile.txt"}` - Files map[string]interface{} - // (OPTIONAL) User-defined parameters to pass to the template. - Parameters map[string]string - // (OPTIONAL) The timeout for stack creation in minutes. - Timeout int -} - -// ToStackCreateMap casts a CreateOpts struct to a map. -func (opts CreateOpts) ToStackCreateMap() (map[string]interface{}, error) { - s := make(map[string]interface{}) - - if opts.Name == "" { - return s, errors.New("Required field 'Name' not provided.") - } - s["stack_name"] = opts.Name - - if opts.Template != "" { - s["template"] = opts.Template - } else if opts.TemplateURL != "" { - s["template_url"] = opts.TemplateURL - } else { - return s, errors.New("Either Template or TemplateURL must be provided.") - } - - if opts.DisableRollback != nil { - s["disable_rollback"] = &opts.DisableRollback - } - - if opts.Environment != "" { - s["environment"] = opts.Environment - } - if opts.Files != nil { - s["files"] = opts.Files - } - if opts.Parameters != nil { - s["parameters"] = opts.Parameters - } - - if opts.Timeout != 0 { - s["timeout_mins"] = opts.Timeout - } - - return s, nil -} - -// Create accepts a CreateOpts struct and creates a new stack using the values -// provided. -func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult { - var res CreateResult - - reqBody, err := opts.ToStackCreateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = c.Post(createURL(c), reqBody, &res.Body, nil) - return res -} - -// AdoptOptsBuilder is the interface options structs have to satisfy in order -// to be used in the Adopt function in this package. Since many -// extensions decorate or modify the common logic, it is useful for them to -// satisfy a basic interface in order for them to be used. -type AdoptOptsBuilder interface { - ToStackAdoptMap() (map[string]interface{}, error) -} - -// AdoptOpts is the common options struct used in this package's Adopt -// operation. -type AdoptOpts struct { - // (REQUIRED) Existing resources data represented as a string to add to the - // new stack. Data returned by Abandon could be provided as AdoptsStackData. - AdoptStackData string - // (REQUIRED) The name of the stack. It must start with an alphabetic character. - Name string - // (REQUIRED) The timeout for stack creation in minutes. - Timeout int - // (OPTIONAL; REQUIRED IF Template IS EMPTY) The URL of the template to instantiate. - // This value is ignored if Template is supplied inline. - TemplateURL string - // (OPTIONAL; REQUIRED IF TemplateURL IS EMPTY) A template to instantiate. The value - // is a stringified version of the JSON/YAML template. Since the template will likely - // be located in a file, one way to set this variable is by using ioutil.ReadFile: - // import "io/ioutil" - // var opts stacks.CreateOpts - // b, err := ioutil.ReadFile("path/to/you/template/file.json") - // if err != nil { - // // handle error... - // } - // opts.Template = string(b) - Template string - // (OPTIONAL) Enables or disables deletion of all stack resources when a stack - // creation fails. Default is true, meaning all resources are not deleted when - // stack creation fails. - DisableRollback Rollback - // (OPTIONAL) A stringified JSON environment for the stack. - Environment string - // (OPTIONAL) A map that maps file names to file contents. It can also be used - // to pass provider template contents. Example: - // Files: `{"myfile": "#!/bin/bash\necho 'Hello world' > /root/testfile.txt"}` - Files map[string]interface{} - // (OPTIONAL) User-defined parameters to pass to the template. - Parameters map[string]string -} - -// ToStackAdoptMap casts a CreateOpts struct to a map. -func (opts AdoptOpts) ToStackAdoptMap() (map[string]interface{}, error) { - s := make(map[string]interface{}) - - if opts.Name == "" { - return s, errors.New("Required field 'Name' not provided.") - } - s["stack_name"] = opts.Name - - if opts.Template != "" { - s["template"] = opts.Template - } else if opts.TemplateURL != "" { - s["template_url"] = opts.TemplateURL - } else { - return s, errors.New("Either Template or TemplateURL must be provided.") - } - - if opts.AdoptStackData == "" { - return s, errors.New("Required field 'AdoptStackData' not provided.") - } - s["adopt_stack_data"] = opts.AdoptStackData - - if opts.DisableRollback != nil { - s["disable_rollback"] = &opts.DisableRollback - } - - if opts.Environment != "" { - s["environment"] = opts.Environment - } - if opts.Files != nil { - s["files"] = opts.Files - } - if opts.Parameters != nil { - s["parameters"] = opts.Parameters - } - - if opts.Timeout == 0 { - return nil, errors.New("Required field 'Timeout' not provided.") - } - s["timeout_mins"] = opts.Timeout - - return map[string]interface{}{"stack": s}, nil -} - -// Adopt accepts an AdoptOpts struct and creates a new stack using the resources -// from another stack. -func Adopt(c *gophercloud.ServiceClient, opts AdoptOptsBuilder) AdoptResult { - var res AdoptResult - - reqBody, err := opts.ToStackAdoptMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = c.Post(adoptURL(c), reqBody, &res.Body, nil) - return res -} - -// SortDir is a type for specifying in which direction to sort a list of stacks. -type SortDir string - -// SortKey is a type for specifying by which key to sort a list of stacks. -type SortKey string - -var ( - // SortAsc is used to sort a list of stacks in ascending order. - SortAsc SortDir = "asc" - // SortDesc is used to sort a list of stacks in descending order. - SortDesc SortDir = "desc" - // SortName is used to sort a list of stacks by name. - SortName SortKey = "name" - // SortStatus is used to sort a list of stacks by status. - SortStatus SortKey = "status" - // SortCreatedAt is used to sort a list of stacks by date created. - SortCreatedAt SortKey = "created_at" - // SortUpdatedAt is used to sort a list of stacks by date updated. - SortUpdatedAt SortKey = "updated_at" -) - -// ListOptsBuilder allows extensions to add additional parameters to the -// List request. -type ListOptsBuilder interface { - ToStackListQuery() (string, error) -} - -// ListOpts allows the filtering and sorting of paginated collections through -// the API. Filtering is achieved by passing in struct field values that map to -// the network attributes you want to see returned. SortKey allows you to sort -// by a particular network attribute. SortDir sets the direction, and is either -// `asc' or `desc'. Marker and Limit are used for pagination. -type ListOpts struct { - Status string `q:"status"` - Name string `q:"name"` - Marker string `q:"marker"` - Limit int `q:"limit"` - SortKey SortKey `q:"sort_keys"` - SortDir SortDir `q:"sort_dir"` -} - -// ToStackListQuery formats a ListOpts into a query string. -func (opts ListOpts) ToStackListQuery() (string, error) { - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return "", err - } - return q.String(), nil -} - -// List returns a Pager which allows you to iterate over a collection of -// stacks. It accepts a ListOpts struct, which allows you to filter and sort -// the returned collection for greater efficiency. -func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { - url := listURL(c) - if opts != nil { - query, err := opts.ToStackListQuery() - if err != nil { - return pagination.Pager{Err: err} - } - url += query - } - - createPage := func(r pagination.PageResult) pagination.Page { - return StackPage{pagination.SinglePageBase(r)} - } - return pagination.NewPager(c, url, createPage) -} - -// Get retreives a stack based on the stack name and stack ID. -func Get(c *gophercloud.ServiceClient, stackName, stackID string) GetResult { - var res GetResult - _, res.Err = c.Get(getURL(c, stackName, stackID), &res.Body, nil) - return res -} - -// UpdateOptsBuilder is the interface options structs have to satisfy in order -// to be used in the Update operation in this package. -type UpdateOptsBuilder interface { - ToStackUpdateMap() (map[string]interface{}, error) -} - -// UpdateOpts contains the common options struct used in this package's Update -// operation. -type UpdateOpts struct { - // (OPTIONAL; REQUIRED IF Template IS EMPTY) The URL of the template to instantiate. - // This value is ignored if Template is supplied inline. - TemplateURL string - // (OPTIONAL; REQUIRED IF TemplateURL IS EMPTY) A template to instantiate. The value - // is a stringified version of the JSON/YAML template. Since the template will likely - // be located in a file, one way to set this variable is by using ioutil.ReadFile: - // import "io/ioutil" - // var opts stacks.CreateOpts - // b, err := ioutil.ReadFile("path/to/you/template/file.json") - // if err != nil { - // // handle error... - // } - // opts.Template = string(b) - Template string - // (OPTIONAL) A stringified JSON environment for the stack. - Environment string - // (OPTIONAL) A map that maps file names to file contents. It can also be used - // to pass provider template contents. Example: - // Files: `{"myfile": "#!/bin/bash\necho 'Hello world' > /root/testfile.txt"}` - Files map[string]interface{} - // (OPTIONAL) User-defined parameters to pass to the template. - Parameters map[string]string - // (OPTIONAL) The timeout for stack creation in minutes. - Timeout int -} - -// ToStackUpdateMap casts a CreateOpts struct to a map. -func (opts UpdateOpts) ToStackUpdateMap() (map[string]interface{}, error) { - s := make(map[string]interface{}) - - if opts.Template != "" { - s["template"] = opts.Template - } else if opts.TemplateURL != "" { - s["template_url"] = opts.TemplateURL - } else { - return s, errors.New("Either Template or TemplateURL must be provided.") - } - - if opts.Environment != "" { - s["environment"] = opts.Environment - } - - if opts.Files != nil { - s["files"] = opts.Files - } - - if opts.Parameters != nil { - s["parameters"] = opts.Parameters - } - - if opts.Timeout != 0 { - s["timeout_mins"] = opts.Timeout - } - - return s, nil -} - -// Update accepts an UpdateOpts struct and updates an existing stack using the values -// provided. -func Update(c *gophercloud.ServiceClient, stackName, stackID string, opts UpdateOptsBuilder) UpdateResult { - var res UpdateResult - - reqBody, err := opts.ToStackUpdateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = c.Put(updateURL(c, stackName, stackID), reqBody, nil, nil) - return res -} - -// Delete deletes a stack based on the stack name and stack ID. -func Delete(c *gophercloud.ServiceClient, stackName, stackID string) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(deleteURL(c, stackName, stackID), nil) - return res -} - -// PreviewOptsBuilder is the interface options structs have to satisfy in order -// to be used in the Preview operation in this package. -type PreviewOptsBuilder interface { - ToStackPreviewMap() (map[string]interface{}, error) -} - -// PreviewOpts contains the common options struct used in this package's Preview -// operation. -type PreviewOpts struct { - // (REQUIRED) The name of the stack. It must start with an alphabetic character. - Name string - // (REQUIRED) The timeout for stack creation in minutes. - Timeout int - // (OPTIONAL; REQUIRED IF Template IS EMPTY) The URL of the template to instantiate. - // This value is ignored if Template is supplied inline. - TemplateURL string - // (OPTIONAL; REQUIRED IF TemplateURL IS EMPTY) A template to instantiate. The value - // is a stringified version of the JSON/YAML template. Since the template will likely - // be located in a file, one way to set this variable is by using ioutil.ReadFile: - // import "io/ioutil" - // var opts stacks.CreateOpts - // b, err := ioutil.ReadFile("path/to/you/template/file.json") - // if err != nil { - // // handle error... - // } - // opts.Template = string(b) - Template string - // (OPTIONAL) Enables or disables deletion of all stack resources when a stack - // creation fails. Default is true, meaning all resources are not deleted when - // stack creation fails. - DisableRollback Rollback - // (OPTIONAL) A stringified JSON environment for the stack. - Environment string - // (OPTIONAL) A map that maps file names to file contents. It can also be used - // to pass provider template contents. Example: - // Files: `{"myfile": "#!/bin/bash\necho 'Hello world' > /root/testfile.txt"}` - Files map[string]interface{} - // (OPTIONAL) User-defined parameters to pass to the template. - Parameters map[string]string -} - -// ToStackPreviewMap casts a PreviewOpts struct to a map. -func (opts PreviewOpts) ToStackPreviewMap() (map[string]interface{}, error) { - s := make(map[string]interface{}) - - if opts.Name == "" { - return s, errors.New("Required field 'Name' not provided.") - } - s["stack_name"] = opts.Name - - if opts.Template != "" { - s["template"] = opts.Template - } else if opts.TemplateURL != "" { - s["template_url"] = opts.TemplateURL - } else { - return s, errors.New("Either Template or TemplateURL must be provided.") - } - - if opts.DisableRollback != nil { - s["disable_rollback"] = &opts.DisableRollback - } - - if opts.Environment != "" { - s["environment"] = opts.Environment - } - if opts.Files != nil { - s["files"] = opts.Files - } - if opts.Parameters != nil { - s["parameters"] = opts.Parameters - } - - if opts.Timeout != 0 { - s["timeout_mins"] = opts.Timeout - } - - return s, nil -} - -// Preview accepts a PreviewOptsBuilder interface and creates a preview of a stack using the values -// provided. -func Preview(c *gophercloud.ServiceClient, opts PreviewOptsBuilder) PreviewResult { - var res PreviewResult - - reqBody, err := opts.ToStackPreviewMap() - if err != nil { - res.Err = err - return res - } - - // Send request to API - _, res.Err = c.Post(previewURL(c), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - return res -} - -// Abandon deletes the stack with the provided stackName and stackID, but leaves its -// resources intact, and returns data describing the stack and its resources. -func Abandon(c *gophercloud.ServiceClient, stackName, stackID string) AbandonResult { - var res AbandonResult - _, res.Err = c.Delete(abandonURL(c, stackName, stackID), &gophercloud.RequestOpts{ - JSONResponse: &res.Body, - OkCodes: []int{200}, - }) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks/results.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks/results.go deleted file mode 100644 index 04d3f8ea96..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks/results.go +++ /dev/null @@ -1,309 +0,0 @@ -package stacks - -import ( - "encoding/json" - "fmt" - "reflect" - "time" - - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// CreatedStack represents the object extracted from a Create operation. -type CreatedStack struct { - ID string `mapstructure:"id"` - Links []gophercloud.Link `mapstructure:"links"` -} - -// CreateResult represents the result of a Create operation. -type CreateResult struct { - gophercloud.Result -} - -// Extract returns a pointer to a CreatedStack object and is called after a -// Create operation. -func (r CreateResult) Extract() (*CreatedStack, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Stack *CreatedStack `mapstructure:"stack"` - } - - if err := mapstructure.Decode(r.Body, &res); err != nil { - return nil, err - } - - return res.Stack, nil -} - -// AdoptResult represents the result of an Adopt operation. AdoptResult has the -// same form as CreateResult. -type AdoptResult struct { - CreateResult -} - -// StackPage is a pagination.Pager that is returned from a call to the List function. -type StackPage struct { - pagination.SinglePageBase -} - -// IsEmpty returns true if a ListResult contains no Stacks. -func (r StackPage) IsEmpty() (bool, error) { - stacks, err := ExtractStacks(r) - if err != nil { - return true, err - } - return len(stacks) == 0, nil -} - -// ListedStack represents an element in the slice extracted from a List operation. -type ListedStack struct { - CreationTime time.Time `mapstructure:"-"` - Description string `mapstructure:"description"` - ID string `mapstructure:"id"` - Links []gophercloud.Link `mapstructure:"links"` - Name string `mapstructure:"stack_name"` - Status string `mapstructure:"stack_status"` - StatusReason string `mapstructure:"stack_status_reason"` - UpdatedTime time.Time `mapstructure:"-"` -} - -// ExtractStacks extracts and returns a slice of ListedStack. It is used while iterating -// over a stacks.List call. -func ExtractStacks(page pagination.Page) ([]ListedStack, error) { - casted := page.(StackPage).Body - - var res struct { - Stacks []ListedStack `mapstructure:"stacks"` - } - - err := mapstructure.Decode(page.(StackPage).Body, &res) - if err != nil { - return nil, err - } - - var rawStacks []interface{} - switch casted.(type) { - case map[string]interface{}: - rawStacks = casted.(map[string]interface{})["stacks"].([]interface{}) - case map[string][]interface{}: - rawStacks = casted.(map[string][]interface{})["stacks"] - default: - return res.Stacks, fmt.Errorf("Unknown type: %v", reflect.TypeOf(casted)) - } - - for i := range rawStacks { - thisStack := (rawStacks[i]).(map[string]interface{}) - - if t, ok := thisStack["creation_time"].(string); ok && t != "" { - creationTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return res.Stacks, err - } - res.Stacks[i].CreationTime = creationTime - } - - if t, ok := thisStack["updated_time"].(string); ok && t != "" { - updatedTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return res.Stacks, err - } - res.Stacks[i].UpdatedTime = updatedTime - } - } - - return res.Stacks, nil -} - -// RetrievedStack represents the object extracted from a Get operation. -type RetrievedStack struct { - Capabilities []interface{} `mapstructure:"capabilities"` - CreationTime time.Time `mapstructure:"-"` - Description string `mapstructure:"description"` - DisableRollback bool `mapstructure:"disable_rollback"` - ID string `mapstructure:"id"` - Links []gophercloud.Link `mapstructure:"links"` - NotificationTopics []interface{} `mapstructure:"notification_topics"` - Outputs []map[string]interface{} `mapstructure:"outputs"` - Parameters map[string]string `mapstructure:"parameters"` - Name string `mapstructure:"stack_name"` - Status string `mapstructure:"stack_status"` - StatusReason string `mapstructure:"stack_status_reason"` - TemplateDescription string `mapstructure:"template_description"` - Timeout int `mapstructure:"timeout_mins"` - UpdatedTime time.Time `mapstructure:"-"` -} - -// GetResult represents the result of a Get operation. -type GetResult struct { - gophercloud.Result -} - -// Extract returns a pointer to a RetrievedStack object and is called after a -// Get operation. -func (r GetResult) Extract() (*RetrievedStack, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Stack *RetrievedStack `mapstructure:"stack"` - } - - config := &mapstructure.DecoderConfig{ - Result: &res, - WeaklyTypedInput: true, - } - decoder, err := mapstructure.NewDecoder(config) - if err != nil { - return nil, err - } - - if err := decoder.Decode(r.Body); err != nil { - return nil, err - } - - b := r.Body.(map[string]interface{})["stack"].(map[string]interface{}) - - if date, ok := b["creation_time"]; ok && date != nil { - t, err := time.Parse(time.RFC3339, date.(string)) - if err != nil { - return nil, err - } - res.Stack.CreationTime = t - } - - if date, ok := b["updated_time"]; ok && date != nil { - t, err := time.Parse(time.RFC3339, date.(string)) - if err != nil { - return nil, err - } - res.Stack.UpdatedTime = t - } - - return res.Stack, err -} - -// UpdateResult represents the result of a Update operation. -type UpdateResult struct { - gophercloud.ErrResult -} - -// DeleteResult represents the result of a Delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} - -// PreviewedStack represents the result of a Preview operation. -type PreviewedStack struct { - Capabilities []interface{} `mapstructure:"capabilities"` - CreationTime time.Time `mapstructure:"-"` - Description string `mapstructure:"description"` - DisableRollback bool `mapstructure:"disable_rollback"` - ID string `mapstructure:"id"` - Links []gophercloud.Link `mapstructure:"links"` - Name string `mapstructure:"stack_name"` - NotificationTopics []interface{} `mapstructure:"notification_topics"` - Parameters map[string]string `mapstructure:"parameters"` - Resources []map[string]interface{} `mapstructure:"resources"` - Status string `mapstructure:"stack_status"` - StatusReason string `mapstructure:"stack_status_reason"` - TemplateDescription string `mapstructure:"template_description"` - Timeout int `mapstructure:"timeout_mins"` - UpdatedTime time.Time `mapstructure:"-"` -} - -// PreviewResult represents the result of a Preview operation. -type PreviewResult struct { - gophercloud.Result -} - -// Extract returns a pointer to a PreviewedStack object and is called after a -// Preview operation. -func (r PreviewResult) Extract() (*PreviewedStack, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Stack *PreviewedStack `mapstructure:"stack"` - } - - config := &mapstructure.DecoderConfig{ - Result: &res, - WeaklyTypedInput: true, - } - decoder, err := mapstructure.NewDecoder(config) - if err != nil { - return nil, err - } - - if err := decoder.Decode(r.Body); err != nil { - return nil, err - } - - b := r.Body.(map[string]interface{})["stack"].(map[string]interface{}) - - if date, ok := b["creation_time"]; ok && date != nil { - t, err := time.Parse(time.RFC3339, date.(string)) - if err != nil { - return nil, err - } - res.Stack.CreationTime = t - } - - if date, ok := b["updated_time"]; ok && date != nil { - t, err := time.Parse(time.RFC3339, date.(string)) - if err != nil { - return nil, err - } - res.Stack.UpdatedTime = t - } - - return res.Stack, err -} - -// AbandonedStack represents the result of an Abandon operation. -type AbandonedStack struct { - Status string `mapstructure:"status"` - Name string `mapstructure:"name"` - Template map[string]interface{} `mapstructure:"template"` - Action string `mapstructure:"action"` - ID string `mapstructure:"id"` - Resources map[string]interface{} `mapstructure:"resources"` -} - -// AbandonResult represents the result of an Abandon operation. -type AbandonResult struct { - gophercloud.Result -} - -// Extract returns a pointer to an AbandonedStack object and is called after an -// Abandon operation. -func (r AbandonResult) Extract() (*AbandonedStack, error) { - if r.Err != nil { - return nil, r.Err - } - - var res AbandonedStack - - if err := mapstructure.Decode(r.Body, &res); err != nil { - return nil, err - } - - return &res, nil -} - -// String converts an AbandonResult to a string. This is useful to when passing -// the result of an Abandon operation to an AdoptOpts AdoptStackData field. -func (r AbandonResult) String() (string, error) { - out, err := json.Marshal(r) - if err != nil { - return "", err - } - return string(out), nil -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks/urls.go deleted file mode 100644 index 3dd2bb32ea..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks/urls.go +++ /dev/null @@ -1,35 +0,0 @@ -package stacks - -import "github.com/rackspace/gophercloud" - -func createURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL("stacks") -} - -func adoptURL(c *gophercloud.ServiceClient) string { - return createURL(c) -} - -func listURL(c *gophercloud.ServiceClient) string { - return createURL(c) -} - -func getURL(c *gophercloud.ServiceClient, name, id string) string { - return c.ServiceURL("stacks", name, id) -} - -func updateURL(c *gophercloud.ServiceClient, name, id string) string { - return getURL(c, name, id) -} - -func deleteURL(c *gophercloud.ServiceClient, name, id string) string { - return getURL(c, name, id) -} - -func previewURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL("stacks", "preview") -} - -func abandonURL(c *gophercloud.ServiceClient, name, id string) string { - return c.ServiceURL("stacks", name, id, "abandon") -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates/doc.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates/doc.go deleted file mode 100644 index 5af0bd62a1..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates/doc.go +++ /dev/null @@ -1,8 +0,0 @@ -// Package stacktemplates provides operations for working with Heat templates. -// A Cloud Orchestration template is a portable file, written in a user-readable -// language, that describes how a set of resources should be assembled and what -// software should be installed in order to produce a working stack. The template -// specifies what resources should be used, what attributes can be set, and other -// parameters that are critical to the successful, repeatable automation of a -// specific application stack. -package stacktemplates diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates/fixtures.go deleted file mode 100644 index 71fa80891e..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates/fixtures.go +++ /dev/null @@ -1,118 +0,0 @@ -package stacktemplates - -import ( - "fmt" - "net/http" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -// GetExpected represents the expected object from a Get request. -var GetExpected = &Template{ - Description: "Simple template to test heat commands", - HeatTemplateVersion: "2013-05-23", - Parameters: map[string]interface{}{ - "flavor": map[string]interface{}{ - "default": "m1.tiny", - "type": "string", - }, - }, - Resources: map[string]interface{}{ - "hello_world": map[string]interface{}{ - "type": "OS::Nova::Server", - "properties": map[string]interface{}{ - "key_name": "heat_key", - "flavor": map[string]interface{}{ - "get_param": "flavor", - }, - "image": "ad091b52-742f-469e-8f3c-fd81cadf0743", - "user_data": "#!/bin/bash -xv\necho \"hello world\" > /root/hello-world.txt\n", - }, - }, - }, -} - -// GetOutput represents the response body from a Get request. -const GetOutput = ` -{ - "heat_template_version": "2013-05-23", - "description": "Simple template to test heat commands", - "parameters": { - "flavor": { - "default": "m1.tiny", - "type": "string" - } - }, - "resources": { - "hello_world": { - "type": "OS::Nova::Server", - "properties": { - "key_name": "heat_key", - "flavor": { - "get_param": "flavor" - }, - "image": "ad091b52-742f-469e-8f3c-fd81cadf0743", - "user_data": "#!/bin/bash -xv\necho \"hello world\" > /root/hello-world.txt\n" - } - } - } -}` - -// HandleGetSuccessfully creates an HTTP handler at `/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87/template` -// on the test handler mux that responds with a `Get` response. -func HandleGetSuccessfully(t *testing.T, output string) { - th.Mux.HandleFunc("/stacks/postman_stack/16ef0584-4458-41eb-87c8-0dc8d5f66c87/template", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, output) - }) -} - -// ValidateExpected represents the expected object from a Validate request. -var ValidateExpected = &ValidatedTemplate{ - Description: "Simple template to test heat commands", - Parameters: map[string]interface{}{ - "flavor": map[string]interface{}{ - "Default": "m1.tiny", - "Type": "String", - "NoEcho": "false", - "Description": "", - "Label": "flavor", - }, - }, -} - -// ValidateOutput represents the response body from a Validate request. -const ValidateOutput = ` -{ - "Description": "Simple template to test heat commands", - "Parameters": { - "flavor": { - "Default": "m1.tiny", - "Type": "String", - "NoEcho": "false", - "Description": "", - "Label": "flavor" - } - } -}` - -// HandleValidateSuccessfully creates an HTTP handler at `/validate` -// on the test handler mux that responds with a `Validate` response. -func HandleValidateSuccessfully(t *testing.T, output string) { - th.Mux.HandleFunc("/validate", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - th.TestHeader(t, r, "Accept", "application/json") - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, output) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates/requests.go deleted file mode 100644 index ad1e468d19..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates/requests.go +++ /dev/null @@ -1,58 +0,0 @@ -package stacktemplates - -import ( - "fmt" - - "github.com/rackspace/gophercloud" -) - -// Get retreives data for the given stack template. -func Get(c *gophercloud.ServiceClient, stackName, stackID string) GetResult { - var res GetResult - _, res.Err = c.Request("GET", getURL(c, stackName, stackID), gophercloud.RequestOpts{ - JSONResponse: &res.Body, - }) - return res -} - -// ValidateOptsBuilder describes struct types that can be accepted by the Validate call. -// The ValidateOpts struct in this package does. -type ValidateOptsBuilder interface { - ToStackTemplateValidateMap() (map[string]interface{}, error) -} - -// ValidateOpts specifies the template validation parameters. -type ValidateOpts struct { - Template map[string]interface{} - TemplateURL string -} - -// ToStackTemplateValidateMap assembles a request body based on the contents of a ValidateOpts. -func (opts ValidateOpts) ToStackTemplateValidateMap() (map[string]interface{}, error) { - vo := make(map[string]interface{}) - if opts.Template != nil { - vo["template"] = opts.Template - return vo, nil - } - if opts.TemplateURL != "" { - vo["template_url"] = opts.TemplateURL - return vo, nil - } - return vo, fmt.Errorf("One of Template or TemplateURL is required.") -} - -// Validate validates the given stack template. -func Validate(c *gophercloud.ServiceClient, opts ValidateOptsBuilder) ValidateResult { - var res ValidateResult - - reqBody, err := opts.ToStackTemplateValidateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = c.Post(validateURL(c), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates/results.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates/results.go deleted file mode 100644 index ac2f24b80b..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates/results.go +++ /dev/null @@ -1,60 +0,0 @@ -package stacktemplates - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" -) - -// Template represents a stack template. -type Template struct { - Description string `mapstructure:"description"` - HeatTemplateVersion string `mapstructure:"heat_template_version"` - Parameters map[string]interface{} `mapstructure:"parameters"` - Resources map[string]interface{} `mapstructure:"resources"` -} - -// GetResult represents the result of a Get operation. -type GetResult struct { - gophercloud.Result -} - -// Extract returns a pointer to a Template object and is called after a -// Get operation. -func (r GetResult) Extract() (*Template, error) { - if r.Err != nil { - return nil, r.Err - } - - var res Template - if err := mapstructure.Decode(r.Body, &res); err != nil { - return nil, err - } - - return &res, nil -} - -// ValidatedTemplate represents the parsed object returned from a Validate request. -type ValidatedTemplate struct { - Description string - Parameters map[string]interface{} -} - -// ValidateResult represents the result of a Validate operation. -type ValidateResult struct { - gophercloud.Result -} - -// Extract returns a pointer to a ValidatedTemplate object and is called after a -// Validate operation. -func (r ValidateResult) Extract() (*ValidatedTemplate, error) { - if r.Err != nil { - return nil, r.Err - } - - var res ValidatedTemplate - if err := mapstructure.Decode(r.Body, &res); err != nil { - return nil, err - } - - return &res, nil -} diff --git a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates/urls.go b/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates/urls.go deleted file mode 100644 index c30b7ca1af..0000000000 --- a/vendor/github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates/urls.go +++ /dev/null @@ -1,11 +0,0 @@ -package stacktemplates - -import "github.com/rackspace/gophercloud" - -func getURL(c *gophercloud.ServiceClient, stackName, stackID string) string { - return c.ServiceURL("stacks", stackName, stackID, "template") -} - -func validateURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL("validate") -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/snapshots/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/snapshots/delegate.go deleted file mode 100644 index 1cd1b6e30c..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/snapshots/delegate.go +++ /dev/null @@ -1,131 +0,0 @@ -package snapshots - -import ( - "errors" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" - - os "github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots" -) - -func updateURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL("snapshots", id) -} - -// CreateOptsBuilder allows extensions to add additional parameters to the -// Create request. -type CreateOptsBuilder interface { - ToSnapshotCreateMap() (map[string]interface{}, error) -} - -// CreateOpts contains options for creating a Snapshot. This object is passed to -// the snapshots.Create function. For more information about these parameters, -// see the Snapshot object. -type CreateOpts struct { - // REQUIRED - VolumeID string - // OPTIONAL - Description string - // OPTIONAL - Force bool - // OPTIONAL - Name string -} - -// ToSnapshotCreateMap assembles a request body based on the contents of a -// CreateOpts. -func (opts CreateOpts) ToSnapshotCreateMap() (map[string]interface{}, error) { - s := make(map[string]interface{}) - - if opts.VolumeID == "" { - return nil, errors.New("Required CreateOpts field 'VolumeID' not set.") - } - - s["volume_id"] = opts.VolumeID - - if opts.Description != "" { - s["display_description"] = opts.Description - } - if opts.Name != "" { - s["display_name"] = opts.Name - } - if opts.Force { - s["force"] = opts.Force - } - - return map[string]interface{}{"snapshot": s}, nil -} - -// Create will create a new Snapshot based on the values in CreateOpts. To -// extract the Snapshot object from the response, call the Extract method on the -// CreateResult. -func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult { - return CreateResult{os.Create(client, opts)} -} - -// Delete will delete the existing Snapshot with the provided ID. -func Delete(client *gophercloud.ServiceClient, id string) os.DeleteResult { - return os.Delete(client, id) -} - -// Get retrieves the Snapshot with the provided ID. To extract the Snapshot -// object from the response, call the Extract method on the GetResult. -func Get(client *gophercloud.ServiceClient, id string) GetResult { - return GetResult{os.Get(client, id)} -} - -// List returns Snapshots. -func List(client *gophercloud.ServiceClient) pagination.Pager { - return os.List(client, os.ListOpts{}) -} - -// UpdateOptsBuilder is the interface options structs have to satisfy in order -// to be used in the main Update operation in this package. Since many -// extensions decorate or modify the common logic, it is useful for them to -// satisfy a basic interface in order for them to be used. -type UpdateOptsBuilder interface { - ToSnapshotUpdateMap() (map[string]interface{}, error) -} - -// UpdateOpts is the common options struct used in this package's Update -// operation. -type UpdateOpts struct { - Name string - Description string -} - -// ToSnapshotUpdateMap casts a UpdateOpts struct to a map. -func (opts UpdateOpts) ToSnapshotUpdateMap() (map[string]interface{}, error) { - s := make(map[string]interface{}) - - if opts.Name != "" { - s["display_name"] = opts.Name - } - if opts.Description != "" { - s["display_description"] = opts.Description - } - - return map[string]interface{}{"snapshot": s}, nil -} - -// Update accepts a UpdateOpts struct and updates an existing snapshot using the -// values provided. -func Update(c *gophercloud.ServiceClient, snapshotID string, opts UpdateOptsBuilder) UpdateResult { - var res UpdateResult - - reqBody, err := opts.ToSnapshotUpdateMap() - if err != nil { - res.Err = err - return res - } - - // Send request to API - _, res.Err = c.Request("PUT", updateURL(c, snapshotID), gophercloud.RequestOpts{ - JSONBody: &reqBody, - JSONResponse: &res.Body, - OkCodes: []int{200, 201}, - }) - - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/snapshots/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/snapshots/doc.go deleted file mode 100644 index ad6064f2af..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/snapshots/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package snapshots provides information and interaction with the snapshot -// API resource for the Rackspace Block Storage service. -package snapshots diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/snapshots/results.go b/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/snapshots/results.go deleted file mode 100644 index c81644c5dd..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/snapshots/results.go +++ /dev/null @@ -1,147 +0,0 @@ -package snapshots - -import ( - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots" - "github.com/rackspace/gophercloud/pagination" - - "github.com/mitchellh/mapstructure" -) - -// Status is the type used to represent a snapshot's status -type Status string - -// Constants to use for supported statuses -const ( - Creating Status = "CREATING" - Available Status = "AVAILABLE" - Deleting Status = "DELETING" - Error Status = "ERROR" - DeleteError Status = "ERROR_DELETING" -) - -// Snapshot is the Rackspace representation of an external block storage device. -type Snapshot struct { - // The timestamp when this snapshot was created. - CreatedAt string `mapstructure:"created_at"` - - // The human-readable description for this snapshot. - Description string `mapstructure:"display_description"` - - // The human-readable name for this snapshot. - Name string `mapstructure:"display_name"` - - // The UUID for this snapshot. - ID string `mapstructure:"id"` - - // The random metadata associated with this snapshot. Note: unlike standard - // OpenStack snapshots, this cannot actually be set. - Metadata map[string]string `mapstructure:"metadata"` - - // Indicates the current progress of the snapshot's backup procedure. - Progress string `mapstructure:"os-extended-snapshot-attributes:progress"` - - // The project ID. - ProjectID string `mapstructure:"os-extended-snapshot-attributes:project_id"` - - // The size of the volume which this snapshot backs up. - Size int `mapstructure:"size"` - - // The status of the snapshot. - Status Status `mapstructure:"status"` - - // The ID of the volume which this snapshot seeks to back up. - VolumeID string `mapstructure:"volume_id"` -} - -// CreateResult represents the result of a create operation -type CreateResult struct { - os.CreateResult -} - -// GetResult represents the result of a get operation -type GetResult struct { - os.GetResult -} - -// UpdateResult represents the result of an update operation -type UpdateResult struct { - gophercloud.Result -} - -func commonExtract(resp interface{}, err error) (*Snapshot, error) { - if err != nil { - return nil, err - } - - var respStruct struct { - Snapshot *Snapshot `json:"snapshot"` - } - - err = mapstructure.Decode(resp, &respStruct) - - return respStruct.Snapshot, err -} - -// Extract will get the Snapshot object out of the GetResult object. -func (r GetResult) Extract() (*Snapshot, error) { - return commonExtract(r.Body, r.Err) -} - -// Extract will get the Snapshot object out of the CreateResult object. -func (r CreateResult) Extract() (*Snapshot, error) { - return commonExtract(r.Body, r.Err) -} - -// Extract will get the Snapshot object out of the UpdateResult object. -func (r UpdateResult) Extract() (*Snapshot, error) { - return commonExtract(r.Body, r.Err) -} - -// ExtractSnapshots extracts and returns Snapshots. It is used while iterating over a snapshots.List call. -func ExtractSnapshots(page pagination.Page) ([]Snapshot, error) { - var response struct { - Snapshots []Snapshot `json:"snapshots"` - } - - err := mapstructure.Decode(page.(os.ListResult).Body, &response) - return response.Snapshots, err -} - -// WaitUntilComplete will continually poll a snapshot until it successfully -// transitions to a specified state. It will do this for at most the number of -// seconds specified. -func (snapshot Snapshot) WaitUntilComplete(c *gophercloud.ServiceClient, timeout int) error { - return gophercloud.WaitFor(timeout, func() (bool, error) { - // Poll resource - current, err := Get(c, snapshot.ID).Extract() - if err != nil { - return false, err - } - - // Has it been built yet? - if current.Progress == "100%" { - return true, nil - } - - return false, nil - }) -} - -// WaitUntilDeleted will continually poll a snapshot until it has been -// successfully deleted, i.e. returns a 404 status. -func (snapshot Snapshot) WaitUntilDeleted(c *gophercloud.ServiceClient, timeout int) error { - return gophercloud.WaitFor(timeout, func() (bool, error) { - // Poll resource - _, err := Get(c, snapshot.ID).Extract() - - // Check for a 404 - if casted, ok := err.(*gophercloud.UnexpectedResponseCodeError); ok && casted.Actual == 404 { - return true, nil - } else if err != nil { - return false, err - } - - return false, nil - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumes/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumes/delegate.go deleted file mode 100644 index 438349410a..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumes/delegate.go +++ /dev/null @@ -1,75 +0,0 @@ -package volumes - -import ( - "fmt" - - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes" - "github.com/rackspace/gophercloud/pagination" -) - -type CreateOpts struct { - os.CreateOpts -} - -func (opts CreateOpts) ToVolumeCreateMap() (map[string]interface{}, error) { - if opts.Size < 75 || opts.Size > 1024 { - return nil, fmt.Errorf("Size field must be between 75 and 1024") - } - - return opts.CreateOpts.ToVolumeCreateMap() -} - -// Create will create a new Volume based on the values in CreateOpts. To extract -// the Volume object from the response, call the Extract method on the -// CreateResult. -func Create(client *gophercloud.ServiceClient, opts os.CreateOptsBuilder) CreateResult { - return CreateResult{os.Create(client, opts)} -} - -// Delete will delete the existing Volume with the provided ID. -func Delete(client *gophercloud.ServiceClient, id string) os.DeleteResult { - return os.Delete(client, id) -} - -// Get retrieves the Volume with the provided ID. To extract the Volume object -// from the response, call the Extract method on the GetResult. -func Get(client *gophercloud.ServiceClient, id string) GetResult { - return GetResult{os.Get(client, id)} -} - -// List returns volumes optionally limited by the conditions provided in ListOpts. -func List(client *gophercloud.ServiceClient) pagination.Pager { - return os.List(client, os.ListOpts{}) -} - -// UpdateOpts contain options for updating an existing Volume. This object is passed -// to the volumes.Update function. For more information about the parameters, see -// the Volume object. -type UpdateOpts struct { - // OPTIONAL - Name string - // OPTIONAL - Description string -} - -// ToVolumeUpdateMap assembles a request body based on the contents of an -// UpdateOpts. -func (opts UpdateOpts) ToVolumeUpdateMap() (map[string]interface{}, error) { - v := make(map[string]interface{}) - - if opts.Description != "" { - v["display_description"] = opts.Description - } - if opts.Name != "" { - v["display_name"] = opts.Name - } - - return map[string]interface{}{"volume": v}, nil -} - -// Update will update the Volume with provided information. To extract the updated -// Volume from the response, call the Extract method on the UpdateResult. -func Update(client *gophercloud.ServiceClient, id string, opts os.UpdateOptsBuilder) UpdateResult { - return UpdateResult{os.Update(client, id, opts)} -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumes/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumes/doc.go deleted file mode 100644 index b2be25c538..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumes/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package volumes provides information and interaction with the volume -// API resource for the Rackspace Block Storage service. -package volumes diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumes/results.go b/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumes/results.go deleted file mode 100644 index c7c2cc4984..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumes/results.go +++ /dev/null @@ -1,66 +0,0 @@ -package volumes - -import ( - os "github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes" - "github.com/rackspace/gophercloud/pagination" - - "github.com/mitchellh/mapstructure" -) - -// Volume wraps an Openstack volume -type Volume os.Volume - -// CreateResult represents the result of a create operation -type CreateResult struct { - os.CreateResult -} - -// GetResult represents the result of a get operation -type GetResult struct { - os.GetResult -} - -// UpdateResult represents the result of an update operation -type UpdateResult struct { - os.UpdateResult -} - -func commonExtract(resp interface{}, err error) (*Volume, error) { - if err != nil { - return nil, err - } - - var respStruct struct { - Volume *Volume `json:"volume"` - } - - err = mapstructure.Decode(resp, &respStruct) - - return respStruct.Volume, err -} - -// Extract will get the Volume object out of the GetResult object. -func (r GetResult) Extract() (*Volume, error) { - return commonExtract(r.Body, r.Err) -} - -// Extract will get the Volume object out of the CreateResult object. -func (r CreateResult) Extract() (*Volume, error) { - return commonExtract(r.Body, r.Err) -} - -// Extract will get the Volume object out of the UpdateResult object. -func (r UpdateResult) Extract() (*Volume, error) { - return commonExtract(r.Body, r.Err) -} - -// ExtractVolumes extracts and returns Volumes. It is used while iterating over a volumes.List call. -func ExtractVolumes(page pagination.Page) ([]Volume, error) { - var response struct { - Volumes []Volume `json:"volumes"` - } - - err := mapstructure.Decode(page.(os.ListResult).Body, &response) - - return response.Volumes, err -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumetypes/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumetypes/delegate.go deleted file mode 100644 index c96b3e4a35..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumetypes/delegate.go +++ /dev/null @@ -1,18 +0,0 @@ -package volumetypes - -import ( - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes" - "github.com/rackspace/gophercloud/pagination" -) - -// List returns all volume types. -func List(client *gophercloud.ServiceClient) pagination.Pager { - return os.List(client) -} - -// Get will retrieve the volume type with the provided ID. To extract the volume -// type from the result, call the Extract method on the GetResult. -func Get(client *gophercloud.ServiceClient, id string) GetResult { - return GetResult{os.Get(client, id)} -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumetypes/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumetypes/doc.go deleted file mode 100644 index 70122b77c4..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumetypes/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package volumetypes provides information and interaction with the volume type -// API resource for the Rackspace Block Storage service. -package volumetypes diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumetypes/results.go b/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumetypes/results.go deleted file mode 100644 index 39c8d6f7fa..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/blockstorage/v1/volumetypes/results.go +++ /dev/null @@ -1,37 +0,0 @@ -package volumetypes - -import ( - "github.com/mitchellh/mapstructure" - os "github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes" - "github.com/rackspace/gophercloud/pagination" -) - -type VolumeType os.VolumeType - -type GetResult struct { - os.GetResult -} - -// Extract will get the Volume Type struct out of the response. -func (r GetResult) Extract() (*VolumeType, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - VolumeType *VolumeType `json:"volume_type" mapstructure:"volume_type"` - } - - err := mapstructure.Decode(r.Body, &res) - - return res.VolumeType, err -} - -func ExtractVolumeTypes(page pagination.Page) ([]VolumeType, error) { - var response struct { - VolumeTypes []VolumeType `mapstructure:"volume_types"` - } - - err := mapstructure.Decode(page.(os.ListResult).Body, &response) - return response.VolumeTypes, err -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/base/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/base/delegate.go deleted file mode 100644 index 5af7e07784..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/base/delegate.go +++ /dev/null @@ -1,18 +0,0 @@ -package base - -import ( - "github.com/rackspace/gophercloud" - - os "github.com/rackspace/gophercloud/openstack/cdn/v1/base" -) - -// Get retrieves the home document, allowing the user to discover the -// entire API. -func Get(c *gophercloud.ServiceClient) os.GetResult { - return os.Get(c) -} - -// Ping retrieves a ping to the server. -func Ping(c *gophercloud.ServiceClient) os.PingResult { - return os.Ping(c) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/base/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/base/doc.go deleted file mode 100644 index 5582306a8e..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/base/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -// Package base provides information and interaction with the base API -// resource in the Rackspace CDN service. This API resource allows for -// retrieving the Home Document and pinging the root URL. -package base diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/flavors/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/flavors/delegate.go deleted file mode 100644 index 7152fa23af..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/flavors/delegate.go +++ /dev/null @@ -1,18 +0,0 @@ -package flavors - -import ( - "github.com/rackspace/gophercloud" - - os "github.com/rackspace/gophercloud/openstack/cdn/v1/flavors" - "github.com/rackspace/gophercloud/pagination" -) - -// List returns a single page of CDN flavors. -func List(c *gophercloud.ServiceClient) pagination.Pager { - return os.List(c) -} - -// Get retrieves a specific flavor based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) os.GetResult { - return os.Get(c, id) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/flavors/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/flavors/doc.go deleted file mode 100644 index 4ad966eac8..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/flavors/doc.go +++ /dev/null @@ -1,6 +0,0 @@ -// Package flavors provides information and interaction with the flavors API -// resource in the Rackspace CDN service. This API resource allows for -// listing flavors and retrieving a specific flavor. -// -// A flavor is a mapping configuration to a CDN provider. -package flavors diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/serviceassets/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/serviceassets/delegate.go deleted file mode 100644 index 07c93a8dcd..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/serviceassets/delegate.go +++ /dev/null @@ -1,13 +0,0 @@ -package serviceassets - -import ( - "github.com/rackspace/gophercloud" - - os "github.com/rackspace/gophercloud/openstack/cdn/v1/serviceassets" -) - -// Delete accepts a unique ID and deletes the CDN service asset associated with -// it. -func Delete(c *gophercloud.ServiceClient, id string, opts os.DeleteOptsBuilder) os.DeleteResult { - return os.Delete(c, id, opts) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/serviceassets/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/serviceassets/doc.go deleted file mode 100644 index 46b3d50a81..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/serviceassets/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -// Package serviceassets provides information and interaction with the -// serviceassets API resource in the Rackspace CDN service. This API resource -// allows for deleting cached assets. -// -// A service distributes assets across the network. Service assets let you -// interrogate properties about these assets and perform certain actions on them. -package serviceassets diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/services/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/services/delegate.go deleted file mode 100644 index e3f1459977..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/services/delegate.go +++ /dev/null @@ -1,37 +0,0 @@ -package services - -import ( - "github.com/rackspace/gophercloud" - - os "github.com/rackspace/gophercloud/openstack/cdn/v1/services" - "github.com/rackspace/gophercloud/pagination" -) - -// List returns a Pager which allows you to iterate over a collection of -// CDN services. It accepts a ListOpts struct, which allows for pagination via -// marker and limit. -func List(c *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager { - return os.List(c, opts) -} - -// Create accepts a CreateOpts struct and creates a new CDN service using the -// values provided. -func Create(c *gophercloud.ServiceClient, opts os.CreateOptsBuilder) os.CreateResult { - return os.Create(c, opts) -} - -// Get retrieves a specific service based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) os.GetResult { - return os.Get(c, id) -} - -// Update accepts a UpdateOpts struct and updates an existing CDN service using -// the values provided. -func Update(c *gophercloud.ServiceClient, id string, patches []os.Patch) os.UpdateResult { - return os.Update(c, id, patches) -} - -// Delete accepts a unique ID and deletes the CDN service associated with it. -func Delete(c *gophercloud.ServiceClient, id string) os.DeleteResult { - return os.Delete(c, id) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/services/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/services/doc.go deleted file mode 100644 index ee6e2a54fc..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/cdn/v1/services/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -// Package services provides information and interaction with the services API -// resource in the Rackspace CDN service. This API resource allows for -// listing, creating, updating, retrieving, and deleting services. -// -// A service represents an application that has its content cached to the edge -// nodes. -package services diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/bootfromvolume/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/bootfromvolume/delegate.go deleted file mode 100644 index 2580459f07..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/bootfromvolume/delegate.go +++ /dev/null @@ -1,12 +0,0 @@ -package bootfromvolume - -import ( - "github.com/rackspace/gophercloud" - osBFV "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume" - osServers "github.com/rackspace/gophercloud/openstack/compute/v2/servers" -) - -// Create requests the creation of a server from the given block device mapping. -func Create(client *gophercloud.ServiceClient, opts osServers.CreateOptsBuilder) osServers.CreateResult { - return osBFV.Create(client, opts) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/flavors/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/flavors/delegate.go deleted file mode 100644 index 6bfc20c564..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/flavors/delegate.go +++ /dev/null @@ -1,46 +0,0 @@ -package flavors - -import ( - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/compute/v2/flavors" - "github.com/rackspace/gophercloud/pagination" -) - -// ListOpts helps control the results returned by the List() function. For example, a flavor with a -// minDisk field of 10 will not be returned if you specify MinDisk set to 20. -type ListOpts struct { - - // MinDisk and MinRAM, if provided, elide flavors that do not meet your criteria. - MinDisk int `q:"minDisk"` - MinRAM int `q:"minRam"` - - // Marker specifies the ID of the last flavor in the previous page. - Marker string `q:"marker"` - - // Limit instructs List to refrain from sending excessively large lists of flavors. - Limit int `q:"limit"` -} - -// ToFlavorListQuery formats a ListOpts into a query string. -func (opts ListOpts) ToFlavorListQuery() (string, error) { - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return "", err - } - return q.String(), nil -} - -// ListDetail enumerates the server images available to your account. -func ListDetail(client *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager { - return os.ListDetail(client, opts) -} - -// Get returns details about a single flavor, identity by ID. -func Get(client *gophercloud.ServiceClient, id string) os.GetResult { - return os.Get(client, id) -} - -// ExtractFlavors interprets a page of List results as Flavors. -func ExtractFlavors(page pagination.Page) ([]os.Flavor, error) { - return os.ExtractFlavors(page) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/flavors/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/flavors/doc.go deleted file mode 100644 index 278229ab97..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/flavors/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package flavors provides information and interaction with the flavor -// API resource for the Rackspace Cloud Servers service. -package flavors diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/flavors/fixtures.go b/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/flavors/fixtures.go deleted file mode 100644 index 894f916f67..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/flavors/fixtures.go +++ /dev/null @@ -1,129 +0,0 @@ -// +build fixtures - -package flavors - -import ( - os "github.com/rackspace/gophercloud/openstack/compute/v2/flavors" -) - -// ListOutput is a sample response of a flavor List request. -const ListOutput = ` -{ - "flavors": [ - { - "OS-FLV-EXT-DATA:ephemeral": 0, - "OS-FLV-WITH-EXT-SPECS:extra_specs": { - "class": "performance1", - "disk_io_index": "40", - "number_of_data_disks": "0", - "policy_class": "performance_flavor", - "resize_policy_class": "performance_flavor" - }, - "disk": 20, - "id": "performance1-1", - "links": [ - { - "href": "https://iad.servers.api.rackspacecloud.com/v2/864477/flavors/performance1-1", - "rel": "self" - }, - { - "href": "https://iad.servers.api.rackspacecloud.com/864477/flavors/performance1-1", - "rel": "bookmark" - } - ], - "name": "1 GB Performance", - "ram": 1024, - "rxtx_factor": 200, - "swap": "", - "vcpus": 1 - }, - { - "OS-FLV-EXT-DATA:ephemeral": 20, - "OS-FLV-WITH-EXT-SPECS:extra_specs": { - "class": "performance1", - "disk_io_index": "40", - "number_of_data_disks": "1", - "policy_class": "performance_flavor", - "resize_policy_class": "performance_flavor" - }, - "disk": 40, - "id": "performance1-2", - "links": [ - { - "href": "https://iad.servers.api.rackspacecloud.com/v2/864477/flavors/performance1-2", - "rel": "self" - }, - { - "href": "https://iad.servers.api.rackspacecloud.com/864477/flavors/performance1-2", - "rel": "bookmark" - } - ], - "name": "2 GB Performance", - "ram": 2048, - "rxtx_factor": 400, - "swap": "", - "vcpus": 2 - } - ] -}` - -// GetOutput is a sample response from a flavor Get request. Its contents correspond to the -// Performance1Flavor struct. -const GetOutput = ` -{ - "flavor": { - "OS-FLV-EXT-DATA:ephemeral": 0, - "OS-FLV-WITH-EXT-SPECS:extra_specs": { - "class": "performance1", - "disk_io_index": "40", - "number_of_data_disks": "0", - "policy_class": "performance_flavor", - "resize_policy_class": "performance_flavor" - }, - "disk": 20, - "id": "performance1-1", - "links": [ - { - "href": "https://iad.servers.api.rackspacecloud.com/v2/864477/flavors/performance1-1", - "rel": "self" - }, - { - "href": "https://iad.servers.api.rackspacecloud.com/864477/flavors/performance1-1", - "rel": "bookmark" - } - ], - "name": "1 GB Performance", - "ram": 1024, - "rxtx_factor": 200, - "swap": "", - "vcpus": 1 - } -} -` - -// Performance1Flavor is the expected result of parsing GetOutput, or the first element of -// ListOutput. -var Performance1Flavor = os.Flavor{ - ID: "performance1-1", - Disk: 20, - RAM: 1024, - Name: "1 GB Performance", - RxTxFactor: 200.0, - Swap: 0, - VCPUs: 1, -} - -// Performance2Flavor is the second result expected from parsing ListOutput. -var Performance2Flavor = os.Flavor{ - ID: "performance1-2", - Disk: 40, - RAM: 2048, - Name: "2 GB Performance", - RxTxFactor: 400.0, - Swap: 0, - VCPUs: 2, -} - -// ExpectedFlavorSlice is the slice of Flavor structs that are expected to be parsed from -// ListOutput. -var ExpectedFlavorSlice = []os.Flavor{Performance1Flavor, Performance2Flavor} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/images/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/images/delegate.go deleted file mode 100644 index 18e1f315af..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/images/delegate.go +++ /dev/null @@ -1,22 +0,0 @@ -package images - -import ( - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/compute/v2/images" - "github.com/rackspace/gophercloud/pagination" -) - -// ListDetail enumerates the available server images. -func ListDetail(client *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager { - return os.ListDetail(client, opts) -} - -// Get acquires additional detail about a specific image by ID. -func Get(client *gophercloud.ServiceClient, id string) os.GetResult { - return os.Get(client, id) -} - -// ExtractImages interprets a page as a collection of server images. -func ExtractImages(page pagination.Page) ([]os.Image, error) { - return os.ExtractImages(page) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/images/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/images/doc.go deleted file mode 100644 index cfae806712..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/images/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package images provides information and interaction with the image -// API resource for the Rackspace Cloud Servers service. -package images diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/images/fixtures.go b/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/images/fixtures.go deleted file mode 100644 index ccfbdc6a1e..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/images/fixtures.go +++ /dev/null @@ -1,200 +0,0 @@ -// +build fixtures - -package images - -import ( - os "github.com/rackspace/gophercloud/openstack/compute/v2/images" -) - -// ListOutput is an example response from an /images/detail request. -const ListOutput = ` -{ - "images": [ - { - "OS-DCF:diskConfig": "MANUAL", - "OS-EXT-IMG-SIZE:size": 1.017415075e+09, - "created": "2014-10-01T15:49:02Z", - "id": "30aa010e-080e-4d4b-a7f9-09fc55b07d69", - "links": [ - { - "href": "https://iad.servers.api.rackspacecloud.com/v2/111222/images/30aa010e-080e-4d4b-a7f9-09fc55b07d69", - "rel": "self" - }, - { - "href": "https://iad.servers.api.rackspacecloud.com/111222/images/30aa010e-080e-4d4b-a7f9-09fc55b07d69", - "rel": "bookmark" - }, - { - "href": "https://iad.servers.api.rackspacecloud.com/111222/images/30aa010e-080e-4d4b-a7f9-09fc55b07d69", - "rel": "alternate", - "type": "application/vnd.openstack.image" - } - ], - "metadata": { - "auto_disk_config": "disabled", - "cache_in_nova": "True", - "com.rackspace__1__build_core": "1", - "com.rackspace__1__build_managed": "1", - "com.rackspace__1__build_rackconnect": "1", - "com.rackspace__1__options": "0", - "com.rackspace__1__platform_target": "PublicCloud", - "com.rackspace__1__release_build_date": "2014-10-01_15-46-08", - "com.rackspace__1__release_id": "100", - "com.rackspace__1__release_version": "10", - "com.rackspace__1__source": "kickstart", - "com.rackspace__1__visible_core": "1", - "com.rackspace__1__visible_managed": "0", - "com.rackspace__1__visible_rackconnect": "0", - "image_type": "base", - "org.openstack__1__architecture": "x64", - "org.openstack__1__os_distro": "org.archlinux", - "org.openstack__1__os_version": "2014.8", - "os_distro": "arch", - "os_type": "linux", - "vm_mode": "hvm" - }, - "minDisk": 20, - "minRam": 512, - "name": "Arch 2014.10 (PVHVM)", - "progress": 100, - "status": "ACTIVE", - "updated": "2014-10-01T19:37:58Z" - }, - { - "OS-DCF:diskConfig": "AUTO", - "OS-EXT-IMG-SIZE:size": 1.060306463e+09, - "created": "2014-10-01T12:58:11Z", - "id": "e19a734c-c7e6-443a-830c-242209c4d65d", - "links": [ - { - "href": "https://iad.servers.api.rackspacecloud.com/v2/111222/images/e19a734c-c7e6-443a-830c-242209c4d65d", - "rel": "self" - }, - { - "href": "https://iad.servers.api.rackspacecloud.com/111222/images/e19a734c-c7e6-443a-830c-242209c4d65d", - "rel": "bookmark" - }, - { - "href": "https://iad.servers.api.rackspacecloud.com/111222/images/e19a734c-c7e6-443a-830c-242209c4d65d", - "rel": "alternate", - "type": "application/vnd.openstack.image" - } - ], - "metadata": { - "auto_disk_config": "True", - "cache_in_nova": "True", - "com.rackspace__1__build_core": "1", - "com.rackspace__1__build_managed": "1", - "com.rackspace__1__build_rackconnect": "1", - "com.rackspace__1__options": "0", - "com.rackspace__1__platform_target": "PublicCloud", - "com.rackspace__1__release_build_date": "2014-10-01_12-31-03", - "com.rackspace__1__release_id": "1007", - "com.rackspace__1__release_version": "6", - "com.rackspace__1__source": "kickstart", - "com.rackspace__1__visible_core": "1", - "com.rackspace__1__visible_managed": "1", - "com.rackspace__1__visible_rackconnect": "1", - "image_type": "base", - "org.openstack__1__architecture": "x64", - "org.openstack__1__os_distro": "com.ubuntu", - "org.openstack__1__os_version": "14.04", - "os_distro": "ubuntu", - "os_type": "linux", - "vm_mode": "xen" - }, - "minDisk": 20, - "minRam": 512, - "name": "Ubuntu 14.04 LTS (Trusty Tahr)", - "progress": 100, - "status": "ACTIVE", - "updated": "2014-10-01T15:51:44Z" - } - ] -} -` - -// GetOutput is an example response from an /images request. -const GetOutput = ` -{ - "image": { - "OS-DCF:diskConfig": "AUTO", - "OS-EXT-IMG-SIZE:size": 1060306463, - "created": "2014-10-01T12:58:11Z", - "id": "e19a734c-c7e6-443a-830c-242209c4d65d", - "links": [ - { - "href": "https://iad.servers.api.rackspacecloud.com/v2/111222/images/e19a734c-c7e6-443a-830c-242209c4d65d", - "rel": "self" - }, - { - "href": "https://iad.servers.api.rackspacecloud.com/111222/images/e19a734c-c7e6-443a-830c-242209c4d65d", - "rel": "bookmark" - }, - { - "href": "https://iad.servers.api.rackspacecloud.com/111222/images/e19a734c-c7e6-443a-830c-242209c4d65d", - "rel": "alternate", - "type": "application/vnd.openstack.image" - } - ], - "metadata": { - "auto_disk_config": "True", - "cache_in_nova": "True", - "com.rackspace__1__build_core": "1", - "com.rackspace__1__build_managed": "1", - "com.rackspace__1__build_rackconnect": "1", - "com.rackspace__1__options": "0", - "com.rackspace__1__platform_target": "PublicCloud", - "com.rackspace__1__release_build_date": "2014-10-01_12-31-03", - "com.rackspace__1__release_id": "1007", - "com.rackspace__1__release_version": "6", - "com.rackspace__1__source": "kickstart", - "com.rackspace__1__visible_core": "1", - "com.rackspace__1__visible_managed": "1", - "com.rackspace__1__visible_rackconnect": "1", - "image_type": "base", - "org.openstack__1__architecture": "x64", - "org.openstack__1__os_distro": "com.ubuntu", - "org.openstack__1__os_version": "14.04", - "os_distro": "ubuntu", - "os_type": "linux", - "vm_mode": "xen" - }, - "minDisk": 20, - "minRam": 512, - "name": "Ubuntu 14.04 LTS (Trusty Tahr)", - "progress": 100, - "status": "ACTIVE", - "updated": "2014-10-01T15:51:44Z" - } -} -` - -// ArchImage is the first Image structure that should be parsed from ListOutput. -var ArchImage = os.Image{ - ID: "30aa010e-080e-4d4b-a7f9-09fc55b07d69", - Name: "Arch 2014.10 (PVHVM)", - Created: "2014-10-01T15:49:02Z", - Updated: "2014-10-01T19:37:58Z", - MinDisk: 20, - MinRAM: 512, - Progress: 100, - Status: "ACTIVE", -} - -// UbuntuImage is the second Image structure that should be parsed from ListOutput and -// the only image that should be extracted from GetOutput. -var UbuntuImage = os.Image{ - ID: "e19a734c-c7e6-443a-830c-242209c4d65d", - Name: "Ubuntu 14.04 LTS (Trusty Tahr)", - Created: "2014-10-01T12:58:11Z", - Updated: "2014-10-01T15:51:44Z", - MinDisk: 20, - MinRAM: 512, - Progress: 100, - Status: "ACTIVE", -} - -// ExpectedImageSlice is the collection of images that should be parsed from ListOutput, -// in order. -var ExpectedImageSlice = []os.Image{ArchImage, UbuntuImage} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/keypairs/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/keypairs/delegate.go deleted file mode 100644 index 3e53525dc7..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/keypairs/delegate.go +++ /dev/null @@ -1,33 +0,0 @@ -package keypairs - -import ( - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/keypairs" - "github.com/rackspace/gophercloud/pagination" -) - -// List returns a Pager that allows you to iterate over a collection of KeyPairs. -func List(client *gophercloud.ServiceClient) pagination.Pager { - return os.List(client) -} - -// Create requests the creation of a new keypair on the server, or to import a pre-existing -// keypair. -func Create(client *gophercloud.ServiceClient, opts os.CreateOptsBuilder) os.CreateResult { - return os.Create(client, opts) -} - -// Get returns public data about a previously uploaded KeyPair. -func Get(client *gophercloud.ServiceClient, name string) os.GetResult { - return os.Get(client, name) -} - -// Delete requests the deletion of a previous stored KeyPair from the server. -func Delete(client *gophercloud.ServiceClient, name string) os.DeleteResult { - return os.Delete(client, name) -} - -// ExtractKeyPairs interprets a page of results as a slice of KeyPairs. -func ExtractKeyPairs(page pagination.Page) ([]os.KeyPair, error) { - return os.ExtractKeyPairs(page) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/keypairs/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/keypairs/doc.go deleted file mode 100644 index 31713752ea..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/keypairs/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package keypairs provides information and interaction with the keypair -// API resource for the Rackspace Cloud Servers service. -package keypairs diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/networks/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/networks/doc.go deleted file mode 100644 index 8e5c77382d..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/networks/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package networks provides information and interaction with the network -// API resource for the Rackspace Cloud Servers service. -package networks diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/networks/requests.go b/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/networks/requests.go deleted file mode 100644 index cebbffd36a..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/networks/requests.go +++ /dev/null @@ -1,89 +0,0 @@ -package networks - -import ( - "errors" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// List returns a Pager which allows you to iterate over a collection of -// networks. It accepts a ListOpts struct, which allows you to filter and sort -// the returned collection for greater efficiency. -func List(c *gophercloud.ServiceClient) pagination.Pager { - createPage := func(r pagination.PageResult) pagination.Page { - return NetworkPage{pagination.SinglePageBase(r)} - } - - return pagination.NewPager(c, listURL(c), createPage) -} - -// Get retrieves a specific network based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) GetResult { - var res GetResult - _, res.Err = c.Get(getURL(c, id), &res.Body, nil) - return res -} - -// CreateOptsBuilder is the interface options structs have to satisfy in order -// to be used in the main Create operation in this package. Since many -// extensions decorate or modify the common logic, it is useful for them to -// satisfy a basic interface in order for them to be used. -type CreateOptsBuilder interface { - ToNetworkCreateMap() (map[string]interface{}, error) -} - -// CreateOpts is the common options struct used in this package's Create -// operation. -type CreateOpts struct { - // REQUIRED. See Network object for more info. - CIDR string - // REQUIRED. See Network object for more info. - Label string -} - -// ToNetworkCreateMap casts a CreateOpts struct to a map. -func (opts CreateOpts) ToNetworkCreateMap() (map[string]interface{}, error) { - n := make(map[string]interface{}) - - if opts.CIDR == "" { - return nil, errors.New("Required field CIDR not set.") - } - if opts.Label == "" { - return nil, errors.New("Required field Label not set.") - } - - n["label"] = opts.Label - n["cidr"] = opts.CIDR - return map[string]interface{}{"network": n}, nil -} - -// Create accepts a CreateOpts struct and creates a new network using the values -// provided. This operation does not actually require a request body, i.e. the -// CreateOpts struct argument can be empty. -// -// The tenant ID that is contained in the URI is the tenant that creates the -// network. An admin user, however, has the option of specifying another tenant -// ID in the CreateOpts struct. -func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult { - var res CreateResult - - reqBody, err := opts.ToNetworkCreateMap() - if err != nil { - res.Err = err - return res - } - - // Send request to API - _, res.Err = c.Post(createURL(c), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200, 201, 202}, - }) - return res -} - -// Delete accepts a unique ID and deletes the network associated with it. -func Delete(c *gophercloud.ServiceClient, networkID string) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(deleteURL(c, networkID), nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/networks/results.go b/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/networks/results.go deleted file mode 100644 index eb6a76c008..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/networks/results.go +++ /dev/null @@ -1,81 +0,0 @@ -package networks - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -type commonResult struct { - gophercloud.Result -} - -// Extract is a function that accepts a result and extracts a network resource. -func (r commonResult) Extract() (*Network, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - Network *Network `json:"network"` - } - - err := mapstructure.Decode(r.Body, &res) - - return res.Network, err -} - -// CreateResult represents the result of a create operation. -type CreateResult struct { - commonResult -} - -// GetResult represents the result of a get operation. -type GetResult struct { - commonResult -} - -// DeleteResult represents the result of a delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} - -// Network represents, well, a network. -type Network struct { - // UUID for the network - ID string `mapstructure:"id" json:"id"` - - // Human-readable name for the network. Might not be unique. - Label string `mapstructure:"label" json:"label"` - - // Classless Inter-Domain Routing - CIDR string `mapstructure:"cidr" json:"cidr"` -} - -// NetworkPage is the page returned by a pager when traversing over a -// collection of networks. -type NetworkPage struct { - pagination.SinglePageBase -} - -// IsEmpty returns true if the NetworkPage contains no Networks. -func (r NetworkPage) IsEmpty() (bool, error) { - networks, err := ExtractNetworks(r) - if err != nil { - return true, err - } - return len(networks) == 0, nil -} - -// ExtractNetworks accepts a Page struct, specifically a NetworkPage struct, -// and extracts the elements into a slice of Network structs. In other words, -// a generic collection is mapped into a relevant slice. -func ExtractNetworks(page pagination.Page) ([]Network, error) { - var resp struct { - Networks []Network `mapstructure:"networks" json:"networks"` - } - - err := mapstructure.Decode(page.(NetworkPage).Body, &resp) - - return resp.Networks, err -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/networks/urls.go b/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/networks/urls.go deleted file mode 100644 index 19a21aa90d..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/networks/urls.go +++ /dev/null @@ -1,27 +0,0 @@ -package networks - -import "github.com/rackspace/gophercloud" - -func resourceURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL("os-networksv2", id) -} - -func rootURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL("os-networksv2") -} - -func getURL(c *gophercloud.ServiceClient, id string) string { - return resourceURL(c, id) -} - -func listURL(c *gophercloud.ServiceClient) string { - return rootURL(c) -} - -func createURL(c *gophercloud.ServiceClient) string { - return rootURL(c) -} - -func deleteURL(c *gophercloud.ServiceClient, id string) string { - return resourceURL(c, id) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/servers/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/servers/delegate.go deleted file mode 100644 index 7810d156a0..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/servers/delegate.go +++ /dev/null @@ -1,116 +0,0 @@ -package servers - -import ( - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/compute/v2/servers" - "github.com/rackspace/gophercloud/pagination" -) - -// List makes a request against the API to list servers accessible to you. -func List(client *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager { - return os.List(client, opts) -} - -// Create requests a server to be provisioned to the user in the current tenant. -func Create(client *gophercloud.ServiceClient, opts os.CreateOptsBuilder) os.CreateResult { - return os.Create(client, opts) -} - -// Update requests an existing server to be updated with the supplied options. -func Update(client *gophercloud.ServiceClient, id string, opts os.UpdateOptsBuilder) os.UpdateResult { - return os.Update(client, id, opts) -} - -// Delete requests that a server previously provisioned be removed from your account. -func Delete(client *gophercloud.ServiceClient, id string) os.DeleteResult { - return os.Delete(client, id) -} - -// Get requests details on a single server, by ID. -func Get(client *gophercloud.ServiceClient, id string) os.GetResult { - return os.Get(client, id) -} - -// ChangeAdminPassword alters the administrator or root password for a specified server. -func ChangeAdminPassword(client *gophercloud.ServiceClient, id, newPassword string) os.ActionResult { - return os.ChangeAdminPassword(client, id, newPassword) -} - -// Reboot requests that a given server reboot. Two methods exist for rebooting a server: -// -// os.HardReboot (aka PowerCycle) restarts the server instance by physically cutting power to the -// machine, or if a VM, terminating it at the hypervisor level. It's done. Caput. Full stop. Then, -// after a brief wait, power is restored or the VM instance restarted. -// -// os.SoftReboot (aka OSReboot) simply tells the OS to restart under its own procedures. E.g., in -// Linux, asking it to enter runlevel 6, or executing "sudo shutdown -r now", or by asking Windows to restart the machine. -func Reboot(client *gophercloud.ServiceClient, id string, how os.RebootMethod) os.ActionResult { - return os.Reboot(client, id, how) -} - -// Rebuild will reprovision the server according to the configuration options provided in the -// RebuildOpts struct. -func Rebuild(client *gophercloud.ServiceClient, id string, opts os.RebuildOptsBuilder) os.RebuildResult { - return os.Rebuild(client, id, opts) -} - -// Resize instructs the provider to change the flavor of the server. -// Note that this implies rebuilding it. -// Unfortunately, one cannot pass rebuild parameters to the resize function. -// When the resize completes, the server will be in RESIZE_VERIFY state. -// While in this state, you can explore the use of the new server's configuration. -// If you like it, call ConfirmResize() to commit the resize permanently. -// Otherwise, call RevertResize() to restore the old configuration. -func Resize(client *gophercloud.ServiceClient, id string, opts os.ResizeOptsBuilder) os.ActionResult { - return os.Resize(client, id, opts) -} - -// ConfirmResize confirms a previous resize operation on a server. -// See Resize() for more details. -func ConfirmResize(client *gophercloud.ServiceClient, id string) os.ActionResult { - return os.ConfirmResize(client, id) -} - -// WaitForStatus will continually poll a server until it successfully transitions to a specified -// status. It will do this for at most the number of seconds specified. -func WaitForStatus(c *gophercloud.ServiceClient, id, status string, secs int) error { - return os.WaitForStatus(c, id, status, secs) -} - -// ExtractServers interprets the results of a single page from a List() call, producing a slice of Server entities. -func ExtractServers(page pagination.Page) ([]os.Server, error) { - return os.ExtractServers(page) -} - -// ListAddresses makes a request against the API to list the servers IP addresses. -func ListAddresses(client *gophercloud.ServiceClient, id string) pagination.Pager { - return os.ListAddresses(client, id) -} - -// ExtractAddresses interprets the results of a single page from a ListAddresses() call, producing a map of Address slices. -func ExtractAddresses(page pagination.Page) (map[string][]os.Address, error) { - return os.ExtractAddresses(page) -} - -// ListAddressesByNetwork makes a request against the API to list the servers IP addresses -// for the given network. -func ListAddressesByNetwork(client *gophercloud.ServiceClient, id, network string) pagination.Pager { - return os.ListAddressesByNetwork(client, id, network) -} - -// ExtractNetworkAddresses interprets the results of a single page from a ListAddressesByNetwork() call, producing a map of Address slices. -func ExtractNetworkAddresses(page pagination.Page) ([]os.Address, error) { - return os.ExtractNetworkAddresses(page) -} - -// Metadata requests all the metadata for the given server ID. -func Metadata(client *gophercloud.ServiceClient, id string) os.GetMetadataResult { - return os.Metadata(client, id) -} - -// UpdateMetadata updates (or creates) all the metadata specified by opts for the given server ID. -// This operation does not affect already-existing metadata that is not specified -// by opts. -func UpdateMetadata(client *gophercloud.ServiceClient, id string, opts os.UpdateMetadataOptsBuilder) os.UpdateMetadataResult { - return os.UpdateMetadata(client, id, opts) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/servers/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/servers/doc.go deleted file mode 100644 index c9f77f6945..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/servers/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package servers provides information and interaction with the server -// API resource for the Rackspace Cloud Servers service. -package servers diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/servers/fixtures.go b/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/servers/fixtures.go deleted file mode 100644 index 75cccd0418..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/servers/fixtures.go +++ /dev/null @@ -1,574 +0,0 @@ -// +build fixtures - -package servers - -import ( - os "github.com/rackspace/gophercloud/openstack/compute/v2/servers" -) - -// ListOutput is the recorded output of a Rackspace servers.List request. -const ListOutput = ` -{ - "servers": [ - { - "OS-DCF:diskConfig": "MANUAL", - "OS-EXT-STS:power_state": 1, - "OS-EXT-STS:task_state": null, - "OS-EXT-STS:vm_state": "active", - "accessIPv4": "1.2.3.4", - "accessIPv6": "1111:4822:7818:121:2000:9b5e:7438:a2d0", - "addresses": { - "private": [ - { - "addr": "10.208.230.113", - "version": 4 - } - ], - "public": [ - { - "addr": "2001:4800:7818:101:2000:9b5e:7428:a2d0", - "version": 6 - }, - { - "addr": "104.130.131.164", - "version": 4 - } - ] - }, - "created": "2014-09-23T12:34:58Z", - "flavor": { - "id": "performance1-8", - "links": [ - { - "href": "https://dfw.servers.api.rackspacecloud.com/111111/flavors/performance1-8", - "rel": "bookmark" - } - ] - }, - "hostId": "e8951a524bc465b0898aeac7674da6fe1495e253ae1ea17ddb2c2475", - "id": "59818cee-bc8c-44eb-8073-673ee65105f7", - "image": { - "id": "255df5fb-e3d4-45a3-9a07-c976debf7c14", - "links": [ - { - "href": "https://dfw.servers.api.rackspacecloud.com/111111/images/255df5fb-e3d4-45a3-9a07-c976debf7c14", - "rel": "bookmark" - } - ] - }, - "key_name": "mykey", - "links": [ - { - "href": "https://dfw.servers.api.rackspacecloud.com/v2/111111/servers/59818cee-bc8c-44eb-8073-673ee65105f7", - "rel": "self" - }, - { - "href": "https://dfw.servers.api.rackspacecloud.com/111111/servers/59818cee-bc8c-44eb-8073-673ee65105f7", - "rel": "bookmark" - } - ], - "metadata": {}, - "name": "devstack", - "progress": 100, - "status": "ACTIVE", - "tenant_id": "111111", - "updated": "2014-09-23T12:38:19Z", - "user_id": "14ae7bb21d81422694655f3cc30f2930" - }, - { - "OS-DCF:diskConfig": "MANUAL", - "OS-EXT-STS:power_state": 1, - "OS-EXT-STS:task_state": null, - "OS-EXT-STS:vm_state": "active", - "accessIPv4": "1.1.2.3", - "accessIPv6": "2222:4444:7817:101:be76:4eff:f0e5:9e02", - "addresses": { - "private": [ - { - "addr": "10.10.20.30", - "version": 4 - } - ], - "public": [ - { - "addr": "1.1.2.3", - "version": 4 - }, - { - "addr": "2222:4444:7817:101:be76:4eff:f0e5:9e02", - "version": 6 - } - ] - }, - "created": "2014-07-21T19:32:55Z", - "flavor": { - "id": "performance1-2", - "links": [ - { - "href": "https://dfw.servers.api.rackspacecloud.com/111111/flavors/performance1-2", - "rel": "bookmark" - } - ] - }, - "hostId": "f859679906d6b1a38c1bd516b78f4dcc7d5fcf012578fa3ce460716c", - "id": "25f1c7f5-e00a-4715-b354-16e24b2f4630", - "image": { - "id": "bb02b1a3-bc77-4d17-ab5b-421d89850fca", - "links": [ - { - "href": "https://dfw.servers.api.rackspacecloud.com/111111/images/bb02b1a3-bc77-4d17-ab5b-421d89850fca", - "rel": "bookmark" - } - ] - }, - "key_name": "otherkey", - "links": [ - { - "href": "https://dfw.servers.api.rackspacecloud.com/v2/111111/servers/25f1c7f5-e00a-4715-b355-16e24b2f4630", - "rel": "self" - }, - { - "href": "https://dfw.servers.api.rackspacecloud.com/111111/servers/25f1c7f5-e00a-4715-b355-16e24b2f4630", - "rel": "bookmark" - } - ], - "metadata": {}, - "name": "peril-dfw", - "progress": 100, - "status": "ACTIVE", - "tenant_id": "111111", - "updated": "2014-07-21T19:34:24Z", - "user_id": "14ae7bb21d81422694655f3cc30f2930" - } - ] -} -` - -// GetOutput is the recorded output of a Rackspace servers.Get request. -const GetOutput = ` -{ - "server": { - "OS-DCF:diskConfig": "AUTO", - "OS-EXT-STS:power_state": 1, - "OS-EXT-STS:task_state": null, - "OS-EXT-STS:vm_state": "active", - "accessIPv4": "1.2.4.8", - "accessIPv6": "2001:4800:6666:105:2a0f:c056:f594:7777", - "addresses": { - "private": [ - { - "addr": "10.20.40.80", - "version": 4 - } - ], - "public": [ - { - "addr": "1.2.4.8", - "version": 4 - }, - { - "addr": "2001:4800:6666:105:2a0f:c056:f594:7777", - "version": 6 - } - ] - }, - "created": "2014-10-21T14:42:16Z", - "flavor": { - "id": "performance1-1", - "links": [ - { - "href": "https://dfw.servers.api.rackspacecloud.com/111111/flavors/performance1-1", - "rel": "bookmark" - } - ] - }, - "hostId": "430d2ae02de0a7af77012c94778145eccf67e75b1fac0528aa10d4a7", - "id": "8c65cb68-0681-4c30-bc88-6b83a8a26aee", - "image": { - "id": "e19a734c-c7e6-443a-830c-242209c4d65d", - "links": [ - { - "href": "https://dfw.servers.api.rackspacecloud.com/111111/images/e19a734c-c7e6-443a-830c-242209c4d65d", - "rel": "bookmark" - } - ] - }, - "key_name": null, - "links": [ - { - "href": "https://dfw.servers.api.rackspacecloud.com/v2/111111/servers/8c65cb68-0681-4c30-bc88-6b83a8a26aee", - "rel": "self" - }, - { - "href": "https://dfw.servers.api.rackspacecloud.com/111111/servers/8c65cb68-0681-4c30-bc88-6b83a8a26aee", - "rel": "bookmark" - } - ], - "metadata": {}, - "name": "Gophercloud-pxpGGuey", - "progress": 100, - "status": "ACTIVE", - "tenant_id": "111111", - "updated": "2014-10-21T14:42:57Z", - "user_id": "14ae7bb21d81423694655f4dd30f2930" - } -} -` - -// UpdateOutput is the recorded output of a Rackspace servers.Update request. -const UpdateOutput = ` -{ - "server": { - "OS-DCF:diskConfig": "AUTO", - "OS-EXT-STS:power_state": 1, - "OS-EXT-STS:task_state": null, - "OS-EXT-STS:vm_state": "active", - "accessIPv4": "1.2.4.8", - "accessIPv6": "2001:4800:6666:105:2a0f:c056:f594:7777", - "addresses": { - "private": [ - { - "addr": "10.20.40.80", - "version": 4 - } - ], - "public": [ - { - "addr": "1.2.4.8", - "version": 4 - }, - { - "addr": "2001:4800:6666:105:2a0f:c056:f594:7777", - "version": 6 - } - ] - }, - "created": "2014-10-21T14:42:16Z", - "flavor": { - "id": "performance1-1", - "links": [ - { - "href": "https://dfw.servers.api.rackspacecloud.com/111111/flavors/performance1-1", - "rel": "bookmark" - } - ] - }, - "hostId": "430d2ae02de0a7af77012c94778145eccf67e75b1fac0528aa10d4a7", - "id": "8c65cb68-0681-4c30-bc88-6b83a8a26aee", - "image": { - "id": "e19a734c-c7e6-443a-830c-242209c4d65d", - "links": [ - { - "href": "https://dfw.servers.api.rackspacecloud.com/111111/images/e19a734c-c7e6-443a-830c-242209c4d65d", - "rel": "bookmark" - } - ] - }, - "key_name": null, - "links": [ - { - "href": "https://dfw.servers.api.rackspacecloud.com/v2/111111/servers/8c65cb68-0681-4c30-bc88-6b83a8a26aee", - "rel": "self" - }, - { - "href": "https://dfw.servers.api.rackspacecloud.com/111111/servers/8c65cb68-0681-4c30-bc88-6b83a8a26aee", - "rel": "bookmark" - } - ], - "metadata": {}, - "name": "test-server-updated", - "progress": 100, - "status": "ACTIVE", - "tenant_id": "111111", - "updated": "2014-10-21T14:42:57Z", - "user_id": "14ae7bb21d81423694655f4dd30f2930" - } -} -` - -// CreateOutput contains a sample of Rackspace's response to a Create call. -const CreateOutput = ` -{ - "server": { - "OS-DCF:diskConfig": "AUTO", - "adminPass": "v7tADqbE5pr9", - "id": "bb63327b-6a2f-34bc-b0ef-4b6d97ea637e", - "links": [ - { - "href": "https://dfw.servers.api.rackspacecloud.com/v2/111111/servers/bb63327b-6a2f-34bc-b0ef-4b6d97ea637e", - "rel": "self" - }, - { - "href": "https://dfw.servers.api.rackspacecloud.com/111111/servers/bb63327b-6a2f-34bc-b0ef-4b6d97ea637e", - "rel": "bookmark" - } - ] - } -} -` - -// DevstackServer is the expected first result from parsing ListOutput. -var DevstackServer = os.Server{ - ID: "59818cee-bc8c-44eb-8073-673ee65105f7", - Name: "devstack", - TenantID: "111111", - UserID: "14ae7bb21d81422694655f3cc30f2930", - HostID: "e8951a524bc465b0898aeac7674da6fe1495e253ae1ea17ddb2c2475", - Updated: "2014-09-23T12:38:19Z", - Created: "2014-09-23T12:34:58Z", - AccessIPv4: "1.2.3.4", - AccessIPv6: "1111:4822:7818:121:2000:9b5e:7438:a2d0", - Progress: 100, - Status: "ACTIVE", - Image: map[string]interface{}{ - "id": "255df5fb-e3d4-45a3-9a07-c976debf7c14", - "links": []interface{}{ - map[string]interface{}{ - "href": "https://dfw.servers.api.rackspacecloud.com/111111/images/255df5fb-e3d4-45a3-9a07-c976debf7c14", - "rel": "bookmark", - }, - }, - }, - Flavor: map[string]interface{}{ - "id": "performance1-8", - "links": []interface{}{ - map[string]interface{}{ - "href": "https://dfw.servers.api.rackspacecloud.com/111111/flavors/performance1-8", - "rel": "bookmark", - }, - }, - }, - Addresses: map[string]interface{}{ - "private": []interface{}{ - map[string]interface{}{ - "addr": "10.20.30.40", - "version": float64(4.0), - }, - }, - "public": []interface{}{ - map[string]interface{}{ - "addr": "1111:4822:7818:121:2000:9b5e:7438:a2d0", - "version": float64(6.0), - }, - map[string]interface{}{ - "addr": "1.2.3.4", - "version": float64(4.0), - }, - }, - }, - Metadata: map[string]interface{}{}, - Links: []interface{}{ - map[string]interface{}{ - "href": "https://dfw.servers.api.rackspacecloud.com/v2/111111/servers/59918cee-bd9d-44eb-8173-673ee75105f7", - "rel": "self", - }, - map[string]interface{}{ - "href": "https://dfw.servers.api.rackspacecloud.com/v2/111111/servers/59818cee-bc8c-44eb-8073-673ee65105f7", - "rel": "bookmark", - }, - }, - KeyName: "mykey", - AdminPass: "", -} - -// PerilServer is the expected second result from parsing ListOutput. -var PerilServer = os.Server{ - ID: "25f1c7f5-e00a-4715-b354-16e24b2f4630", - Name: "peril-dfw", - TenantID: "111111", - UserID: "14ae7bb21d81422694655f3cc30f2930", - HostID: "f859679906d6b1a38c1bd516b78f4dcc7d5fcf012578fa3ce460716c", - Updated: "2014-07-21T19:34:24Z", - Created: "2014-07-21T19:32:55Z", - AccessIPv4: "1.1.2.3", - AccessIPv6: "2222:4444:7817:101:be76:4eff:f0e5:9e02", - Progress: 100, - Status: "ACTIVE", - Image: map[string]interface{}{ - "id": "bb02b1a3-bc77-4d17-ab5b-421d89850fca", - "links": []interface{}{ - map[string]interface{}{ - "href": "https://dfw.servers.api.rackspacecloud.com/111111/images/bb02b1a3-bc77-4d17-ab5b-421d89850fca", - "rel": "bookmark", - }, - }, - }, - Flavor: map[string]interface{}{ - "id": "performance1-2", - "links": []interface{}{ - map[string]interface{}{ - "href": "https://dfw.servers.api.rackspacecloud.com/111111/flavors/performance1-2", - "rel": "bookmark", - }, - }, - }, - Addresses: map[string]interface{}{ - "private": []interface{}{ - map[string]interface{}{ - "addr": "10.10.20.30", - "version": float64(4.0), - }, - }, - "public": []interface{}{ - map[string]interface{}{ - "addr": "2222:4444:7817:101:be76:4eff:f0e5:9e02", - "version": float64(6.0), - }, - map[string]interface{}{ - "addr": "1.1.2.3", - "version": float64(4.0), - }, - }, - }, - Metadata: map[string]interface{}{}, - Links: []interface{}{ - map[string]interface{}{ - "href": "https://dfw.servers.api.rackspacecloud.com/v2/111111/servers/25f1c7f5-e00a-4715-b355-16e24b2f4630", - "rel": "self", - }, - map[string]interface{}{ - "href": "https://dfw.servers.api.rackspacecloud.com/v2/111111/servers/25f1c7f5-e00a-4715-b355-16e24b2f4630", - "rel": "bookmark", - }, - }, - KeyName: "otherkey", - AdminPass: "", -} - -// GophercloudServer is the expected result from parsing GetOutput. -var GophercloudServer = os.Server{ - ID: "8c65cb68-0681-4c30-bc88-6b83a8a26aee", - Name: "Gophercloud-pxpGGuey", - TenantID: "111111", - UserID: "14ae7bb21d81423694655f4dd30f2930", - HostID: "430d2ae02de0a7af77012c94778145eccf67e75b1fac0528aa10d4a7", - Updated: "2014-10-21T14:42:57Z", - Created: "2014-10-21T14:42:16Z", - AccessIPv4: "1.2.4.8", - AccessIPv6: "2001:4800:6666:105:2a0f:c056:f594:7777", - Progress: 100, - Status: "ACTIVE", - Image: map[string]interface{}{ - "id": "e19a734c-c7e6-443a-830c-242209c4d65d", - "links": []interface{}{ - map[string]interface{}{ - "href": "https://dfw.servers.api.rackspacecloud.com/111111/images/e19a734c-c7e6-443a-830c-242209c4d65d", - "rel": "bookmark", - }, - }, - }, - Flavor: map[string]interface{}{ - "id": "performance1-1", - "links": []interface{}{ - map[string]interface{}{ - "href": "https://dfw.servers.api.rackspacecloud.com/111111/flavors/performance1-1", - "rel": "bookmark", - }, - }, - }, - Addresses: map[string]interface{}{ - "private": []interface{}{ - map[string]interface{}{ - "addr": "10.20.40.80", - "version": float64(4.0), - }, - }, - "public": []interface{}{ - map[string]interface{}{ - "addr": "2001:4800:6666:105:2a0f:c056:f594:7777", - "version": float64(6.0), - }, - map[string]interface{}{ - "addr": "1.2.4.8", - "version": float64(4.0), - }, - }, - }, - Metadata: map[string]interface{}{}, - Links: []interface{}{ - map[string]interface{}{ - "href": "https://dfw.servers.api.rackspacecloud.com/v2/111111/servers/8c65cb68-0681-4c30-bc88-6b83a8a26aee", - "rel": "self", - }, - map[string]interface{}{ - "href": "https://dfw.servers.api.rackspacecloud.com/111111/servers/8c65cb68-0681-4c30-bc88-6b83a8a26aee", - "rel": "bookmark", - }, - }, - KeyName: "", - AdminPass: "", -} - -// GophercloudUpdatedServer is the expected result from parsing UpdateOutput. -var GophercloudUpdatedServer = os.Server{ - ID: "8c65cb68-0681-4c30-bc88-6b83a8a26aee", - Name: "test-server-updated", - TenantID: "111111", - UserID: "14ae7bb21d81423694655f4dd30f2930", - HostID: "430d2ae02de0a7af77012c94778145eccf67e75b1fac0528aa10d4a7", - Updated: "2014-10-21T14:42:57Z", - Created: "2014-10-21T14:42:16Z", - AccessIPv4: "1.2.4.8", - AccessIPv6: "2001:4800:6666:105:2a0f:c056:f594:7777", - Progress: 100, - Status: "ACTIVE", - Image: map[string]interface{}{ - "id": "e19a734c-c7e6-443a-830c-242209c4d65d", - "links": []interface{}{ - map[string]interface{}{ - "href": "https://dfw.servers.api.rackspacecloud.com/111111/images/e19a734c-c7e6-443a-830c-242209c4d65d", - "rel": "bookmark", - }, - }, - }, - Flavor: map[string]interface{}{ - "id": "performance1-1", - "links": []interface{}{ - map[string]interface{}{ - "href": "https://dfw.servers.api.rackspacecloud.com/111111/flavors/performance1-1", - "rel": "bookmark", - }, - }, - }, - Addresses: map[string]interface{}{ - "private": []interface{}{ - map[string]interface{}{ - "addr": "10.20.40.80", - "version": float64(4.0), - }, - }, - "public": []interface{}{ - map[string]interface{}{ - "addr": "2001:4800:6666:105:2a0f:c056:f594:7777", - "version": float64(6.0), - }, - map[string]interface{}{ - "addr": "1.2.4.8", - "version": float64(4.0), - }, - }, - }, - Metadata: map[string]interface{}{}, - Links: []interface{}{ - map[string]interface{}{ - "href": "https://dfw.servers.api.rackspacecloud.com/v2/111111/servers/8c65cb68-0681-4c30-bc88-6b83a8a26aee", - "rel": "self", - }, - map[string]interface{}{ - "href": "https://dfw.servers.api.rackspacecloud.com/111111/servers/8c65cb68-0681-4c30-bc88-6b83a8a26aee", - "rel": "bookmark", - }, - }, - KeyName: "", - AdminPass: "", -} - -// CreatedServer is the partial Server struct that can be parsed from CreateOutput. -var CreatedServer = os.Server{ - ID: "bb63327b-6a2f-34bc-b0ef-4b6d97ea637e", - AdminPass: "v7tADqbE5pr9", - Links: []interface{}{}, -} - -// ExpectedServerSlice is the collection of servers, in order, that should be parsed from ListOutput. -var ExpectedServerSlice = []os.Server{DevstackServer, PerilServer} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/servers/requests.go b/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/servers/requests.go deleted file mode 100644 index 809183ec7c..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/servers/requests.go +++ /dev/null @@ -1,163 +0,0 @@ -package servers - -import ( - "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume" - "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/diskconfig" - os "github.com/rackspace/gophercloud/openstack/compute/v2/servers" -) - -// CreateOpts specifies all of the options that Rackspace accepts in its Create request, including -// the union of all extensions that Rackspace supports. -type CreateOpts struct { - // Name [required] is the name to assign to the newly launched server. - Name string - - // ImageRef [required] is the ID or full URL to the image that contains the server's OS and initial state. - // Optional if using the boot-from-volume extension. - ImageRef string - - // FlavorRef [required] is the ID or full URL to the flavor that describes the server's specs. - FlavorRef string - - // SecurityGroups [optional] lists the names of the security groups to which this server should belong. - SecurityGroups []string - - // UserData [optional] contains configuration information or scripts to use upon launch. - // Create will base64-encode it for you. - UserData []byte - - // AvailabilityZone [optional] in which to launch the server. - AvailabilityZone string - - // Networks [optional] dictates how this server will be attached to available networks. - // By default, the server will be attached to all isolated networks for the tenant. - Networks []os.Network - - // Metadata [optional] contains key-value pairs (up to 255 bytes each) to attach to the server. - Metadata map[string]string - - // Personality [optional] includes the path and contents of a file to inject into the server at launch. - // The maximum size of the file is 255 bytes (decoded). - Personality []byte - - // ConfigDrive [optional] enables metadata injection through a configuration drive. - ConfigDrive bool - - // AdminPass [optional] sets the root user password. If not set, a randomly-generated - // password will be created and returned in the response. - AdminPass string - - // Rackspace-specific extensions begin here. - - // KeyPair [optional] specifies the name of the SSH KeyPair to be injected into the newly launched - // server. See the "keypairs" extension in OpenStack compute v2. - KeyPair string - - // DiskConfig [optional] controls how the created server's disk is partitioned. See the "diskconfig" - // extension in OpenStack compute v2. - DiskConfig diskconfig.DiskConfig - - // BlockDevice [optional] will create the server from a volume, which is created from an image, - // a snapshot, or an another volume. - BlockDevice []bootfromvolume.BlockDevice -} - -// ToServerCreateMap constructs a request body using all of the OpenStack extensions that are -// active on Rackspace. -func (opts CreateOpts) ToServerCreateMap() (map[string]interface{}, error) { - base := os.CreateOpts{ - Name: opts.Name, - ImageRef: opts.ImageRef, - FlavorRef: opts.FlavorRef, - SecurityGroups: opts.SecurityGroups, - UserData: opts.UserData, - AvailabilityZone: opts.AvailabilityZone, - Networks: opts.Networks, - Metadata: opts.Metadata, - Personality: opts.Personality, - ConfigDrive: opts.ConfigDrive, - AdminPass: opts.AdminPass, - } - - drive := diskconfig.CreateOptsExt{ - CreateOptsBuilder: base, - DiskConfig: opts.DiskConfig, - } - - res, err := drive.ToServerCreateMap() - if err != nil { - return nil, err - } - - if len(opts.BlockDevice) != 0 { - bfv := bootfromvolume.CreateOptsExt{ - CreateOptsBuilder: drive, - BlockDevice: opts.BlockDevice, - } - - res, err = bfv.ToServerCreateMap() - if err != nil { - return nil, err - } - } - - // key_name doesn't actually come from the extension (or at least isn't documented there) so - // we need to add it manually. - serverMap := res["server"].(map[string]interface{}) - serverMap["key_name"] = opts.KeyPair - - return res, nil -} - -// RebuildOpts represents all of the configuration options used in a server rebuild operation that -// are supported by Rackspace. -type RebuildOpts struct { - // Required. The ID of the image you want your server to be provisioned on - ImageID string - - // Name to set the server to - Name string - - // Required. The server's admin password - AdminPass string - - // AccessIPv4 [optional] provides a new IPv4 address for the instance. - AccessIPv4 string - - // AccessIPv6 [optional] provides a new IPv6 address for the instance. - AccessIPv6 string - - // Metadata [optional] contains key-value pairs (up to 255 bytes each) to attach to the server. - Metadata map[string]string - - // Personality [optional] includes the path and contents of a file to inject into the server at launch. - // The maximum size of the file is 255 bytes (decoded). - Personality []byte - - // Rackspace-specific stuff begins here. - - // DiskConfig [optional] controls how the created server's disk is partitioned. See the "diskconfig" - // extension in OpenStack compute v2. - DiskConfig diskconfig.DiskConfig -} - -// ToServerRebuildMap constructs a request body using all of the OpenStack extensions that are -// active on Rackspace. -func (opts RebuildOpts) ToServerRebuildMap() (map[string]interface{}, error) { - base := os.RebuildOpts{ - ImageID: opts.ImageID, - Name: opts.Name, - AdminPass: opts.AdminPass, - AccessIPv4: opts.AccessIPv4, - AccessIPv6: opts.AccessIPv6, - Metadata: opts.Metadata, - Personality: opts.Personality, - } - - drive := diskconfig.RebuildOptsExt{ - RebuildOptsBuilder: base, - DiskConfig: opts.DiskConfig, - } - - return drive.ToServerRebuildMap() -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/virtualinterfaces/requests.go b/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/virtualinterfaces/requests.go deleted file mode 100644 index 1ff7c5ae55..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/virtualinterfaces/requests.go +++ /dev/null @@ -1,45 +0,0 @@ -package virtualinterfaces - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// List returns a Pager which allows you to iterate over a collection of -// networks. It accepts a ListOpts struct, which allows you to filter and sort -// the returned collection for greater efficiency. -func List(c *gophercloud.ServiceClient, instanceID string) pagination.Pager { - createPage := func(r pagination.PageResult) pagination.Page { - return VirtualInterfacePage{pagination.SinglePageBase(r)} - } - - return pagination.NewPager(c, listURL(c, instanceID), createPage) -} - -// Create creates a new virtual interface for a network and attaches the network -// to the server instance. -func Create(c *gophercloud.ServiceClient, instanceID, networkID string) CreateResult { - var res CreateResult - - reqBody := map[string]map[string]string{ - "virtual_interface": { - "network_id": networkID, - }, - } - - // Send request to API - _, res.Err = c.Post(createURL(c, instanceID), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200, 201, 202}, - }) - return res -} - -// Delete deletes the interface with interfaceID attached to the instance with -// instanceID. -func Delete(c *gophercloud.ServiceClient, instanceID, interfaceID string) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(deleteURL(c, instanceID, interfaceID), &gophercloud.RequestOpts{ - OkCodes: []int{200, 204}, - }) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/virtualinterfaces/results.go b/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/virtualinterfaces/results.go deleted file mode 100644 index 26fa7f31ce..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/virtualinterfaces/results.go +++ /dev/null @@ -1,81 +0,0 @@ -package virtualinterfaces - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -type commonResult struct { - gophercloud.Result -} - -// Extract is a function that accepts a result and extracts a network resource. -func (r commonResult) Extract() (*VirtualInterface, error) { - if r.Err != nil { - return nil, r.Err - } - - var res struct { - VirtualInterfaces []VirtualInterface `mapstructure:"virtual_interfaces" json:"virtual_interfaces"` - } - - err := mapstructure.Decode(r.Body, &res) - - return &res.VirtualInterfaces[0], err -} - -// CreateResult represents the result of a create operation. -type CreateResult struct { - commonResult -} - -// DeleteResult represents the result of a delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} - -// IPAddress represents a vitual address attached to a VirtualInterface. -type IPAddress struct { - Address string `mapstructure:"address" json:"address"` - NetworkID string `mapstructure:"network_id" json:"network_id"` - NetworkLabel string `mapstructure:"network_label" json:"network_label"` -} - -// VirtualInterface represents a virtual interface. -type VirtualInterface struct { - // UUID for the virtual interface - ID string `mapstructure:"id" json:"id"` - - MACAddress string `mapstructure:"mac_address" json:"mac_address"` - - IPAddresses []IPAddress `mapstructure:"ip_addresses" json:"ip_addresses"` -} - -// VirtualInterfacePage is the page returned by a pager when traversing over a -// collection of virtual interfaces. -type VirtualInterfacePage struct { - pagination.SinglePageBase -} - -// IsEmpty returns true if the NetworkPage contains no Networks. -func (r VirtualInterfacePage) IsEmpty() (bool, error) { - networks, err := ExtractVirtualInterfaces(r) - if err != nil { - return true, err - } - return len(networks) == 0, nil -} - -// ExtractVirtualInterfaces accepts a Page struct, specifically a VirtualInterfacePage struct, -// and extracts the elements into a slice of VirtualInterface structs. In other words, -// a generic collection is mapped into a relevant slice. -func ExtractVirtualInterfaces(page pagination.Page) ([]VirtualInterface, error) { - var resp struct { - VirtualInterfaces []VirtualInterface `mapstructure:"virtual_interfaces" json:"virtual_interfaces"` - } - - err := mapstructure.Decode(page.(VirtualInterfacePage).Body, &resp) - - return resp.VirtualInterfaces, err -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/virtualinterfaces/urls.go b/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/virtualinterfaces/urls.go deleted file mode 100644 index 9e5693e849..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/virtualinterfaces/urls.go +++ /dev/null @@ -1,15 +0,0 @@ -package virtualinterfaces - -import "github.com/rackspace/gophercloud" - -func listURL(c *gophercloud.ServiceClient, instanceID string) string { - return c.ServiceURL("servers", instanceID, "os-virtual-interfacesv2") -} - -func createURL(c *gophercloud.ServiceClient, instanceID string) string { - return c.ServiceURL("servers", instanceID, "os-virtual-interfacesv2") -} - -func deleteURL(c *gophercloud.ServiceClient, instanceID, interfaceID string) string { - return c.ServiceURL("servers", instanceID, "os-virtual-interfacesv2", interfaceID) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/volumeattach/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/volumeattach/delegate.go deleted file mode 100644 index c6003e0e5b..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/volumeattach/delegate.go +++ /dev/null @@ -1,27 +0,0 @@ -package volumeattach - -import ( - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach" - "github.com/rackspace/gophercloud/pagination" -) - -// List returns a Pager that allows you to iterate over a collection of VolumeAttachments. -func List(client *gophercloud.ServiceClient, serverID string) pagination.Pager { - return os.List(client, serverID) -} - -// Create requests the creation of a new volume attachment on the server -func Create(client *gophercloud.ServiceClient, serverID string, opts os.CreateOptsBuilder) os.CreateResult { - return os.Create(client, serverID, opts) -} - -// Get returns public data about a previously created VolumeAttachment. -func Get(client *gophercloud.ServiceClient, serverID, aID string) os.GetResult { - return os.Get(client, serverID, aID) -} - -// Delete requests the deletion of a previous stored VolumeAttachment from the server. -func Delete(client *gophercloud.ServiceClient, serverID, aID string) os.DeleteResult { - return os.Delete(client, serverID, aID) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/volumeattach/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/volumeattach/doc.go deleted file mode 100644 index 2164908e3a..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/compute/v2/volumeattach/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package volumeattach provides the ability to attach and detach volume -// to instances to Rackspace servers -package volumeattach diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/extensions/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/extensions/delegate.go deleted file mode 100644 index fc547cde5f..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/extensions/delegate.go +++ /dev/null @@ -1,24 +0,0 @@ -package extensions - -import ( - "github.com/rackspace/gophercloud" - common "github.com/rackspace/gophercloud/openstack/common/extensions" - "github.com/rackspace/gophercloud/pagination" -) - -// ExtractExtensions accepts a Page struct, specifically an ExtensionPage struct, and extracts the -// elements into a slice of os.Extension structs. -func ExtractExtensions(page pagination.Page) ([]common.Extension, error) { - return common.ExtractExtensions(page) -} - -// Get retrieves information for a specific extension using its alias. -func Get(c *gophercloud.ServiceClient, alias string) common.GetResult { - return common.Get(c, alias) -} - -// List returns a Pager which allows you to iterate over the full collection of extensions. -// It does not accept query parameters. -func List(c *gophercloud.ServiceClient) pagination.Pager { - return common.List(c) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/extensions/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/extensions/doc.go deleted file mode 100644 index b02a95b534..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/extensions/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package extensions provides information and interaction with the all the -// extensions available for the Rackspace Identity service. -package extensions diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/roles/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/roles/delegate.go deleted file mode 100644 index a6ee8515ce..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/roles/delegate.go +++ /dev/null @@ -1,50 +0,0 @@ -package roles - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" - - os "github.com/rackspace/gophercloud/openstack/identity/v2/extensions/admin/roles" -) - -// List is the operation responsible for listing all available global roles -// that a user can adopt. -func List(client *gophercloud.ServiceClient) pagination.Pager { - return os.List(client) -} - -// AddUserRole is the operation responsible for assigning a particular role to -// a user. This is confined to the scope of the user's tenant - so the tenant -// ID is a required argument. -func AddUserRole(client *gophercloud.ServiceClient, userID, roleID string) UserRoleResult { - var result UserRoleResult - - _, result.Err = client.Request("PUT", userRoleURL(client, userID, roleID), gophercloud.RequestOpts{ - OkCodes: []int{200, 201}, - }) - - return result -} - -// DeleteUserRole is the operation responsible for deleting a particular role -// from a user. This is confined to the scope of the user's tenant - so the -// tenant ID is a required argument. -func DeleteUserRole(client *gophercloud.ServiceClient, userID, roleID string) UserRoleResult { - var result UserRoleResult - - _, result.Err = client.Request("DELETE", userRoleURL(client, userID, roleID), gophercloud.RequestOpts{ - OkCodes: []int{204}, - }) - - return result -} - -// UserRoleResult represents the result of either an AddUserRole or -// a DeleteUserRole operation. -type UserRoleResult struct { - gophercloud.ErrResult -} - -func userRoleURL(c *gophercloud.ServiceClient, userID, roleID string) string { - return c.ServiceURL(os.UserPath, userID, os.RolePath, os.ExtPath, roleID) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/roles/fixtures.go b/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/roles/fixtures.go deleted file mode 100644 index 5f22d0f642..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/roles/fixtures.go +++ /dev/null @@ -1,49 +0,0 @@ -package roles - -import ( - "fmt" - "net/http" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -func MockListRoleResponse(t *testing.T) { - th.Mux.HandleFunc("/OS-KSADM/roles", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "roles": [ - { - "id": "123", - "name": "compute:admin", - "description": "Nova Administrator", - "serviceId": "cke5372ebabeeabb70a0e702a4626977x4406e5" - } - ] -} - `) - }) -} - -func MockAddUserRoleResponse(t *testing.T) { - th.Mux.HandleFunc("/users/{user_id}/roles/OS-KSADM/{role_id}", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PUT") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.WriteHeader(http.StatusCreated) - }) -} - -func MockDeleteUserRoleResponse(t *testing.T) { - th.Mux.HandleFunc("/users/{user_id}/roles/OS-KSADM/{role_id}", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.WriteHeader(http.StatusNoContent) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/tenants/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/tenants/delegate.go deleted file mode 100644 index 6cdd0cfbdc..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/tenants/delegate.go +++ /dev/null @@ -1,17 +0,0 @@ -package tenants - -import ( - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/identity/v2/tenants" - "github.com/rackspace/gophercloud/pagination" -) - -// ExtractTenants interprets a page of List results as a more usable slice of Tenant structs. -func ExtractTenants(page pagination.Page) ([]os.Tenant, error) { - return os.ExtractTenants(page) -} - -// List enumerates the tenants to which the current token grants access. -func List(client *gophercloud.ServiceClient, opts *os.ListOpts) pagination.Pager { - return os.List(client, opts) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/tenants/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/tenants/doc.go deleted file mode 100644 index c1825c21dc..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/tenants/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package tenants provides information and interaction with the tenant -// API resource for the Rackspace Identity service. -package tenants diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/users/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/users/delegate.go deleted file mode 100644 index 6135bec101..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/users/delegate.go +++ /dev/null @@ -1,142 +0,0 @@ -package users - -import ( - "errors" - - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/identity/v2/users" - "github.com/rackspace/gophercloud/pagination" -) - -// List returns a pager that allows traversal over a collection of users. -func List(client *gophercloud.ServiceClient) pagination.Pager { - return os.List(client) -} - -// CommonOpts are the options which are shared between CreateOpts and -// UpdateOpts -type CommonOpts struct { - // Required. The username to assign to the user. When provided, the username - // must: - // - start with an alphabetical (A-Za-z) character - // - have a minimum length of 1 character - // - // The username may contain upper and lowercase characters, as well as any of - // the following special character: . - @ _ - Username string - - // Required. Email address for the user account. - Email string - - // Required. Indicates whether the user can authenticate after the user - // account is created. If no value is specified, the default value is true. - Enabled os.EnabledState - - // Optional. The password to assign to the user. If provided, the password - // must: - // - start with an alphabetical (A-Za-z) character - // - have a minimum length of 8 characters - // - contain at least one uppercase character, one lowercase character, and - // one numeric character. - // - // The password may contain any of the following special characters: . - @ _ - Password string -} - -// CreateOpts represents the options needed when creating new users. -type CreateOpts CommonOpts - -// ToUserCreateMap assembles a request body based on the contents of a CreateOpts. -func (opts CreateOpts) ToUserCreateMap() (map[string]interface{}, error) { - m := make(map[string]interface{}) - - if opts.Username == "" { - return m, errors.New("Username is a required field") - } - if opts.Enabled == nil { - return m, errors.New("Enabled is a required field") - } - if opts.Email == "" { - return m, errors.New("Email is a required field") - } - - if opts.Username != "" { - m["username"] = opts.Username - } - if opts.Email != "" { - m["email"] = opts.Email - } - if opts.Enabled != nil { - m["enabled"] = opts.Enabled - } - if opts.Password != "" { - m["OS-KSADM:password"] = opts.Password - } - - return map[string]interface{}{"user": m}, nil -} - -// Create is the operation responsible for creating new users. -func Create(client *gophercloud.ServiceClient, opts os.CreateOptsBuilder) CreateResult { - return CreateResult{os.Create(client, opts)} -} - -// Get requests details on a single user, either by ID. -func Get(client *gophercloud.ServiceClient, id string) GetResult { - return GetResult{os.Get(client, id)} -} - -// UpdateOptsBuilder allows extensions to add additional attributes to the Update request. -type UpdateOptsBuilder interface { - ToUserUpdateMap() map[string]interface{} -} - -// UpdateOpts specifies the base attributes that may be updated on an existing server. -type UpdateOpts CommonOpts - -// ToUserUpdateMap formats an UpdateOpts structure into a request body. -func (opts UpdateOpts) ToUserUpdateMap() map[string]interface{} { - m := make(map[string]interface{}) - - if opts.Username != "" { - m["username"] = opts.Username - } - if opts.Enabled != nil { - m["enabled"] = &opts.Enabled - } - if opts.Email != "" { - m["email"] = opts.Email - } - - return map[string]interface{}{"user": m} -} - -// Update is the operation responsible for updating exist users by their UUID. -func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) UpdateResult { - var result UpdateResult - - _, result.Err = client.Request("POST", os.ResourceURL(client, id), gophercloud.RequestOpts{ - JSONResponse: &result.Body, - JSONBody: opts.ToUserUpdateMap(), - OkCodes: []int{200}, - }) - - return result -} - -// Delete is the operation responsible for permanently deleting an API user. -func Delete(client *gophercloud.ServiceClient, id string) os.DeleteResult { - return os.Delete(client, id) -} - -// ResetAPIKey resets the User's API key. -func ResetAPIKey(client *gophercloud.ServiceClient, id string) ResetAPIKeyResult { - var result ResetAPIKeyResult - - _, result.Err = client.Request("POST", resetAPIKeyURL(client, id), gophercloud.RequestOpts{ - JSONResponse: &result.Body, - OkCodes: []int{200}, - }) - - return result -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/users/fixtures.go b/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/users/fixtures.go deleted file mode 100644 index 973f39ea8c..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/users/fixtures.go +++ /dev/null @@ -1,154 +0,0 @@ -package users - -import ( - "fmt" - "net/http" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -func mockListResponse(t *testing.T) { - th.Mux.HandleFunc("/users", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "users":[ - { - "id": "u1000", - "username": "jqsmith", - "email": "john.smith@example.org", - "enabled": true - }, - { - "id": "u1001", - "username": "jqsmith", - "email": "jane.smith@example.org", - "enabled": true - } - ] -} - `) - }) -} - -func mockCreateUser(t *testing.T) { - th.Mux.HandleFunc("/users", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "user": { - "username": "new_user", - "enabled": false, - "email": "new_user@foo.com", - "OS-KSADM:password": "foo" - } -} - `) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "user": { - "RAX-AUTH:defaultRegion": "DFW", - "RAX-AUTH:domainId": "5830280", - "id": "123456", - "username": "new_user", - "email": "new_user@foo.com", - "enabled": false - } -} -`) - }) -} - -func mockGetUser(t *testing.T) { - th.Mux.HandleFunc("/users/new_user", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "user": { - "RAX-AUTH:defaultRegion": "DFW", - "RAX-AUTH:domainId": "5830280", - "RAX-AUTH:multiFactorEnabled": "true", - "id": "c39e3de9be2d4c779f1dfd6abacc176d", - "username": "jqsmith", - "email": "john.smith@example.org", - "enabled": true - } -} -`) - }) -} - -func mockUpdateUser(t *testing.T) { - th.Mux.HandleFunc("/users/c39e3de9be2d4c779f1dfd6abacc176d", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "user": { - "email": "new_email@foo.com", - "enabled": true - } -} -`) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "user": { - "RAX-AUTH:defaultRegion": "DFW", - "RAX-AUTH:domainId": "5830280", - "RAX-AUTH:multiFactorEnabled": "true", - "id": "123456", - "username": "jqsmith", - "email": "new_email@foo.com", - "enabled": true - } -} -`) - }) -} - -func mockDeleteUser(t *testing.T) { - th.Mux.HandleFunc("/users/c39e3de9be2d4c779f1dfd6abacc176d", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.WriteHeader(http.StatusNoContent) - }) -} - -func mockResetAPIKey(t *testing.T) { - th.Mux.HandleFunc("/users/99/OS-KSADM/credentials/RAX-KSKEY:apiKeyCredentials/RAX-AUTH/reset", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, ` -{ - "RAX-KSKEY:apiKeyCredentials": { - "username": "joesmith", - "apiKey": "mooH1eiLahd5ahYood7r" - } -}`) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/users/results.go b/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/users/results.go deleted file mode 100644 index 6936ecba84..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/users/results.go +++ /dev/null @@ -1,129 +0,0 @@ -package users - -import ( - "strconv" - - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/identity/v2/users" - - "github.com/mitchellh/mapstructure" -) - -// User represents a user resource that exists on the API. -type User struct { - // The UUID for this user. - ID string - - // The human name for this user. - Name string - - // The username for this user. - Username string - - // Indicates whether the user is enabled (true) or disabled (false). - Enabled bool - - // The email address for this user. - Email string - - // The ID of the tenant to which this user belongs. - TenantID string `mapstructure:"tenant_id"` - - // Specifies the default region for the user account. This value is inherited - // from the user administrator when the account is created. - DefaultRegion string `mapstructure:"RAX-AUTH:defaultRegion"` - - // Identifies the domain that contains the user account. This value is - // inherited from the user administrator when the account is created. - DomainID string `mapstructure:"RAX-AUTH:domainId"` - - // The password value that the user needs for authentication. If the Add user - // request included a password value, this attribute is not included in the - // response. - Password string `mapstructure:"OS-KSADM:password"` - - // Indicates whether the user has enabled multi-factor authentication. - MultiFactorEnabled bool `mapstructure:"RAX-AUTH:multiFactorEnabled"` -} - -// CreateResult represents the result of a Create operation -type CreateResult struct { - os.CreateResult -} - -// GetResult represents the result of a Get operation -type GetResult struct { - os.GetResult -} - -// UpdateResult represents the result of an Update operation -type UpdateResult struct { - os.UpdateResult -} - -func commonExtract(resp interface{}, err error) (*User, error) { - if err != nil { - return nil, err - } - - var respStruct struct { - User *User `json:"user"` - } - - // Since the API returns a string instead of a bool, we need to hack the JSON - json := resp.(map[string]interface{}) - user := json["user"].(map[string]interface{}) - if s, ok := user["RAX-AUTH:multiFactorEnabled"].(string); ok && s != "" { - if b, err := strconv.ParseBool(s); err == nil { - user["RAX-AUTH:multiFactorEnabled"] = b - } - } - - err = mapstructure.Decode(json, &respStruct) - - return respStruct.User, err -} - -// Extract will get the Snapshot object out of the GetResult object. -func (r GetResult) Extract() (*User, error) { - return commonExtract(r.Body, r.Err) -} - -// Extract will get the Snapshot object out of the CreateResult object. -func (r CreateResult) Extract() (*User, error) { - return commonExtract(r.Body, r.Err) -} - -// Extract will get the Snapshot object out of the UpdateResult object. -func (r UpdateResult) Extract() (*User, error) { - return commonExtract(r.Body, r.Err) -} - -// ResetAPIKeyResult represents the server response to the ResetAPIKey method. -type ResetAPIKeyResult struct { - gophercloud.Result -} - -// ResetAPIKeyValue represents an API Key that has been reset. -type ResetAPIKeyValue struct { - // The Username for this API Key reset. - Username string `mapstructure:"username"` - - // The new API Key for this user. - APIKey string `mapstructure:"apiKey"` -} - -// Extract will get the Error or ResetAPIKeyValue object out of the ResetAPIKeyResult object. -func (r ResetAPIKeyResult) Extract() (*ResetAPIKeyValue, error) { - if r.Err != nil { - return nil, r.Err - } - - var response struct { - ResetAPIKeyValue ResetAPIKeyValue `mapstructure:"RAX-KSKEY:apiKeyCredentials"` - } - - err := mapstructure.Decode(r.Body, &response) - - return &response.ResetAPIKeyValue, err -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/users/urls.go b/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/users/urls.go deleted file mode 100644 index bc1aaefb02..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/identity/v2/users/urls.go +++ /dev/null @@ -1,7 +0,0 @@ -package users - -import "github.com/rackspace/gophercloud" - -func resetAPIKeyURL(client *gophercloud.ServiceClient, id string) string { - return client.ServiceURL("users", id, "OS-KSADM", "credentials", "RAX-KSKEY:apiKeyCredentials", "RAX-AUTH", "reset") -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/acl/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/acl/doc.go deleted file mode 100644 index 42325fe83d..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/acl/doc.go +++ /dev/null @@ -1,12 +0,0 @@ -/* -Package acl provides information and interaction with the access lists feature -of the Rackspace Cloud Load Balancer service. - -The access list management feature allows fine-grained network access controls -to be applied to the load balancer's virtual IP address. A single IP address, -multiple IP addresses, or entire network subnets can be added. Items that are -configured with the ALLOW type always takes precedence over items with the DENY -type. To reject traffic from all items except for those with the ALLOW type, -add a networkItem with an address of "0.0.0.0/0" and a DENY type. -*/ -package acl diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/acl/fixtures.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/acl/fixtures.go deleted file mode 100644 index e3c941c81b..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/acl/fixtures.go +++ /dev/null @@ -1,109 +0,0 @@ -package acl - -import ( - "fmt" - "net/http" - "strconv" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -func _rootURL(lbID int) string { - return "/loadbalancers/" + strconv.Itoa(lbID) + "/accesslist" -} - -func mockListResponse(t *testing.T, id int) { - th.Mux.HandleFunc(_rootURL(id), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "accessList": [ - { - "address": "206.160.163.21", - "id": 21, - "type": "DENY" - }, - { - "address": "206.160.163.22", - "id": 22, - "type": "DENY" - }, - { - "address": "206.160.163.23", - "id": 23, - "type": "DENY" - }, - { - "address": "206.160.163.24", - "id": 24, - "type": "DENY" - } - ] -} - `) - }) -} - -func mockCreateResponse(t *testing.T, lbID int) { - th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "accessList": [ - { - "address": "206.160.163.21", - "type": "DENY" - }, - { - "address": "206.160.165.11", - "type": "DENY" - } - ] -} - `) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusAccepted) - }) -} - -func mockDeleteAllResponse(t *testing.T, lbID int) { - th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.WriteHeader(http.StatusAccepted) - }) -} - -func mockBatchDeleteResponse(t *testing.T, lbID int, ids []int) { - th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - r.ParseForm() - - for k, v := range ids { - fids := r.Form["id"] - th.AssertEquals(t, strconv.Itoa(v), fids[k]) - } - - w.WriteHeader(http.StatusAccepted) - }) -} - -func mockDeleteResponse(t *testing.T, lbID, networkID int) { - th.Mux.HandleFunc(_rootURL(lbID)+"/"+strconv.Itoa(networkID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.WriteHeader(http.StatusAccepted) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/acl/requests.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/acl/requests.go deleted file mode 100644 index d4ce7c01f4..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/acl/requests.go +++ /dev/null @@ -1,111 +0,0 @@ -package acl - -import ( - "errors" - "fmt" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// List is the operation responsible for returning a paginated collection of -// network items that define a load balancer's access list. -func List(client *gophercloud.ServiceClient, lbID int) pagination.Pager { - url := rootURL(client, lbID) - - return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { - return AccessListPage{pagination.SinglePageBase(r)} - }) -} - -// CreateOptsBuilder is the interface responsible for generating the JSON -// for a Create operation. -type CreateOptsBuilder interface { - ToAccessListCreateMap() (map[string]interface{}, error) -} - -// CreateOpts is a slice of CreateOpt structs, that allow the user to create -// multiple nodes in a single operation (one node per CreateOpt). -type CreateOpts []CreateOpt - -// CreateOpt represents the options to create a single node. -type CreateOpt struct { - // Required - the IP address or CIDR for item to add to access list. - Address string - - // Required - the type of the node. Either ALLOW or DENY. - Type Type -} - -// ToAccessListCreateMap converts a slice of options into a map that can be -// used for the JSON. -func (opts CreateOpts) ToAccessListCreateMap() (map[string]interface{}, error) { - type itemMap map[string]interface{} - items := []itemMap{} - - for k, v := range opts { - if v.Address == "" { - return itemMap{}, fmt.Errorf("Address is a required attribute, none provided for %d CreateOpt element", k) - } - if v.Type != ALLOW && v.Type != DENY { - return itemMap{}, fmt.Errorf("Type must be ALLOW or DENY") - } - - item := make(itemMap) - item["address"] = v.Address - item["type"] = v.Type - - items = append(items, item) - } - - return itemMap{"accessList": items}, nil -} - -// Create is the operation responsible for adding network items to the access -// rules for a particular load balancer. If network items already exist, the -// new item will be appended. A single IP address or subnet range is considered -// unique and cannot be duplicated. -func Create(client *gophercloud.ServiceClient, loadBalancerID int, opts CreateOptsBuilder) CreateResult { - var res CreateResult - - reqBody, err := opts.ToAccessListCreateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = client.Post(rootURL(client, loadBalancerID), reqBody, nil, nil) - return res -} - -// BulkDelete will delete multiple network items from a load balancer's access -// list in a single operation. -func BulkDelete(c *gophercloud.ServiceClient, loadBalancerID int, itemIDs []int) DeleteResult { - var res DeleteResult - - if len(itemIDs) > 10 || len(itemIDs) == 0 { - res.Err = errors.New("You must provide a minimum of 1 and a maximum of 10 item IDs") - return res - } - - url := rootURL(c, loadBalancerID) - url += gophercloud.IDSliceToQueryString("id", itemIDs) - - _, res.Err = c.Delete(url, nil) - return res -} - -// Delete will remove a single network item from a load balancer's access list. -func Delete(c *gophercloud.ServiceClient, lbID, itemID int) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(resourceURL(c, lbID, itemID), nil) - return res -} - -// DeleteAll will delete the entire contents of a load balancer's access list, -// effectively resetting it and allowing all traffic. -func DeleteAll(c *gophercloud.ServiceClient, lbID int) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(rootURL(c, lbID), nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/acl/results.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/acl/results.go deleted file mode 100644 index 9ea5ea2f4b..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/acl/results.go +++ /dev/null @@ -1,72 +0,0 @@ -package acl - -import ( - "github.com/mitchellh/mapstructure" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// AccessList represents the rules of network access to a particular load -// balancer. -type AccessList []NetworkItem - -// NetworkItem describes how an IP address or entire subnet may interact with a -// load balancer. -type NetworkItem struct { - // The IP address or subnet (CIDR) that defines the network item. - Address string - - // The numeric unique ID for this item. - ID int - - // Either ALLOW or DENY. - Type Type -} - -// Type defines how an item may connect to the load balancer. -type Type string - -// Convenience consts. -const ( - ALLOW Type = "ALLOW" - DENY Type = "DENY" -) - -// AccessListPage is the page returned by a pager for traversing over a -// collection of network items in an access list. -type AccessListPage struct { - pagination.SinglePageBase -} - -// IsEmpty checks whether an AccessListPage struct is empty. -func (p AccessListPage) IsEmpty() (bool, error) { - is, err := ExtractAccessList(p) - if err != nil { - return true, nil - } - return len(is) == 0, nil -} - -// ExtractAccessList accepts a Page struct, specifically an AccessListPage -// struct, and extracts the elements into a slice of NetworkItem structs. In -// other words, a generic collection is mapped into a relevant slice. -func ExtractAccessList(page pagination.Page) (AccessList, error) { - var resp struct { - List AccessList `mapstructure:"accessList" json:"accessList"` - } - - err := mapstructure.Decode(page.(AccessListPage).Body, &resp) - - return resp.List, err -} - -// CreateResult represents the result of a create operation. -type CreateResult struct { - gophercloud.ErrResult -} - -// DeleteResult represents the result of a delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/acl/urls.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/acl/urls.go deleted file mode 100644 index e373fa1d80..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/acl/urls.go +++ /dev/null @@ -1,20 +0,0 @@ -package acl - -import ( - "strconv" - - "github.com/rackspace/gophercloud" -) - -const ( - path = "loadbalancers" - aclPath = "accesslist" -) - -func resourceURL(c *gophercloud.ServiceClient, lbID, networkID int) string { - return c.ServiceURL(path, strconv.Itoa(lbID), aclPath, strconv.Itoa(networkID)) -} - -func rootURL(c *gophercloud.ServiceClient, lbID int) string { - return c.ServiceURL(path, strconv.Itoa(lbID), aclPath) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/lbs/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/lbs/doc.go deleted file mode 100644 index 05f0032859..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/lbs/doc.go +++ /dev/null @@ -1,44 +0,0 @@ -/* -Package lbs provides information and interaction with the Load Balancer API -resource for the Rackspace Cloud Load Balancer service. - -A load balancer is a logical device which belongs to a cloud account. It is -used to distribute workloads between multiple back-end systems or services, -based on the criteria defined as part of its configuration. This configuration -is defined using the Create operation, and can be updated with Update. - -To conserve IPv4 address space, it is highly recommended that you share Virtual -IPs between load balancers. If you have at least one load balancer, you may -create subsequent ones that share a single virtual IPv4 and/or a single IPv6 by -passing in a virtual IP ID to the Update operation (instead of a type). This -feature is also highly desirable if you wish to load balance both an insecure -and secure protocol using one IP or DNS name. In order to share a virtual IP, -each Load Balancer must utilize a unique port. - -All load balancers have a Status attribute that shows the current configuration -status of the device. This status is immutable by the caller and is updated -automatically based on state changes within the service. When a load balancer -is first created, it is placed into a BUILD state while the configuration is -being generated and applied based on the request. Once the configuration is -applied and finalized, it is in an ACTIVE status. In the event of a -configuration change or update, the status of the load balancer changes to -PENDING_UPDATE to signify configuration changes are in progress but have not yet -been finalized. Load balancers in a SUSPENDED status are configured to reject -traffic and do not forward requests to back-end nodes. - -An HTTP load balancer has the X-Forwarded-For (XFF) HTTP header set by default. -This header contains the originating IP address of a client connecting to a web -server through an HTTP proxy or load balancer, which many web applications are -already designed to use when determining the source address for a request. - -It also includes the X-Forwarded-Proto (XFP) HTTP header, which has been added -for identifying the originating protocol of an HTTP request as "http" or -"https" depending on which protocol the client requested. This is useful when -using SSL termination. - -Finally, it also includes the X-Forwarded-Port HTTP header, which has been -added for being able to generate secure URLs containing the specified port. -This header, along with the X-Forwarded-For header, provides the needed -information to the underlying application servers. -*/ -package lbs diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/lbs/fixtures.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/lbs/fixtures.go deleted file mode 100644 index 6325310dbb..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/lbs/fixtures.go +++ /dev/null @@ -1,584 +0,0 @@ -package lbs - -import ( - "fmt" - "net/http" - "strconv" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -func mockListLBResponse(t *testing.T) { - th.Mux.HandleFunc("/loadbalancers", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "loadBalancers":[ - { - "name":"lb-site1", - "id":71, - "protocol":"HTTP", - "port":80, - "algorithm":"RANDOM", - "status":"ACTIVE", - "nodeCount":3, - "virtualIps":[ - { - "id":403, - "address":"206.55.130.1", - "type":"PUBLIC", - "ipVersion":"IPV4" - } - ], - "created":{ - "time":"2010-11-30T03:23:42Z" - }, - "updated":{ - "time":"2010-11-30T03:23:44Z" - } - }, - { - "name":"lb-site2", - "id":72, - "created":{ - "time":"2011-11-30T03:23:42Z" - }, - "updated":{ - "time":"2011-11-30T03:23:44Z" - } - }, - { - "name":"lb-site3", - "id":73, - "created":{ - "time":"2012-11-30T03:23:42Z" - }, - "updated":{ - "time":"2012-11-30T03:23:44Z" - } - } - ] -} - `) - }) -} - -func mockCreateLBResponse(t *testing.T) { - th.Mux.HandleFunc("/loadbalancers", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "loadBalancer": { - "name": "a-new-loadbalancer", - "port": 80, - "protocol": "HTTP", - "virtualIps": [ - { - "id": 2341 - }, - { - "id": 900001 - } - ], - "nodes": [ - { - "address": "10.1.1.1", - "port": 80, - "condition": "ENABLED" - } - ] - } -} - `) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusAccepted) - - fmt.Fprintf(w, ` -{ - "loadBalancer": { - "name": "a-new-loadbalancer", - "id": 144, - "protocol": "HTTP", - "halfClosed": false, - "port": 83, - "algorithm": "RANDOM", - "status": "BUILD", - "timeout": 30, - "cluster": { - "name": "ztm-n01.staging1.lbaas.rackspace.net" - }, - "nodes": [ - { - "address": "10.1.1.1", - "id": 653, - "port": 80, - "status": "ONLINE", - "condition": "ENABLED", - "weight": 1 - } - ], - "virtualIps": [ - { - "address": "206.10.10.210", - "id": 39, - "type": "PUBLIC", - "ipVersion": "IPV4" - }, - { - "address": "2001:4801:79f1:0002:711b:be4c:0000:0021", - "id": 900001, - "type": "PUBLIC", - "ipVersion": "IPV6" - } - ], - "created": { - "time": "2010-11-30T03:23:42Z" - }, - "updated": { - "time": "2010-11-30T03:23:44Z" - }, - "connectionLogging": { - "enabled": false - } - } -} - `) - }) -} - -func mockBatchDeleteLBResponse(t *testing.T, ids []int) { - th.Mux.HandleFunc("/loadbalancers", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - r.ParseForm() - - for k, v := range ids { - fids := r.Form["id"] - th.AssertEquals(t, strconv.Itoa(v), fids[k]) - } - - w.WriteHeader(http.StatusAccepted) - }) -} - -func mockDeleteLBResponse(t *testing.T, id int) { - th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.WriteHeader(http.StatusAccepted) - }) -} - -func mockGetLBResponse(t *testing.T, id int) { - th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "loadBalancer": { - "id": 2000, - "name": "sample-loadbalancer", - "protocol": "HTTP", - "port": 80, - "algorithm": "RANDOM", - "status": "ACTIVE", - "timeout": 30, - "connectionLogging": { - "enabled": true - }, - "virtualIps": [ - { - "id": 1000, - "address": "206.10.10.210", - "type": "PUBLIC", - "ipVersion": "IPV4" - } - ], - "nodes": [ - { - "id": 1041, - "address": "10.1.1.1", - "port": 80, - "condition": "ENABLED", - "status": "ONLINE" - }, - { - "id": 1411, - "address": "10.1.1.2", - "port": 80, - "condition": "ENABLED", - "status": "ONLINE" - } - ], - "sessionPersistence": { - "persistenceType": "HTTP_COOKIE" - }, - "connectionThrottle": { - "maxConnections": 100 - }, - "cluster": { - "name": "c1.dfw1" - }, - "created": { - "time": "2010-11-30T03:23:42Z" - }, - "updated": { - "time": "2010-11-30T03:23:44Z" - }, - "sourceAddresses": { - "ipv6Public": "2001:4801:79f1:1::1/64", - "ipv4Servicenet": "10.0.0.0", - "ipv4Public": "10.12.99.28" - } - } -} - `) - }) -} - -func mockUpdateLBResponse(t *testing.T, id int) { - th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PUT") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "loadBalancer": { - "name": "a-new-loadbalancer", - "protocol": "TCP", - "halfClosed": true, - "algorithm": "RANDOM", - "port": 8080, - "timeout": 100, - "httpsRedirect": false - } -} - `) - - w.WriteHeader(http.StatusAccepted) - }) -} - -func mockListProtocolsResponse(t *testing.T) { - th.Mux.HandleFunc("/loadbalancers/protocols", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "protocols": [ - { - "name": "DNS_TCP", - "port": 53 - }, - { - "name": "DNS_UDP", - "port": 53 - }, - { - "name": "FTP", - "port": 21 - }, - { - "name": "HTTP", - "port": 80 - }, - { - "name": "HTTPS", - "port": 443 - }, - { - "name": "IMAPS", - "port": 993 - }, - { - "name": "IMAPv4", - "port": 143 - }, - { - "name": "LDAP", - "port": 389 - }, - { - "name": "LDAPS", - "port": 636 - }, - { - "name": "MYSQL", - "port": 3306 - }, - { - "name": "POP3", - "port": 110 - }, - { - "name": "POP3S", - "port": 995 - }, - { - "name": "SMTP", - "port": 25 - }, - { - "name": "TCP", - "port": 0 - }, - { - "name": "TCP_CLIENT_FIRST", - "port": 0 - }, - { - "name": "UDP", - "port": 0 - }, - { - "name": "UDP_STREAM", - "port": 0 - }, - { - "name": "SFTP", - "port": 22 - }, - { - "name": "TCP_STREAM", - "port": 0 - } - ] -} - `) - }) -} - -func mockListAlgorithmsResponse(t *testing.T) { - th.Mux.HandleFunc("/loadbalancers/algorithms", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "algorithms": [ - { - "name": "LEAST_CONNECTIONS" - }, - { - "name": "RANDOM" - }, - { - "name": "ROUND_ROBIN" - }, - { - "name": "WEIGHTED_LEAST_CONNECTIONS" - }, - { - "name": "WEIGHTED_ROUND_ROBIN" - } - ] -} - `) - }) -} - -func mockGetLoggingResponse(t *testing.T, id int) { - th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/connectionlogging", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "connectionLogging": { - "enabled": true - } -} - `) - }) -} - -func mockEnableLoggingResponse(t *testing.T, id int) { - th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/connectionlogging", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PUT") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "connectionLogging":{ - "enabled":true - } -} - `) - - w.WriteHeader(http.StatusAccepted) - }) -} - -func mockDisableLoggingResponse(t *testing.T, id int) { - th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/connectionlogging", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PUT") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "connectionLogging":{ - "enabled":false - } -} - `) - - w.WriteHeader(http.StatusAccepted) - }) -} - -func mockGetErrorPageResponse(t *testing.T, id int) { - th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/errorpage", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "errorpage": { - "content": "DEFAULT ERROR PAGE" - } -} - `) - }) -} - -func mockSetErrorPageResponse(t *testing.T, id int) { - th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/errorpage", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PUT") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "errorpage": { - "content": "New error page" - } -} - `) - - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "errorpage": { - "content": "New error page" - } -} - `) - }) -} - -func mockDeleteErrorPageResponse(t *testing.T, id int) { - th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/errorpage", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.WriteHeader(http.StatusOK) - }) -} - -func mockGetStatsResponse(t *testing.T, id int) { - th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/stats", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "connectTimeOut": 10, - "connectError": 20, - "connectFailure": 30, - "dataTimedOut": 40, - "keepAliveTimedOut": 50, - "maxConn": 60, - "currentConn": 40, - "connectTimeOutSsl": 10, - "connectErrorSsl": 20, - "connectFailureSsl": 30, - "dataTimedOutSsl": 40, - "keepAliveTimedOutSsl": 50, - "maxConnSsl": 60, - "currentConnSsl": 40 -} - `) - }) -} - -func mockGetCachingResponse(t *testing.T, id int) { - th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/contentcaching", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "contentCaching": { - "enabled": true - } -} - `) - }) -} - -func mockEnableCachingResponse(t *testing.T, id int) { - th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/contentcaching", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PUT") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "contentCaching":{ - "enabled":true - } -} - `) - - w.WriteHeader(http.StatusAccepted) - }) -} - -func mockDisableCachingResponse(t *testing.T, id int) { - th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/contentcaching", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PUT") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "contentCaching":{ - "enabled":false - } -} - `) - - w.WriteHeader(http.StatusAccepted) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/lbs/requests.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/lbs/requests.go deleted file mode 100644 index 46f5f02a43..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/lbs/requests.go +++ /dev/null @@ -1,497 +0,0 @@ -package lbs - -import ( - "errors" - - "github.com/mitchellh/mapstructure" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" - "github.com/rackspace/gophercloud/rackspace/lb/v1/acl" - "github.com/rackspace/gophercloud/rackspace/lb/v1/monitors" - "github.com/rackspace/gophercloud/rackspace/lb/v1/nodes" - "github.com/rackspace/gophercloud/rackspace/lb/v1/sessions" - "github.com/rackspace/gophercloud/rackspace/lb/v1/throttle" - "github.com/rackspace/gophercloud/rackspace/lb/v1/vips" -) - -var ( - errNameRequired = errors.New("Name is a required attribute") - errTimeoutExceeded = errors.New("Timeout must be less than 120") -) - -// ListOptsBuilder allows extensions to add additional parameters to the -// List request. -type ListOptsBuilder interface { - ToLBListQuery() (string, error) -} - -// ListOpts allows the filtering and sorting of paginated collections through -// the API. -type ListOpts struct { - ChangesSince string `q:"changes-since"` - Status Status `q:"status"` - NodeAddr string `q:"nodeaddress"` - Marker string `q:"marker"` - Limit int `q:"limit"` -} - -// ToLBListQuery formats a ListOpts into a query string. -func (opts ListOpts) ToLBListQuery() (string, error) { - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return "", err - } - return q.String(), nil -} - -// List is the operation responsible for returning a paginated collection of -// load balancers. You may pass in a ListOpts struct to filter results. -func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { - url := rootURL(client) - if opts != nil { - query, err := opts.ToLBListQuery() - if err != nil { - return pagination.Pager{Err: err} - } - url += query - } - - return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { - return LBPage{pagination.LinkedPageBase{PageResult: r}} - }) -} - -// CreateOptsBuilder is the interface options structs have to satisfy in order -// to be used in the main Create operation in this package. Since many -// extensions decorate or modify the common logic, it is useful for them to -// satisfy a basic interface in order for them to be used. -type CreateOptsBuilder interface { - ToLBCreateMap() (map[string]interface{}, error) -} - -// CreateOpts is the common options struct used in this package's Create -// operation. -type CreateOpts struct { - // Required - name of the load balancer to create. The name must be 128 - // characters or fewer in length, and all UTF-8 characters are valid. - Name string - - // Optional - nodes to be added. - Nodes []nodes.Node - - // Required - protocol of the service that is being load balanced. - // See http://docs.rackspace.com/loadbalancers/api/v1.0/clb-devguide/content/protocols.html - // for a full list of supported protocols. - Protocol string - - // Optional - enables or disables Half-Closed support for the load balancer. - // Half-Closed support provides the ability for one end of the connection to - // terminate its output, while still receiving data from the other end. Only - // available for TCP/TCP_CLIENT_FIRST protocols. - HalfClosed gophercloud.EnabledState - - // Optional - the type of virtual IPs you want associated with the load - // balancer. - VIPs []vips.VIP - - // Optional - the access list management feature allows fine-grained network - // access controls to be applied to the load balancer virtual IP address. - AccessList *acl.AccessList - - // Optional - algorithm that defines how traffic should be directed between - // back-end nodes. - Algorithm string - - // Optional - current connection logging configuration. - ConnectionLogging *ConnectionLogging - - // Optional - specifies a limit on the number of connections per IP address - // to help mitigate malicious or abusive traffic to your applications. - ConnThrottle *throttle.ConnectionThrottle - - // Optional - the type of health monitor check to perform to ensure that the - // service is performing properly. - HealthMonitor *monitors.Monitor - - // Optional - arbitrary information that can be associated with each LB. - Metadata map[string]interface{} - - // Optional - port number for the service you are load balancing. - Port int - - // Optional - the timeout value for the load balancer and communications with - // its nodes. Defaults to 30 seconds with a maximum of 120 seconds. - Timeout int - - // Optional - specifies whether multiple requests from clients are directed - // to the same node. - SessionPersistence *sessions.SessionPersistence - - // Optional - enables or disables HTTP to HTTPS redirection for the load - // balancer. When enabled, any HTTP request returns status code 301 (Moved - // Permanently), and the requester is redirected to the requested URL via the - // HTTPS protocol on port 443. For example, http://example.com/page.html - // would be redirected to https://example.com/page.html. Only available for - // HTTPS protocol (port=443), or HTTP protocol with a properly configured SSL - // termination (secureTrafficOnly=true, securePort=443). - HTTPSRedirect gophercloud.EnabledState -} - -// ToLBCreateMap casts a CreateOpts struct to a map. -func (opts CreateOpts) ToLBCreateMap() (map[string]interface{}, error) { - lb := make(map[string]interface{}) - - if opts.Name == "" { - return lb, errNameRequired - } - if opts.Timeout > 120 { - return lb, errTimeoutExceeded - } - - lb["name"] = opts.Name - - if len(opts.Nodes) > 0 { - nodes := []map[string]interface{}{} - for _, n := range opts.Nodes { - nodes = append(nodes, map[string]interface{}{ - "address": n.Address, - "port": n.Port, - "condition": n.Condition, - }) - } - lb["nodes"] = nodes - } - - if opts.Protocol != "" { - lb["protocol"] = opts.Protocol - } - if opts.HalfClosed != nil { - lb["halfClosed"] = opts.HalfClosed - } - if len(opts.VIPs) > 0 { - lb["virtualIps"] = opts.VIPs - } - if opts.AccessList != nil { - lb["accessList"] = &opts.AccessList - } - if opts.Algorithm != "" { - lb["algorithm"] = opts.Algorithm - } - if opts.ConnectionLogging != nil { - lb["connectionLogging"] = &opts.ConnectionLogging - } - if opts.ConnThrottle != nil { - lb["connectionThrottle"] = &opts.ConnThrottle - } - if opts.HealthMonitor != nil { - lb["healthMonitor"] = &opts.HealthMonitor - } - if len(opts.Metadata) != 0 { - lb["metadata"] = opts.Metadata - } - if opts.Port > 0 { - lb["port"] = opts.Port - } - if opts.Timeout > 0 { - lb["timeout"] = opts.Timeout - } - if opts.SessionPersistence != nil { - lb["sessionPersistence"] = &opts.SessionPersistence - } - if opts.HTTPSRedirect != nil { - lb["httpsRedirect"] = &opts.HTTPSRedirect - } - - return map[string]interface{}{"loadBalancer": lb}, nil -} - -// Create is the operation responsible for asynchronously provisioning a new -// load balancer based on the configuration defined in CreateOpts. Once the -// request is validated and progress has started on the provisioning process, a -// response struct is returned. When extracted (with Extract()), you have -// to the load balancer's unique ID and status. -// -// Once an ID is attained, you can check on the progress of the operation by -// calling Get and passing in the ID. If the corresponding request cannot be -// fulfilled due to insufficient or invalid data, an HTTP 400 (Bad Request) -// error response is returned with information regarding the nature of the -// failure in the body of the response. Failures in the validation process are -// non-recoverable and require the caller to correct the cause of the failure. -func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult { - var res CreateResult - - reqBody, err := opts.ToLBCreateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil) - return res -} - -// Get is the operation responsible for providing detailed information -// regarding a specific load balancer which is configured and associated with -// your account. This operation is not capable of returning details for a load -// balancer which has been deleted. -func Get(c *gophercloud.ServiceClient, id int) GetResult { - var res GetResult - - _, res.Err = c.Get(resourceURL(c, id), &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - - return res -} - -// BulkDelete removes all the load balancers referenced in the slice of IDs. -// Any and all configuration data associated with these load balancers is -// immediately purged and is not recoverable. -// -// If one of the items in the list cannot be removed due to its current status, -// a 400 Bad Request error is returned along with the IDs of the ones the -// system identified as potential failures for this request. -func BulkDelete(c *gophercloud.ServiceClient, ids []int) DeleteResult { - var res DeleteResult - - if len(ids) > 10 || len(ids) == 0 { - res.Err = errors.New("You must provide a minimum of 1 and a maximum of 10 LB IDs") - return res - } - - url := rootURL(c) - url += gophercloud.IDSliceToQueryString("id", ids) - - _, res.Err = c.Delete(url, nil) - return res -} - -// Delete removes a single load balancer. -func Delete(c *gophercloud.ServiceClient, id int) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(resourceURL(c, id), nil) - return res -} - -// UpdateOptsBuilder represents a type that can be converted into a JSON-like -// map structure. -type UpdateOptsBuilder interface { - ToLBUpdateMap() (map[string]interface{}, error) -} - -// UpdateOpts represents the options for updating an existing load balancer. -type UpdateOpts struct { - // Optional - new name of the load balancer. - Name string - - // Optional - the new protocol you want your load balancer to have. - // See http://docs.rackspace.com/loadbalancers/api/v1.0/clb-devguide/content/protocols.html - // for a full list of supported protocols. - Protocol string - - // Optional - see the HalfClosed field in CreateOpts for more information. - HalfClosed gophercloud.EnabledState - - // Optional - see the Algorithm field in CreateOpts for more information. - Algorithm string - - // Optional - see the Port field in CreateOpts for more information. - Port int - - // Optional - see the Timeout field in CreateOpts for more information. - Timeout int - - // Optional - see the HTTPSRedirect field in CreateOpts for more information. - HTTPSRedirect gophercloud.EnabledState -} - -// ToLBUpdateMap casts an UpdateOpts struct to a map. -func (opts UpdateOpts) ToLBUpdateMap() (map[string]interface{}, error) { - lb := make(map[string]interface{}) - - if opts.Name != "" { - lb["name"] = opts.Name - } - if opts.Protocol != "" { - lb["protocol"] = opts.Protocol - } - if opts.HalfClosed != nil { - lb["halfClosed"] = opts.HalfClosed - } - if opts.Algorithm != "" { - lb["algorithm"] = opts.Algorithm - } - if opts.Port > 0 { - lb["port"] = opts.Port - } - if opts.Timeout > 0 { - lb["timeout"] = opts.Timeout - } - if opts.HTTPSRedirect != nil { - lb["httpsRedirect"] = &opts.HTTPSRedirect - } - - return map[string]interface{}{"loadBalancer": lb}, nil -} - -// Update is the operation responsible for asynchronously updating the -// attributes of a specific load balancer. Upon successful validation of the -// request, the service returns a 202 Accepted response, and the load balancer -// enters a PENDING_UPDATE state. A user can poll the load balancer with Get to -// wait for the changes to be applied. When this happens, the load balancer will -// return to an ACTIVE state. -func Update(c *gophercloud.ServiceClient, id int, opts UpdateOptsBuilder) UpdateResult { - var res UpdateResult - - reqBody, err := opts.ToLBUpdateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = c.Put(resourceURL(c, id), reqBody, nil, nil) - return res -} - -// ListProtocols is the operation responsible for returning a paginated -// collection of load balancer protocols. -func ListProtocols(client *gophercloud.ServiceClient) pagination.Pager { - url := protocolsURL(client) - return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { - return ProtocolPage{pagination.SinglePageBase(r)} - }) -} - -// ListAlgorithms is the operation responsible for returning a paginated -// collection of load balancer algorithms. -func ListAlgorithms(client *gophercloud.ServiceClient) pagination.Pager { - url := algorithmsURL(client) - return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { - return AlgorithmPage{pagination.SinglePageBase(r)} - }) -} - -// IsLoggingEnabled returns true if the load balancer has connection logging -// enabled and false if not. -func IsLoggingEnabled(client *gophercloud.ServiceClient, id int) (bool, error) { - var body interface{} - - _, err := client.Get(loggingURL(client, id), &body, nil) - if err != nil { - return false, err - } - - var resp struct { - CL struct { - Enabled bool `mapstructure:"enabled"` - } `mapstructure:"connectionLogging"` - } - - err = mapstructure.Decode(body, &resp) - return resp.CL.Enabled, err -} - -func toConnLoggingMap(state bool) map[string]map[string]bool { - return map[string]map[string]bool{ - "connectionLogging": map[string]bool{"enabled": state}, - } -} - -// EnableLogging will enable connection logging for a specified load balancer. -func EnableLogging(client *gophercloud.ServiceClient, id int) gophercloud.ErrResult { - var res gophercloud.ErrResult - _, res.Err = client.Put(loggingURL(client, id), toConnLoggingMap(true), nil, nil) - return res -} - -// DisableLogging will disable connection logging for a specified load balancer. -func DisableLogging(client *gophercloud.ServiceClient, id int) gophercloud.ErrResult { - var res gophercloud.ErrResult - _, res.Err = client.Put(loggingURL(client, id), toConnLoggingMap(false), nil, nil) - return res -} - -// GetErrorPage will retrieve the current error page for the load balancer. -func GetErrorPage(client *gophercloud.ServiceClient, id int) ErrorPageResult { - var res ErrorPageResult - _, res.Err = client.Get(errorPageURL(client, id), &res.Body, nil) - return res -} - -// SetErrorPage will set the HTML of the load balancer's error page to a -// specific value. -func SetErrorPage(client *gophercloud.ServiceClient, id int, html string) ErrorPageResult { - var res ErrorPageResult - - type stringMap map[string]string - reqBody := map[string]stringMap{"errorpage": stringMap{"content": html}} - - _, res.Err = client.Put(errorPageURL(client, id), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - - return res -} - -// DeleteErrorPage will delete the current error page for the load balancer. -func DeleteErrorPage(client *gophercloud.ServiceClient, id int) gophercloud.ErrResult { - var res gophercloud.ErrResult - _, res.Err = client.Delete(errorPageURL(client, id), &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - return res -} - -// GetStats will retrieve detailed stats related to the load balancer's usage. -func GetStats(client *gophercloud.ServiceClient, id int) StatsResult { - var res StatsResult - _, res.Err = client.Get(statsURL(client, id), &res.Body, nil) - return res -} - -// IsContentCached will check to see whether the specified load balancer caches -// content. When content caching is enabled, recently-accessed files are stored -// on the load balancer for easy retrieval by web clients. Content caching -// improves the performance of high traffic web sites by temporarily storing -// data that was recently accessed. While it's cached, requests for that data -// are served by the load balancer, which in turn reduces load off the back-end -// nodes. The result is improved response times for those requests and less -// load on the web server. -func IsContentCached(client *gophercloud.ServiceClient, id int) (bool, error) { - var body interface{} - - _, err := client.Get(cacheURL(client, id), &body, nil) - if err != nil { - return false, err - } - - var resp struct { - CC struct { - Enabled bool `mapstructure:"enabled"` - } `mapstructure:"contentCaching"` - } - - err = mapstructure.Decode(body, &resp) - return resp.CC.Enabled, err -} - -func toCachingMap(state bool) map[string]map[string]bool { - return map[string]map[string]bool{ - "contentCaching": map[string]bool{"enabled": state}, - } -} - -// EnableCaching will enable content-caching for the specified load balancer. -func EnableCaching(client *gophercloud.ServiceClient, id int) gophercloud.ErrResult { - var res gophercloud.ErrResult - _, res.Err = client.Put(cacheURL(client, id), toCachingMap(true), nil, nil) - return res -} - -// DisableCaching will disable content-caching for the specified load balancer. -func DisableCaching(client *gophercloud.ServiceClient, id int) gophercloud.ErrResult { - var res gophercloud.ErrResult - _, res.Err = client.Put(cacheURL(client, id), toCachingMap(false), nil, nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/lbs/results.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/lbs/results.go deleted file mode 100644 index 98f3962d77..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/lbs/results.go +++ /dev/null @@ -1,420 +0,0 @@ -package lbs - -import ( - "reflect" - "time" - - "github.com/mitchellh/mapstructure" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" - "github.com/rackspace/gophercloud/rackspace/lb/v1/acl" - "github.com/rackspace/gophercloud/rackspace/lb/v1/nodes" - "github.com/rackspace/gophercloud/rackspace/lb/v1/sessions" - "github.com/rackspace/gophercloud/rackspace/lb/v1/throttle" - "github.com/rackspace/gophercloud/rackspace/lb/v1/vips" -) - -// Protocol represents the network protocol which the load balancer accepts. -type Protocol struct { - // The name of the protocol, e.g. HTTP, LDAP, FTP, etc. - Name string - - // The port number for the protocol. - Port int -} - -// Algorithm defines how traffic should be directed between back-end nodes. -type Algorithm struct { - // The name of the algorithm, e.g RANDOM, ROUND_ROBIN, etc. - Name string -} - -// Status represents the potential state of a load balancer resource. -type Status string - -const ( - // ACTIVE indicates that the LB is configured properly and ready to serve - // traffic to incoming requests via the configured virtual IPs. - ACTIVE Status = "ACTIVE" - - // BUILD indicates that the LB is being provisioned for the first time and - // configuration is being applied to bring the service online. The service - // cannot yet serve incoming requests. - BUILD Status = "BUILD" - - // PENDINGUPDATE indicates that the LB is online but configuration changes - // are being applied to update the service based on a previous request. - PENDINGUPDATE Status = "PENDING_UPDATE" - - // PENDINGDELETE indicates that the LB is online but configuration changes - // are being applied to begin deletion of the service based on a previous - // request. - PENDINGDELETE Status = "PENDING_DELETE" - - // SUSPENDED indicates that the LB has been taken offline and disabled. - SUSPENDED Status = "SUSPENDED" - - // ERROR indicates that the system encountered an error when attempting to - // configure the load balancer. - ERROR Status = "ERROR" - - // DELETED indicates that the LB has been deleted. - DELETED Status = "DELETED" -) - -// Datetime represents the structure of a Created or Updated field. -type Datetime struct { - Time time.Time `mapstructure:"-"` -} - -// LoadBalancer represents a load balancer API resource. -type LoadBalancer struct { - // Human-readable name for the load balancer. - Name string - - // The unique ID for the load balancer. - ID int - - // Represents the service protocol being load balanced. See Protocol type for - // a list of accepted values. - // See http://docs.rackspace.com/loadbalancers/api/v1.0/clb-devguide/content/protocols.html - // for a full list of supported protocols. - Protocol string - - // Defines how traffic should be directed between back-end nodes. The default - // algorithm is RANDOM. See Algorithm type for a list of accepted values. - Algorithm string - - // The current status of the load balancer. - Status Status - - // The number of load balancer nodes. - NodeCount int `mapstructure:"nodeCount"` - - // Slice of virtual IPs associated with this load balancer. - VIPs []vips.VIP `mapstructure:"virtualIps"` - - // Datetime when the LB was created. - Created Datetime - - // Datetime when the LB was created. - Updated Datetime - - // Port number for the service you are load balancing. - Port int - - // HalfClosed provides the ability for one end of the connection to - // terminate its output while still receiving data from the other end. This - // is only available on TCP/TCP_CLIENT_FIRST protocols. - HalfClosed bool - - // Timeout represents the timeout value between a load balancer and its - // nodes. Defaults to 30 seconds with a maximum of 120 seconds. - Timeout int - - // The cluster name. - Cluster Cluster - - // Nodes shows all the back-end nodes which are associated with the load - // balancer. These are the devices which are delivered traffic. - Nodes []nodes.Node - - // Current connection logging configuration. - ConnectionLogging ConnectionLogging - - // SessionPersistence specifies whether multiple requests from clients are - // directed to the same node. - SessionPersistence sessions.SessionPersistence - - // ConnectionThrottle specifies a limit on the number of connections per IP - // address to help mitigate malicious or abusive traffic to your applications. - ConnectionThrottle throttle.ConnectionThrottle - - // The source public and private IP addresses. - SourceAddrs SourceAddrs `mapstructure:"sourceAddresses"` - - // Represents the access rules for this particular load balancer. IP addresses - // or subnet ranges, depending on their type (ALLOW or DENY), can be permitted - // or blocked. - AccessList acl.AccessList -} - -// SourceAddrs represents the source public and private IP addresses. -type SourceAddrs struct { - IPv4Public string `json:"ipv4Public" mapstructure:"ipv4Public"` - IPv4Private string `json:"ipv4Servicenet" mapstructure:"ipv4Servicenet"` - IPv6Public string `json:"ipv6Public" mapstructure:"ipv6Public"` - IPv6Private string `json:"ipv6Servicenet" mapstructure:"ipv6Servicenet"` -} - -// ConnectionLogging - temp -type ConnectionLogging struct { - Enabled bool -} - -// Cluster - temp -type Cluster struct { - Name string -} - -// LBPage is the page returned by a pager when traversing over a collection of -// LBs. -type LBPage struct { - pagination.LinkedPageBase -} - -// IsEmpty checks whether a NetworkPage struct is empty. -func (p LBPage) IsEmpty() (bool, error) { - is, err := ExtractLBs(p) - if err != nil { - return true, nil - } - return len(is) == 0, nil -} - -// ExtractLBs accepts a Page struct, specifically a LBPage struct, and extracts -// the elements into a slice of LoadBalancer structs. In other words, a generic -// collection is mapped into a relevant slice. -func ExtractLBs(page pagination.Page) ([]LoadBalancer, error) { - var resp struct { - LBs []LoadBalancer `mapstructure:"loadBalancers" json:"loadBalancers"` - } - - coll := page.(LBPage).Body - err := mapstructure.Decode(coll, &resp) - - s := reflect.ValueOf(coll.(map[string]interface{})["loadBalancers"]) - - for i := 0; i < s.Len(); i++ { - val := (s.Index(i).Interface()).(map[string]interface{}) - - ts, err := extractTS(val, "created") - if err != nil { - return resp.LBs, err - } - resp.LBs[i].Created.Time = ts - - ts, err = extractTS(val, "updated") - if err != nil { - return resp.LBs, err - } - resp.LBs[i].Updated.Time = ts - } - - return resp.LBs, err -} - -func extractTS(body map[string]interface{}, key string) (time.Time, error) { - val := body[key].(map[string]interface{}) - return time.Parse(time.RFC3339, val["time"].(string)) -} - -type commonResult struct { - gophercloud.Result -} - -// Extract interprets any commonResult as a LB, if possible. -func (r commonResult) Extract() (*LoadBalancer, error) { - if r.Err != nil { - return nil, r.Err - } - - var response struct { - LB LoadBalancer `mapstructure:"loadBalancer"` - } - - err := mapstructure.Decode(r.Body, &response) - - json := r.Body.(map[string]interface{}) - lb := json["loadBalancer"].(map[string]interface{}) - - ts, err := extractTS(lb, "created") - if err != nil { - return nil, err - } - response.LB.Created.Time = ts - - ts, err = extractTS(lb, "updated") - if err != nil { - return nil, err - } - response.LB.Updated.Time = ts - - return &response.LB, err -} - -// CreateResult represents the result of a create operation. -type CreateResult struct { - commonResult -} - -// DeleteResult represents the result of a delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} - -// UpdateResult represents the result of an update operation. -type UpdateResult struct { - gophercloud.ErrResult -} - -// GetResult represents the result of a get operation. -type GetResult struct { - commonResult -} - -// ProtocolPage is the page returned by a pager when traversing over a -// collection of LB protocols. -type ProtocolPage struct { - pagination.SinglePageBase -} - -// IsEmpty checks whether a ProtocolPage struct is empty. -func (p ProtocolPage) IsEmpty() (bool, error) { - is, err := ExtractProtocols(p) - if err != nil { - return true, nil - } - return len(is) == 0, nil -} - -// ExtractProtocols accepts a Page struct, specifically a ProtocolPage struct, -// and extracts the elements into a slice of Protocol structs. In other -// words, a generic collection is mapped into a relevant slice. -func ExtractProtocols(page pagination.Page) ([]Protocol, error) { - var resp struct { - Protocols []Protocol `mapstructure:"protocols" json:"protocols"` - } - err := mapstructure.Decode(page.(ProtocolPage).Body, &resp) - return resp.Protocols, err -} - -// AlgorithmPage is the page returned by a pager when traversing over a -// collection of LB algorithms. -type AlgorithmPage struct { - pagination.SinglePageBase -} - -// IsEmpty checks whether an AlgorithmPage struct is empty. -func (p AlgorithmPage) IsEmpty() (bool, error) { - is, err := ExtractAlgorithms(p) - if err != nil { - return true, nil - } - return len(is) == 0, nil -} - -// ExtractAlgorithms accepts a Page struct, specifically an AlgorithmPage struct, -// and extracts the elements into a slice of Algorithm structs. In other -// words, a generic collection is mapped into a relevant slice. -func ExtractAlgorithms(page pagination.Page) ([]Algorithm, error) { - var resp struct { - Algorithms []Algorithm `mapstructure:"algorithms" json:"algorithms"` - } - err := mapstructure.Decode(page.(AlgorithmPage).Body, &resp) - return resp.Algorithms, err -} - -// ErrorPage represents the HTML file that is shown to an end user who is -// attempting to access a load balancer node that is offline/unavailable. -// -// During provisioning, every load balancer is configured with a default error -// page that gets displayed when traffic is requested for an offline node. -// -// You can add a single custom error page with an HTTP-based protocol to a load -// balancer. Page updates override existing content. If a custom error page is -// deleted, or the load balancer is changed to a non-HTTP protocol, the default -// error page is restored. -type ErrorPage struct { - Content string -} - -// ErrorPageResult represents the result of an error page operation - -// specifically getting or creating one. -type ErrorPageResult struct { - gophercloud.Result -} - -// Extract interprets any commonResult as an ErrorPage, if possible. -func (r ErrorPageResult) Extract() (*ErrorPage, error) { - if r.Err != nil { - return nil, r.Err - } - - var response struct { - ErrorPage ErrorPage `mapstructure:"errorpage"` - } - - err := mapstructure.Decode(r.Body, &response) - - return &response.ErrorPage, err -} - -// Stats represents all the key information about a load balancer's usage. -type Stats struct { - // The number of connections closed by this load balancer because its - // ConnectTimeout interval was exceeded. - ConnectTimeout int `mapstructure:"connectTimeOut"` - - // The number of transaction or protocol errors for this load balancer. - ConnectError int - - // Number of connection failures for this load balancer. - ConnectFailure int - - // Number of connections closed by this load balancer because its Timeout - // interval was exceeded. - DataTimedOut int - - // Number of connections closed by this load balancer because the - // 'keepalive_timeout' interval was exceeded. - KeepAliveTimedOut int - - // The maximum number of simultaneous TCP connections this load balancer has - // processed at any one time. - MaxConnections int `mapstructure:"maxConn"` - - // Number of simultaneous connections active at the time of the request. - CurrentConnections int `mapstructure:"currentConn"` - - // Number of SSL connections closed by this load balancer because the - // ConnectTimeout interval was exceeded. - SSLConnectTimeout int `mapstructure:"connectTimeOutSsl"` - - // Number of SSL transaction or protocol erros in this load balancer. - SSLConnectError int `mapstructure:"connectErrorSsl"` - - // Number of SSL connection failures in this load balancer. - SSLConnectFailure int `mapstructure:"connectFailureSsl"` - - // Number of SSL connections closed by this load balancer because the - // Timeout interval was exceeded. - SSLDataTimedOut int `mapstructure:"dataTimedOutSsl"` - - // Number of SSL connections closed by this load balancer because the - // 'keepalive_timeout' interval was exceeded. - SSLKeepAliveTimedOut int `mapstructure:"keepAliveTimedOutSsl"` - - // Maximum number of simultaneous SSL connections this load balancer has - // processed at any one time. - SSLMaxConnections int `mapstructure:"maxConnSsl"` - - // Number of simultaneous SSL connections active at the time of the request. - SSLCurrentConnections int `mapstructure:"currentConnSsl"` -} - -// StatsResult represents the result of a Stats operation. -type StatsResult struct { - gophercloud.Result -} - -// Extract interprets any commonResult as a Stats struct, if possible. -func (r StatsResult) Extract() (*Stats, error) { - if r.Err != nil { - return nil, r.Err - } - res := &Stats{} - err := mapstructure.Decode(r.Body, res) - return res, err -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/lbs/urls.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/lbs/urls.go deleted file mode 100644 index 471a86b0a7..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/lbs/urls.go +++ /dev/null @@ -1,49 +0,0 @@ -package lbs - -import ( - "strconv" - - "github.com/rackspace/gophercloud" -) - -const ( - path = "loadbalancers" - protocolsPath = "protocols" - algorithmsPath = "algorithms" - logPath = "connectionlogging" - epPath = "errorpage" - stPath = "stats" - cachePath = "contentcaching" -) - -func resourceURL(c *gophercloud.ServiceClient, id int) string { - return c.ServiceURL(path, strconv.Itoa(id)) -} - -func rootURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(path) -} - -func protocolsURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(path, protocolsPath) -} - -func algorithmsURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(path, algorithmsPath) -} - -func loggingURL(c *gophercloud.ServiceClient, id int) string { - return c.ServiceURL(path, strconv.Itoa(id), logPath) -} - -func errorPageURL(c *gophercloud.ServiceClient, id int) string { - return c.ServiceURL(path, strconv.Itoa(id), epPath) -} - -func statsURL(c *gophercloud.ServiceClient, id int) string { - return c.ServiceURL(path, strconv.Itoa(id), stPath) -} - -func cacheURL(c *gophercloud.ServiceClient, id int) string { - return c.ServiceURL(path, strconv.Itoa(id), cachePath) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/monitors/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/monitors/doc.go deleted file mode 100644 index 2c5be75ae4..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/monitors/doc.go +++ /dev/null @@ -1,21 +0,0 @@ -/* -Package monitors provides information and interaction with the Health Monitor -API resource for the Rackspace Cloud Load Balancer service. - -The load balancing service includes a health monitoring resource that -periodically checks your back-end nodes to ensure they are responding correctly. -If a node does not respond, it is removed from rotation until the health monitor -determines that the node is functional. In addition to being performed -periodically, a health check also executes against every new node that is -added, to ensure that the node is operating properly before allowing it to -service traffic. Only one health monitor is allowed to be enabled on a load -balancer at a time. - -As part of a good strategy for monitoring connections, secondary nodes should -also be created which provide failover for effectively routing traffic in case -the primary node fails. This is an additional feature that ensures that you -remain up in case your primary node fails. - -There are three types of health monitor: CONNECT, HTTP and HTTPS. -*/ -package monitors diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/monitors/fixtures.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/monitors/fixtures.go deleted file mode 100644 index a565abced5..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/monitors/fixtures.go +++ /dev/null @@ -1,87 +0,0 @@ -package monitors - -import ( - "fmt" - "net/http" - "strconv" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -func _rootURL(lbID int) string { - return "/loadbalancers/" + strconv.Itoa(lbID) + "/healthmonitor" -} - -func mockGetResponse(t *testing.T, lbID int) { - th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "healthMonitor": { - "type": "CONNECT", - "delay": 10, - "timeout": 10, - "attemptsBeforeDeactivation": 3 - } -} - `) - }) -} - -func mockUpdateConnectResponse(t *testing.T, lbID int) { - th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PUT") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "healthMonitor": { - "type": "CONNECT", - "delay": 10, - "timeout": 10, - "attemptsBeforeDeactivation": 3 - } -} - `) - - w.WriteHeader(http.StatusAccepted) - }) -} - -func mockUpdateHTTPResponse(t *testing.T, lbID int) { - th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PUT") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "healthMonitor": { - "attemptsBeforeDeactivation": 3, - "bodyRegex": "{regex}", - "delay": 10, - "path": "/foo", - "statusRegex": "200", - "timeout": 10, - "type": "HTTPS" - } -} - `) - - w.WriteHeader(http.StatusAccepted) - }) -} - -func mockDeleteResponse(t *testing.T, lbID int) { - th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.WriteHeader(http.StatusAccepted) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/monitors/requests.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/monitors/requests.go deleted file mode 100644 index d4ba27653c..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/monitors/requests.go +++ /dev/null @@ -1,160 +0,0 @@ -package monitors - -import ( - "errors" - - "github.com/rackspace/gophercloud" -) - -var ( - errAttemptLimit = errors.New("AttemptLimit field must be an int greater than 1 and less than 10") - errDelay = errors.New("Delay field must be an int greater than 1 and less than 10") - errTimeout = errors.New("Timeout field must be an int greater than 1 and less than 10") -) - -// UpdateOptsBuilder is the interface options structs have to satisfy in order -// to be used in the main Update operation in this package. -type UpdateOptsBuilder interface { - ToMonitorUpdateMap() (map[string]interface{}, error) -} - -// UpdateConnectMonitorOpts represents the options needed to update a CONNECT -// monitor. -type UpdateConnectMonitorOpts struct { - // Required - number of permissible monitor failures before removing a node - // from rotation. Must be a number between 1 and 10. - AttemptLimit int - - // Required - the minimum number of seconds to wait before executing the - // health monitor. Must be a number between 1 and 3600. - Delay int - - // Required - maximum number of seconds to wait for a connection to be - // established before timing out. Must be a number between 1 and 300. - Timeout int -} - -// ToMonitorUpdateMap produces a map for updating CONNECT monitors. -func (opts UpdateConnectMonitorOpts) ToMonitorUpdateMap() (map[string]interface{}, error) { - type m map[string]interface{} - - if !gophercloud.IntWithinRange(opts.AttemptLimit, 1, 10) { - return m{}, errAttemptLimit - } - if !gophercloud.IntWithinRange(opts.Delay, 1, 3600) { - return m{}, errDelay - } - if !gophercloud.IntWithinRange(opts.Timeout, 1, 300) { - return m{}, errTimeout - } - - return m{"healthMonitor": m{ - "attemptsBeforeDeactivation": opts.AttemptLimit, - "delay": opts.Delay, - "timeout": opts.Timeout, - "type": CONNECT, - }}, nil -} - -// UpdateHTTPMonitorOpts represents the options needed to update a HTTP monitor. -type UpdateHTTPMonitorOpts struct { - // Required - number of permissible monitor failures before removing a node - // from rotation. Must be a number between 1 and 10. - AttemptLimit int `mapstructure:"attemptsBeforeDeactivation"` - - // Required - the minimum number of seconds to wait before executing the - // health monitor. Must be a number between 1 and 3600. - Delay int - - // Required - maximum number of seconds to wait for a connection to be - // established before timing out. Must be a number between 1 and 300. - Timeout int - - // Required - a regular expression that will be used to evaluate the contents - // of the body of the response. - BodyRegex string - - // Required - the HTTP path that will be used in the sample request. - Path string - - // Required - a regular expression that will be used to evaluate the HTTP - // status code returned in the response. - StatusRegex string - - // Optional - the name of a host for which the health monitors will check. - HostHeader string - - // Required - either HTTP or HTTPS - Type Type -} - -// ToMonitorUpdateMap produces a map for updating HTTP(S) monitors. -func (opts UpdateHTTPMonitorOpts) ToMonitorUpdateMap() (map[string]interface{}, error) { - type m map[string]interface{} - - if !gophercloud.IntWithinRange(opts.AttemptLimit, 1, 10) { - return m{}, errAttemptLimit - } - if !gophercloud.IntWithinRange(opts.Delay, 1, 3600) { - return m{}, errDelay - } - if !gophercloud.IntWithinRange(opts.Timeout, 1, 300) { - return m{}, errTimeout - } - if opts.Type != HTTP && opts.Type != HTTPS { - return m{}, errors.New("Type must either by HTTP or HTTPS") - } - if opts.BodyRegex == "" { - return m{}, errors.New("BodyRegex is a required field") - } - if opts.Path == "" { - return m{}, errors.New("Path is a required field") - } - if opts.StatusRegex == "" { - return m{}, errors.New("StatusRegex is a required field") - } - - json := m{ - "attemptsBeforeDeactivation": opts.AttemptLimit, - "delay": opts.Delay, - "timeout": opts.Timeout, - "type": opts.Type, - "bodyRegex": opts.BodyRegex, - "path": opts.Path, - "statusRegex": opts.StatusRegex, - } - - if opts.HostHeader != "" { - json["hostHeader"] = opts.HostHeader - } - - return m{"healthMonitor": json}, nil -} - -// Update is the operation responsible for updating a health monitor. -func Update(c *gophercloud.ServiceClient, id int, opts UpdateOptsBuilder) UpdateResult { - var res UpdateResult - - reqBody, err := opts.ToMonitorUpdateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = c.Put(rootURL(c, id), reqBody, nil, nil) - return res -} - -// Get is the operation responsible for showing details of a health monitor. -func Get(c *gophercloud.ServiceClient, id int) GetResult { - var res GetResult - _, res.Err = c.Get(rootURL(c, id), &res.Body, nil) - return res -} - -// Delete is the operation responsible for deleting a health monitor. -func Delete(c *gophercloud.ServiceClient, id int) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(rootURL(c, id), nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/monitors/results.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/monitors/results.go deleted file mode 100644 index eec556f343..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/monitors/results.go +++ /dev/null @@ -1,90 +0,0 @@ -package monitors - -import ( - "github.com/mitchellh/mapstructure" - - "github.com/rackspace/gophercloud" -) - -// Type represents the type of Monitor. -type Type string - -// Useful constants. -const ( - CONNECT Type = "CONNECT" - HTTP Type = "HTTP" - HTTPS Type = "HTTPS" -) - -// Monitor represents a health monitor API resource. A monitor comes in three -// forms: CONNECT, HTTP or HTTPS. -// -// A CONNECT monitor establishes a basic connection to each node on its defined -// port to ensure that the service is listening properly. The connect monitor -// is the most basic type of health check and does no post-processing or -// protocol-specific health checks. -// -// HTTP and HTTPS health monitors are generally considered more intelligent and -// powerful than CONNECT. It is capable of processing an HTTP or HTTPS response -// to determine the condition of a node. It supports the same basic properties -// as CONNECT and includes additional attributes that are used to evaluate the -// HTTP response. -type Monitor struct { - // Number of permissible monitor failures before removing a node from - // rotation. - AttemptLimit int `mapstructure:"attemptsBeforeDeactivation"` - - // The minimum number of seconds to wait before executing the health monitor. - Delay int - - // Maximum number of seconds to wait for a connection to be established - // before timing out. - Timeout int - - // Type of the health monitor. - Type Type - - // A regular expression that will be used to evaluate the contents of the - // body of the response. - BodyRegex string - - // The name of a host for which the health monitors will check. - HostHeader string - - // The HTTP path that will be used in the sample request. - Path string - - // A regular expression that will be used to evaluate the HTTP status code - // returned in the response. - StatusRegex string -} - -// UpdateResult represents the result of an Update operation. -type UpdateResult struct { - gophercloud.ErrResult -} - -// GetResult represents the result of a Get operation. -type GetResult struct { - gophercloud.Result -} - -// DeleteResult represents the result of an Delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} - -// Extract interprets any GetResult as a Monitor. -func (r GetResult) Extract() (*Monitor, error) { - if r.Err != nil { - return nil, r.Err - } - - var response struct { - M Monitor `mapstructure:"healthMonitor"` - } - - err := mapstructure.Decode(r.Body, &response) - - return &response.M, err -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/monitors/urls.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/monitors/urls.go deleted file mode 100644 index 0a1e6df5f4..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/monitors/urls.go +++ /dev/null @@ -1,16 +0,0 @@ -package monitors - -import ( - "strconv" - - "github.com/rackspace/gophercloud" -) - -const ( - path = "loadbalancers" - monitorPath = "healthmonitor" -) - -func rootURL(c *gophercloud.ServiceClient, lbID int) string { - return c.ServiceURL(path, strconv.Itoa(lbID), monitorPath) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/nodes/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/nodes/doc.go deleted file mode 100644 index 49c431894a..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/nodes/doc.go +++ /dev/null @@ -1,35 +0,0 @@ -/* -Package nodes provides information and interaction with the Node API resource -for the Rackspace Cloud Load Balancer service. - -Nodes are responsible for servicing the requests received through the load -balancer's virtual IP. A node is usually a virtual machine. By default, the -load balancer employs a basic health check that ensures the node is listening -on its defined port. The node is checked at the time of addition and at regular -intervals as defined by the load balancer's health check configuration. If a -back-end node is not listening on its port, or does not meet the conditions of -the defined check, then connections will not be forwarded to the node, and its -status is changed to OFFLINE. Only nodes that are in an ONLINE status receive -and can service traffic from the load balancer. - -All nodes have an associated status that indicates whether the node is -ONLINE, OFFLINE, or DRAINING. Only nodes that are in ONLINE status can receive -and service traffic from the load balancer. The OFFLINE status represents a -node that cannot accept or service traffic. A node in DRAINING status -represents a node that stops the traffic manager from sending any additional -new connections to the node, but honors established sessions. If the traffic -manager receives a request and session persistence requires that the node is -used, the traffic manager uses it. The status is determined by the passive or -active health monitors. - -If the WEIGHTED_ROUND_ROBIN load balancer algorithm mode is selected, then the -caller should assign the relevant weights to the node as part of the weight -attribute of the node element. When the algorithm of the load balancer is -changed to WEIGHTED_ROUND_ROBIN and the nodes do not already have an assigned -weight, the service automatically sets the weight to 1 for all nodes. - -One or more secondary nodes can be added to a specified load balancer so that -if all the primary nodes fail, traffic can be redirected to secondary nodes. -The type attribute allows configuring the node as either PRIMARY or SECONDARY. -*/ -package nodes diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/nodes/fixtures.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/nodes/fixtures.go deleted file mode 100644 index 7c85945caf..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/nodes/fixtures.go +++ /dev/null @@ -1,207 +0,0 @@ -package nodes - -import ( - "fmt" - "net/http" - "strconv" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -func _rootURL(lbID int) string { - return "/loadbalancers/" + strconv.Itoa(lbID) + "/nodes" -} - -func _nodeURL(lbID, nodeID int) string { - return _rootURL(lbID) + "/" + strconv.Itoa(nodeID) -} - -func mockListResponse(t *testing.T, lbID int) { - th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "nodes": [ - { - "id": 410, - "address": "10.1.1.1", - "port": 80, - "condition": "ENABLED", - "status": "ONLINE", - "weight": 3, - "type": "PRIMARY" - }, - { - "id": 411, - "address": "10.1.1.2", - "port": 80, - "condition": "ENABLED", - "status": "ONLINE", - "weight": 8, - "type": "SECONDARY" - } - ] -} - `) - }) -} - -func mockCreateResponse(t *testing.T, lbID int) { - th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "nodes": [ - { - "address": "10.2.2.3", - "port": 80, - "condition": "ENABLED", - "type": "PRIMARY" - }, - { - "address": "10.2.2.4", - "port": 81, - "condition": "ENABLED", - "type": "SECONDARY" - } - ] -} - `) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusAccepted) - - fmt.Fprintf(w, ` -{ - "nodes": [ - { - "address": "10.2.2.3", - "id": 185, - "port": 80, - "status": "ONLINE", - "condition": "ENABLED", - "weight": 1, - "type": "PRIMARY" - }, - { - "address": "10.2.2.4", - "id": 186, - "port": 81, - "status": "ONLINE", - "condition": "ENABLED", - "weight": 1, - "type": "SECONDARY" - } - ] -} - `) - }) -} - -func mockBatchDeleteResponse(t *testing.T, lbID int, ids []int) { - th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - r.ParseForm() - - for k, v := range ids { - fids := r.Form["id"] - th.AssertEquals(t, strconv.Itoa(v), fids[k]) - } - - w.WriteHeader(http.StatusAccepted) - }) -} - -func mockDeleteResponse(t *testing.T, lbID, nodeID int) { - th.Mux.HandleFunc(_nodeURL(lbID, nodeID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.WriteHeader(http.StatusAccepted) - }) -} - -func mockGetResponse(t *testing.T, lbID, nodeID int) { - th.Mux.HandleFunc(_nodeURL(lbID, nodeID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "node": { - "id": 410, - "address": "10.1.1.1", - "port": 80, - "condition": "ENABLED", - "status": "ONLINE", - "weight": 12, - "type": "PRIMARY" - } -} - `) - }) -} - -func mockUpdateResponse(t *testing.T, lbID, nodeID int) { - th.Mux.HandleFunc(_nodeURL(lbID, nodeID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PUT") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "node": { - "condition": "DRAINING", - "weight": 10, - "type": "SECONDARY" - } -} - `) - - w.WriteHeader(http.StatusAccepted) - }) -} - -func mockListEventsResponse(t *testing.T, lbID int) { - th.Mux.HandleFunc(_rootURL(lbID)+"/events", func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "nodeServiceEvents": [ - { - "detailedMessage": "Node is ok", - "nodeId": 373, - "id": 7, - "type": "UPDATE_NODE", - "description": "Node '373' status changed to 'ONLINE' for load balancer '323'", - "category": "UPDATE", - "severity": "INFO", - "relativeUri": "/406271/loadbalancers/323/nodes/373/events", - "accountId": 406271, - "loadbalancerId": 323, - "title": "Node Status Updated", - "author": "Rackspace Cloud", - "created": "10-30-2012 10:18:23" - } - ] -} -`) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/nodes/requests.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/nodes/requests.go deleted file mode 100644 index 02af86b5c1..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/nodes/requests.go +++ /dev/null @@ -1,256 +0,0 @@ -package nodes - -import ( - "errors" - "fmt" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// List is the operation responsible for returning a paginated collection of -// load balancer nodes. It requires the node ID, its parent load balancer ID, -// and optional limit integer (passed in either as a pointer or a nil poitner). -func List(client *gophercloud.ServiceClient, loadBalancerID int, limit *int) pagination.Pager { - url := rootURL(client, loadBalancerID) - if limit != nil { - url += fmt.Sprintf("?limit=%d", limit) - } - - return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { - return NodePage{pagination.SinglePageBase(r)} - }) -} - -// CreateOptsBuilder is the interface responsible for generating the JSON -// for a Create operation. -type CreateOptsBuilder interface { - ToNodeCreateMap() (map[string]interface{}, error) -} - -// CreateOpts is a slice of CreateOpt structs, that allow the user to create -// multiple nodes in a single operation (one node per CreateOpt). -type CreateOpts []CreateOpt - -// CreateOpt represents the options to create a single node. -type CreateOpt struct { - // Required - the IP address or CIDR for this back-end node. It can either be - // a private IP (ServiceNet) or a public IP. - Address string - - // Optional - the port on which traffic is sent and received. - Port int - - // Optional - the condition of the node. See the consts in Results.go. - Condition Condition - - // Optional - the type of the node. See the consts in Results.go. - Type Type - - // Optional - a pointer to an integer between 0 and 100. - Weight *int -} - -func validateWeight(weight *int) error { - if weight != nil && (*weight > 100 || *weight < 0) { - return errors.New("Weight must be a valid int between 0 and 100") - } - return nil -} - -// ToNodeCreateMap converts a slice of options into a map that can be used for -// the JSON. -func (opts CreateOpts) ToNodeCreateMap() (map[string]interface{}, error) { - type nodeMap map[string]interface{} - nodes := []nodeMap{} - - for k, v := range opts { - if v.Address == "" { - return nodeMap{}, fmt.Errorf("ID is a required attribute, none provided for %d CreateOpt element", k) - } - if weightErr := validateWeight(v.Weight); weightErr != nil { - return nodeMap{}, weightErr - } - - node := make(map[string]interface{}) - node["address"] = v.Address - - if v.Port > 0 { - node["port"] = v.Port - } - if v.Condition != "" { - node["condition"] = v.Condition - } - if v.Type != "" { - node["type"] = v.Type - } - if v.Weight != nil { - node["weight"] = &v.Weight - } - - nodes = append(nodes, node) - } - - return nodeMap{"nodes": nodes}, nil -} - -// Create is the operation responsible for creating a new node on a load -// balancer. Since every load balancer exists in both ServiceNet and the public -// Internet, both private and public IP addresses can be used for nodes. -// -// If nodes need time to boot up services before they become operational, you -// can temporarily prevent traffic from being sent to that node by setting the -// Condition field to DRAINING. Health checks will still be performed; but once -// your node is ready, you can update its condition to ENABLED and have it -// handle traffic. -func Create(client *gophercloud.ServiceClient, loadBalancerID int, opts CreateOptsBuilder) CreateResult { - var res CreateResult - - reqBody, err := opts.ToNodeCreateMap() - if err != nil { - res.Err = err - return res - } - - resp, err := client.Post(rootURL(client, loadBalancerID), reqBody, &res.Body, nil) - - if err != nil { - res.Err = err - return res - } - - pr, err := pagination.PageResultFrom(resp) - if err != nil { - res.Err = err - return res - } - - return CreateResult{pagination.SinglePageBase(pr)} -} - -// BulkDelete is the operation responsible for batch deleting multiple nodes in -// a single operation. It accepts a slice of integer IDs and will remove them -// from the load balancer. The maximum limit is 10 node removals at once. -func BulkDelete(c *gophercloud.ServiceClient, loadBalancerID int, nodeIDs []int) DeleteResult { - var res DeleteResult - - if len(nodeIDs) > 10 || len(nodeIDs) == 0 { - res.Err = errors.New("You must provide a minimum of 1 and a maximum of 10 node IDs") - return res - } - - url := rootURL(c, loadBalancerID) - url += gophercloud.IDSliceToQueryString("id", nodeIDs) - - _, res.Err = c.Delete(url, nil) - return res -} - -// Get is the operation responsible for showing details for a single node. -func Get(c *gophercloud.ServiceClient, lbID, nodeID int) GetResult { - var res GetResult - _, res.Err = c.Get(resourceURL(c, lbID, nodeID), &res.Body, nil) - return res -} - -// UpdateOptsBuilder represents a type that can be converted into a JSON-like -// map structure. -type UpdateOptsBuilder interface { - ToNodeUpdateMap() (map[string]interface{}, error) -} - -// UpdateOpts represent the options for updating an existing node. -type UpdateOpts struct { - // Optional - the condition of the node. See the consts in Results.go. - Condition Condition - - // Optional - the type of the node. See the consts in Results.go. - Type Type - - // Optional - a pointer to an integer between 0 and 100. - Weight *int -} - -// ToNodeUpdateMap converts an options struct into a JSON-like map. -func (opts UpdateOpts) ToNodeUpdateMap() (map[string]interface{}, error) { - node := make(map[string]interface{}) - - if opts.Condition != "" { - node["condition"] = opts.Condition - } - if opts.Weight != nil { - if weightErr := validateWeight(opts.Weight); weightErr != nil { - return node, weightErr - } - node["weight"] = &opts.Weight - } - if opts.Type != "" { - node["type"] = opts.Type - } - - return map[string]interface{}{"node": node}, nil -} - -// Update is the operation responsible for updating an existing node. A node's -// IP, port, and status are immutable attributes and cannot be modified. -func Update(c *gophercloud.ServiceClient, lbID, nodeID int, opts UpdateOptsBuilder) UpdateResult { - var res UpdateResult - - reqBody, err := opts.ToNodeUpdateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = c.Put(resourceURL(c, lbID, nodeID), reqBody, nil, nil) - return res -} - -// Delete is the operation responsible for permanently deleting a node. -func Delete(c *gophercloud.ServiceClient, lbID, nodeID int) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(resourceURL(c, lbID, nodeID), nil) - return res -} - -// ListEventsOptsBuilder allows extensions to add additional parameters to the -// List request. -type ListEventsOptsBuilder interface { - ToEventsListQuery() (string, error) -} - -// ListEventsOpts allows the filtering and sorting of paginated collections through -// the API. -type ListEventsOpts struct { - Marker string `q:"marker"` - Limit int `q:"limit"` -} - -// ToEventsListQuery formats a ListOpts into a query string. -func (opts ListEventsOpts) ToEventsListQuery() (string, error) { - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return "", err - } - return q.String(), nil -} - -// ListEvents is the operation responsible for listing all the events -// associated with the activity between the node and the load balancer. The -// events report errors found with the node. The detailedMessage provides the -// detailed reason for the error. -func ListEvents(client *gophercloud.ServiceClient, loadBalancerID int, opts ListEventsOptsBuilder) pagination.Pager { - url := eventsURL(client, loadBalancerID) - - if opts != nil { - query, err := opts.ToEventsListQuery() - if err != nil { - return pagination.Pager{Err: err} - } - url += query - } - - return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { - return NodeEventPage{pagination.SinglePageBase(r)} - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/nodes/results.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/nodes/results.go deleted file mode 100644 index 916485f2fc..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/nodes/results.go +++ /dev/null @@ -1,210 +0,0 @@ -package nodes - -import ( - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// Node represents a back-end device, usually a virtual machine, that can -// handle traffic. It is assigned traffic based on its parent load balancer. -type Node struct { - // The IP address or CIDR for this back-end node. - Address string - - // The unique ID for this node. - ID int - - // The port on which traffic is sent and received. - Port int - - // The node's status. - Status Status - - // The node's condition. - Condition Condition - - // The priority at which this node will receive traffic if a weighted - // algorithm is used by its parent load balancer. Ranges from 1 to 100. - Weight int - - // Type of node. - Type Type -} - -// Type indicates whether the node is of a PRIMARY or SECONDARY nature. -type Type string - -const ( - // PRIMARY nodes are in the normal rotation to receive traffic from the load - // balancer. - PRIMARY Type = "PRIMARY" - - // SECONDARY nodes are only in the rotation to receive traffic from the load - // balancer when all the primary nodes fail. This provides a failover feature - // that automatically routes traffic to the secondary node in the event that - // the primary node is disabled or in a failing state. Note that active - // health monitoring must be enabled on the load balancer to enable the - // failover feature to the secondary node. - SECONDARY Type = "SECONDARY" -) - -// Condition represents the condition of a node. -type Condition string - -const ( - // ENABLED indicates that the node is permitted to accept new connections. - ENABLED Condition = "ENABLED" - - // DISABLED indicates that the node is not permitted to accept any new - // connections regardless of session persistence configuration. Existing - // connections are forcibly terminated. - DISABLED Condition = "DISABLED" - - // DRAINING indicates that the node is allowed to service existing - // established connections and connections that are being directed to it as a - // result of the session persistence configuration. - DRAINING Condition = "DRAINING" -) - -// Status indicates whether the node can accept service traffic. If a node is -// not listening on its port or does not meet the conditions of the defined -// active health check for the load balancer, then the load balancer does not -// forward connections, and its status is listed as OFFLINE. -type Status string - -const ( - // ONLINE indicates that the node is healthy and capable of receiving traffic - // from the load balancer. - ONLINE Status = "ONLINE" - - // OFFLINE indicates that the node is not in a position to receive service - // traffic. It is usually switched into this state when a health check is not - // satisfied with the node's response time. - OFFLINE Status = "OFFLINE" -) - -// NodePage is the page returned by a pager when traversing over a collection -// of nodes. -type NodePage struct { - pagination.SinglePageBase -} - -// IsEmpty checks whether a NodePage struct is empty. -func (p NodePage) IsEmpty() (bool, error) { - is, err := ExtractNodes(p) - if err != nil { - return true, nil - } - return len(is) == 0, nil -} - -func commonExtractNodes(body interface{}) ([]Node, error) { - var resp struct { - Nodes []Node `mapstructure:"nodes" json:"nodes"` - } - - err := mapstructure.Decode(body, &resp) - - return resp.Nodes, err -} - -// ExtractNodes accepts a Page struct, specifically a NodePage struct, and -// extracts the elements into a slice of Node structs. In other words, a -// generic collection is mapped into a relevant slice. -func ExtractNodes(page pagination.Page) ([]Node, error) { - return commonExtractNodes(page.(NodePage).Body) -} - -// CreateResult represents the result of a create operation. Since multiple -// nodes can be added in one operation, this result represents multiple nodes -// and should be treated as a typical pagination Page. Use its ExtractNodes -// method to get out a slice of Node structs. -type CreateResult struct { - pagination.SinglePageBase -} - -// ExtractNodes extracts a slice of Node structs from a CreateResult. -func (res CreateResult) ExtractNodes() ([]Node, error) { - return commonExtractNodes(res.Body) -} - -// DeleteResult represents the result of a delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} - -type commonResult struct { - gophercloud.Result -} - -// GetResult represents the result of a get operation. -type GetResult struct { - commonResult -} - -// UpdateResult represents the result of an update operation. -type UpdateResult struct { - gophercloud.ErrResult -} - -func (r commonResult) Extract() (*Node, error) { - if r.Err != nil { - return nil, r.Err - } - - var response struct { - Node Node `mapstructure:"node"` - } - - err := mapstructure.Decode(r.Body, &response) - - return &response.Node, err -} - -// NodeEvent represents a service event that occurred between a node and a -// load balancer. -type NodeEvent struct { - ID int - DetailedMessage string - NodeID int - Type string - Description string - Category string - Severity string - RelativeURI string - AccountID int - LoadBalancerID int - Title string - Author string - Created string -} - -// NodeEventPage is a concrete type which embeds the common SinglePageBase -// struct, and is used when traversing node event collections. -type NodeEventPage struct { - pagination.SinglePageBase -} - -// IsEmpty is a concrete function which indicates whether an NodeEventPage is -// empty or not. -func (r NodeEventPage) IsEmpty() (bool, error) { - is, err := ExtractNodeEvents(r) - if err != nil { - return true, err - } - return len(is) == 0, nil -} - -// ExtractNodeEvents accepts a Page struct, specifically a NodeEventPage -// struct, and extracts the elements into a slice of NodeEvent structs. In -// other words, the collection is mapped into a relevant slice. -func ExtractNodeEvents(page pagination.Page) ([]NodeEvent, error) { - var resp struct { - Events []NodeEvent `mapstructure:"nodeServiceEvents" json:"nodeServiceEvents"` - } - - err := mapstructure.Decode(page.(NodeEventPage).Body, &resp) - - return resp.Events, err -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/nodes/urls.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/nodes/urls.go deleted file mode 100644 index 2cefee2644..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/nodes/urls.go +++ /dev/null @@ -1,25 +0,0 @@ -package nodes - -import ( - "strconv" - - "github.com/rackspace/gophercloud" -) - -const ( - lbPath = "loadbalancers" - nodePath = "nodes" - eventPath = "events" -) - -func resourceURL(c *gophercloud.ServiceClient, lbID, nodeID int) string { - return c.ServiceURL(lbPath, strconv.Itoa(lbID), nodePath, strconv.Itoa(nodeID)) -} - -func rootURL(c *gophercloud.ServiceClient, lbID int) string { - return c.ServiceURL(lbPath, strconv.Itoa(lbID), nodePath) -} - -func eventsURL(c *gophercloud.ServiceClient, lbID int) string { - return c.ServiceURL(lbPath, strconv.Itoa(lbID), nodePath, eventPath) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/sessions/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/sessions/doc.go deleted file mode 100644 index dcec0a87e2..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/sessions/doc.go +++ /dev/null @@ -1,30 +0,0 @@ -/* -Package sessions provides information and interaction with the Session -Persistence feature of the Rackspace Cloud Load Balancer service. - -Session persistence is a feature of the load balancing service that forces -multiple requests from clients (of the same protocol) to be directed to the -same node. This is common with many web applications that do not inherently -share application state between back-end servers. - -There are two modes to choose from: HTTP_COOKIE and SOURCE_IP. You can only set -one of the session persistence modes on a load balancer, and it can only -support one protocol. If you set HTTP_COOKIE mode for an HTTP load balancer, it -supports session persistence for HTTP requests only. Likewise, if you set -SOURCE_IP mode for an HTTPS load balancer, it supports session persistence for -only HTTPS requests. - -To support session persistence for both HTTP and HTTPS requests concurrently, -choose one of the following options: - -- Use two load balancers, one configured for session persistence for HTTP -requests and the other configured for session persistence for HTTPS requests. -That way, the load balancers support session persistence for both HTTP and -HTTPS requests concurrently, with each load balancer supporting one of the -protocols. - -- Use one load balancer, configure it for session persistence for HTTP requests, -and then enable SSL termination for that load balancer. The load balancer -supports session persistence for both HTTP and HTTPS requests concurrently. -*/ -package sessions diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/sessions/fixtures.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/sessions/fixtures.go deleted file mode 100644 index 9596819d16..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/sessions/fixtures.go +++ /dev/null @@ -1,58 +0,0 @@ -package sessions - -import ( - "fmt" - "net/http" - "strconv" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -func _rootURL(id int) string { - return "/loadbalancers/" + strconv.Itoa(id) + "/sessionpersistence" -} - -func mockGetResponse(t *testing.T, lbID int) { - th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "sessionPersistence": { - "persistenceType": "HTTP_COOKIE" - } -} -`) - }) -} - -func mockEnableResponse(t *testing.T, lbID int) { - th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PUT") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "sessionPersistence": { - "persistenceType": "HTTP_COOKIE" - } -} - `) - - w.WriteHeader(http.StatusAccepted) - }) -} - -func mockDisableResponse(t *testing.T, lbID int) { - th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.WriteHeader(http.StatusAccepted) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/sessions/requests.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/sessions/requests.go deleted file mode 100644 index a93d766cd9..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/sessions/requests.go +++ /dev/null @@ -1,63 +0,0 @@ -package sessions - -import ( - "errors" - - "github.com/rackspace/gophercloud" -) - -// CreateOptsBuilder is the interface options structs have to satisfy in order -// to be used in the main Create operation in this package. -type CreateOptsBuilder interface { - ToSPCreateMap() (map[string]interface{}, error) -} - -// CreateOpts is the common options struct used in this package's Create -// operation. -type CreateOpts struct { - // Required - can either be HTTPCOOKIE or SOURCEIP - Type Type -} - -// ToSPCreateMap casts a CreateOpts struct to a map. -func (opts CreateOpts) ToSPCreateMap() (map[string]interface{}, error) { - sp := make(map[string]interface{}) - - if opts.Type == "" { - return sp, errors.New("Type is a required field") - } - - sp["persistenceType"] = opts.Type - return map[string]interface{}{"sessionPersistence": sp}, nil -} - -// Enable is the operation responsible for enabling session persistence for a -// particular load balancer. -func Enable(c *gophercloud.ServiceClient, lbID int, opts CreateOptsBuilder) EnableResult { - var res EnableResult - - reqBody, err := opts.ToSPCreateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = c.Put(rootURL(c, lbID), reqBody, &res.Body, nil) - return res -} - -// Get is the operation responsible for showing details of the session -// persistence configuration for a particular load balancer. -func Get(c *gophercloud.ServiceClient, lbID int) GetResult { - var res GetResult - _, res.Err = c.Get(rootURL(c, lbID), &res.Body, nil) - return res -} - -// Disable is the operation responsible for disabling session persistence for a -// particular load balancer. -func Disable(c *gophercloud.ServiceClient, lbID int) DisableResult { - var res DisableResult - _, res.Err = c.Delete(rootURL(c, lbID), nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/sessions/results.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/sessions/results.go deleted file mode 100644 index fe90e722cb..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/sessions/results.go +++ /dev/null @@ -1,58 +0,0 @@ -package sessions - -import ( - "github.com/mitchellh/mapstructure" - - "github.com/rackspace/gophercloud" -) - -// Type represents the type of session persistence being used. -type Type string - -const ( - // HTTPCOOKIE is a session persistence mechanism that inserts an HTTP cookie - // and is used to determine the destination back-end node. This is supported - // for HTTP load balancing only. - HTTPCOOKIE Type = "HTTP_COOKIE" - - // SOURCEIP is a session persistence mechanism that keeps track of the source - // IP address that is mapped and is able to determine the destination - // back-end node. This is supported for HTTPS pass-through and non-HTTP load - // balancing only. - SOURCEIP Type = "SOURCE_IP" -) - -// SessionPersistence indicates how a load balancer is using session persistence -type SessionPersistence struct { - Type Type `mapstructure:"persistenceType"` -} - -// EnableResult represents the result of an enable operation. -type EnableResult struct { - gophercloud.ErrResult -} - -// DisableResult represents the result of a disable operation. -type DisableResult struct { - gophercloud.ErrResult -} - -// GetResult represents the result of a get operation. -type GetResult struct { - gophercloud.Result -} - -// Extract interprets a GetResult as an SP, if possible. -func (r GetResult) Extract() (*SessionPersistence, error) { - if r.Err != nil { - return nil, r.Err - } - - var response struct { - SP SessionPersistence `mapstructure:"sessionPersistence"` - } - - err := mapstructure.Decode(r.Body, &response) - - return &response.SP, err -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/sessions/urls.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/sessions/urls.go deleted file mode 100644 index c4a896d905..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/sessions/urls.go +++ /dev/null @@ -1,16 +0,0 @@ -package sessions - -import ( - "strconv" - - "github.com/rackspace/gophercloud" -) - -const ( - path = "loadbalancers" - spPath = "sessionpersistence" -) - -func rootURL(c *gophercloud.ServiceClient, id int) string { - return c.ServiceURL(path, strconv.Itoa(id), spPath) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/ssl/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/ssl/doc.go deleted file mode 100644 index 6a2c174ae9..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/ssl/doc.go +++ /dev/null @@ -1,22 +0,0 @@ -/* -Package ssl provides information and interaction with the SSL Termination -feature of the Rackspace Cloud Load Balancer service. - -You may only enable and configure SSL termination on load balancers with -non-secure protocols, such as HTTP, but not HTTPS. - -SSL-terminated load balancers decrypt the traffic at the traffic manager and -pass unencrypted traffic to the back-end node. Because of this, the customer's -back-end nodes don't know what protocol the client requested. For this reason, -the X-Forwarded-Proto (XFP) header has been added for identifying the -originating protocol of an HTTP request as "http" or "https" depending on what -protocol the client requested. - -Not every service returns certificates in the proper order. Please verify that -your chain of certificates matches that of walking up the chain from the domain -to the CA root. - -If used for HTTP to HTTPS redirection, the LoadBalancer's securePort attribute -must be set to 443, and its secureTrafficOnly attribute must be true. -*/ -package ssl diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/ssl/fixtures.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/ssl/fixtures.go deleted file mode 100644 index 1d40100125..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/ssl/fixtures.go +++ /dev/null @@ -1,195 +0,0 @@ -package ssl - -import ( - "fmt" - "net/http" - "strconv" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -func _rootURL(id int) string { - return "/loadbalancers/" + strconv.Itoa(id) + "/ssltermination" -} - -func _certURL(id, certID int) string { - url := _rootURL(id) + "/certificatemappings" - if certID > 0 { - url += "/" + strconv.Itoa(certID) - } - return url -} - -func mockGetResponse(t *testing.T, lbID int) { - th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "sslTermination": { - "certificate": "-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIGATTEAjK3MA0GCSqGSIb3DQEBBQUAMIGDMRkwFwYDVQQD\nExBUZXN0IENBIFNUdWIgS2V5MRcwFQYDVQQLEw5QbGF0Zm9ybSBMYmFhczEaMBgG\nA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFDASBgNVBAcTC1NhbiBBbnRvbmlvMQ4w\nDAYDVQQIEwVUZXhhczELMAkGA1UEBhMCVVMwHhcNMTIwMTA5MTk0NjQ1WhcNMTQw\nMTA4MTk0NjQ1WjCBgjELMAkGA1UEBhMCVVMxDjAMBgNVBAgTBVRleGFzMRQwEgYD\nVQQHEwtTYW4gQW50b25pbzEaMBgGA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFzAV\nBgNVBAsTDlBsYXRmb3JtIExiYWFzMRgwFgYDVQQDEw9UZXN0IENsaWVudCBLZXkw\nggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDAi51IylFnHtNLT8C0NVfc\nOBfAsP2D5es1qhrOWHCGlgAuDMksBsCc7FPo5PSBOmQ+6z8HtCFbrLoC5/Zx0F5b\nfVegjA+xKjI2HGASsYHHM0BFEH2UjUcJrWiMWtxQuW6Phbqulo7JwjmygMEmIkeK\nf+FtkE9mrq+E8K40/thrjxl3/ZcJD1+3dcp+ZuzVJ2t1E4iGKCx79IZFsysKiuf+\n+E0i6iGvvI6UcbcZxVxQj2TplJkFuoX5kDgClIX9Dr9y6aJ4SCh+GRhvHl+DTaz0\nnCvghachHZtIeztRDqxWApjOOzs93dSelrviMXDr8fqyEAGg7YIhgui0aZBsWCen\nAgMBAAGjgdUwgdIwgbAGA1UdIwSBqDCBpYAUNpx1Pc6cGA7KqEwHMmHBTZMA7lSh\ngYmkgYYwgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVU4IBATAd\nBgNVHQ4EFgQULueOfsjZZOHwJHZwBy6u0swnpccwDQYJKoZIhvcNAQEFBQADggEB\nAFNuqSVUaotUJoWDv4z7Kbi6JFpTjDht5ORw4BdVYlRD4h9DACAFzPrPV2ym/Osp\nhNMdZq6msZku7MdOSQVhdeGWrSNk3M8O9Hg7cVzPNXOF3iNoo3irQ5tURut44xs4\nWw5YWQqS9WyUY5snD8tm7Y1rQTPfhg+678xIq/zWCv/u+FSnfVv1nlhLVQkEeG/Y\ngh1uMaTIpUKTGEjIAGtpGP7wwIcXptR/HyfzhTUSTaWc1Ef7zoKT9LL5z3IV1hC2\njVWz+RwYs98LjMuksJFoHqRfWyYhCIym0jb6GTwaEmpxAjc+d7OLNQdnoEGoUYGP\nYjtfkRYg265ESMA+Kww4Xy8=\n-----END CERTIFICATE-----\n", - "enabled": true, - "secureTrafficOnly": false, - "intermediateCertificate": "-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzEZMBcGA1UEAxMQVGVz\ndCBDQSBTVHViIEtleTEXMBUGA1UECxMOUGxhdGZvcm0gTGJhYXMxGjAYBgNVBAoT\nEVJhY2tzcGFjZSBIb3N0aW5nMRQwEgYDVQQHEwtTYW4gQW50b25pbzEOMAwGA1UE\nCBMFVGV4YXMxCzAJBgNVBAYTAlVTMB4XDTEyMDEwOTE5NDU0OVoXDTE0MDEwODE5\nNDU0OVowgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVUzCCASIw\nDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANNh55lwTVwQvNoEZjq1zGdYz9jA\nXXdjizn8AJhjHLOAallfPtvCfTEgKanhdoyz5FnhQE8HbDAop/KNS1lN2UMvdl5f\nZNLTSjJrNtedqxQwxN/i3bpyBxNVejUH2NjV1mmyj+5CJYwCzWalvI/gLPq/A3as\nO2EQqtf3U8unRgn0zXLRdYxV9MrUzNAmdipPNvNrsVdrCgA42rgF/8KsyRVQfJCX\nfN7PGCfrsC3YaUvhymraWxNnXIzMYTNa9wEeBZLUw8SlEtpa1Zsvui+TPXu3USNZ\nVnWH8Lb6ENlnoX0VBwo62fjOG3JzhNKoJawi3bRqyDdINOvafr7iPrrs/T8CAwEA\nAaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUNpx1Pc6cGA7KqEwHMmHB\nTZMA7lQwDQYJKoZIhvcNAQEFBQADggEBAMoRgH3iTG3t317viLKoY+lNMHUgHuR7\nb3mn9MidJKyYVewe6hCDIN6WY4fUojmMW9wFJWJIo0hRMNHL3n3tq8HP2j20Mxy8\nacPdfGZJa+jiBw72CrIGdobKaFduIlIEDBA1pNdZIJ+EulrtqrMesnIt92WaypIS\n8JycbIgDMCiyC0ENHEk8UWlC6429c7OZAsplMTbHME/1R4btxjkdfrYZJjdJ2yL2\n8cjZDUDMCPTdW/ycP07Gkq30RB5tACB5aZdaCn2YaKC8FsEdhff4X7xEOfOEHWEq\nSRxADDj8Lx1MT6QpR07hCiDyHfTCtbqzI0iGjX63Oh7xXSa0f+JVTa8=\n-----END CERTIFICATE-----\n", - "securePort": 443 - } -} -`) - }) -} - -func mockUpdateResponse(t *testing.T, lbID int) { - th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PUT") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "sslTermination": { - "enabled": true, - "securePort": 443, - "secureTrafficOnly": false, - "privateKey": "foo", - "certificate": "-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIGATTEAjK3MA0GCSqGSIb3DQEBBQUAMIGDMRkwFwYDVQQD\nExBUZXN0IENBIFNUdWIgS2V5MRcwFQYDVQQLEw5QbGF0Zm9ybSBMYmFhczEaMBgG\nA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFDASBgNVBAcTC1NhbiBBbnRvbmlvMQ4w\nDAYDVQQIEwVUZXhhczELMAkGA1UEBhMCVVMwHhcNMTIwMTA5MTk0NjQ1WhcNMTQw\nMTA4MTk0NjQ1WjCBgjELMAkGA1UEBhMCVVMxDjAMBgNVBAgTBVRleGFzMRQwEgYD\nVQQHEwtTYW4gQW50b25pbzEaMBgGA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFzAV\nBgNVBAsTDlBsYXRmb3JtIExiYWFzMRgwFgYDVQQDEw9UZXN0IENsaWVudCBLZXkw\nggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDAi51IylFnHtNLT8C0NVfc\nOBfAsP2D5es1qhrOWHCGlgAuDMksBsCc7FPo5PSBOmQ+6z8HtCFbrLoC5/Zx0F5b\nfVegjA+xKjI2HGASsYHHM0BFEH2UjUcJrWiMWtxQuW6Phbqulo7JwjmygMEmIkeK\nf+FtkE9mrq+E8K40/thrjxl3/ZcJD1+3dcp+ZuzVJ2t1E4iGKCx79IZFsysKiuf+\n+E0i6iGvvI6UcbcZxVxQj2TplJkFuoX5kDgClIX9Dr9y6aJ4SCh+GRhvHl+DTaz0\nnCvghachHZtIeztRDqxWApjOOzs93dSelrviMXDr8fqyEAGg7YIhgui0aZBsWCen\nAgMBAAGjgdUwgdIwgbAGA1UdIwSBqDCBpYAUNpx1Pc6cGA7KqEwHMmHBTZMA7lSh\ngYmkgYYwgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVU4IBATAd\nBgNVHQ4EFgQULueOfsjZZOHwJHZwBy6u0swnpccwDQYJKoZIhvcNAQEFBQADggEB\nAFNuqSVUaotUJoWDv4z7Kbi6JFpTjDht5ORw4BdVYlRD4h9DACAFzPrPV2ym/Osp\nhNMdZq6msZku7MdOSQVhdeGWrSNk3M8O9Hg7cVzPNXOF3iNoo3irQ5tURut44xs4\nWw5YWQqS9WyUY5snD8tm7Y1rQTPfhg+678xIq/zWCv/u+FSnfVv1nlhLVQkEeG/Y\ngh1uMaTIpUKTGEjIAGtpGP7wwIcXptR/HyfzhTUSTaWc1Ef7zoKT9LL5z3IV1hC2\njVWz+RwYs98LjMuksJFoHqRfWyYhCIym0jb6GTwaEmpxAjc+d7OLNQdnoEGoUYGP\nYjtfkRYg265ESMA+Kww4Xy8=\n-----END CERTIFICATE-----\n", - "intermediateCertificate": "-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzEZMBcGA1UEAxMQVGVz\ndCBDQSBTVHViIEtleTEXMBUGA1UECxMOUGxhdGZvcm0gTGJhYXMxGjAYBgNVBAoT\nEVJhY2tzcGFjZSBIb3N0aW5nMRQwEgYDVQQHEwtTYW4gQW50b25pbzEOMAwGA1UE\nCBMFVGV4YXMxCzAJBgNVBAYTAlVTMB4XDTEyMDEwOTE5NDU0OVoXDTE0MDEwODE5\nNDU0OVowgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVUzCCASIw\nDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANNh55lwTVwQvNoEZjq1zGdYz9jA\nXXdjizn8AJhjHLOAallfPtvCfTEgKanhdoyz5FnhQE8HbDAop/KNS1lN2UMvdl5f\nZNLTSjJrNtedqxQwxN/i3bpyBxNVejUH2NjV1mmyj+5CJYwCzWalvI/gLPq/A3as\nO2EQqtf3U8unRgn0zXLRdYxV9MrUzNAmdipPNvNrsVdrCgA42rgF/8KsyRVQfJCX\nfN7PGCfrsC3YaUvhymraWxNnXIzMYTNa9wEeBZLUw8SlEtpa1Zsvui+TPXu3USNZ\nVnWH8Lb6ENlnoX0VBwo62fjOG3JzhNKoJawi3bRqyDdINOvafr7iPrrs/T8CAwEA\nAaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUNpx1Pc6cGA7KqEwHMmHB\nTZMA7lQwDQYJKoZIhvcNAQEFBQADggEBAMoRgH3iTG3t317viLKoY+lNMHUgHuR7\nb3mn9MidJKyYVewe6hCDIN6WY4fUojmMW9wFJWJIo0hRMNHL3n3tq8HP2j20Mxy8\nacPdfGZJa+jiBw72CrIGdobKaFduIlIEDBA1pNdZIJ+EulrtqrMesnIt92WaypIS\n8JycbIgDMCiyC0ENHEk8UWlC6429c7OZAsplMTbHME/1R4btxjkdfrYZJjdJ2yL2\n8cjZDUDMCPTdW/ycP07Gkq30RB5tACB5aZdaCn2YaKC8FsEdhff4X7xEOfOEHWEq\nSRxADDj8Lx1MT6QpR07hCiDyHfTCtbqzI0iGjX63Oh7xXSa0f+JVTa8=\n-----END CERTIFICATE-----\n" - } -} - `) - - w.WriteHeader(http.StatusOK) - }) -} - -func mockDeleteResponse(t *testing.T, lbID int) { - th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.WriteHeader(http.StatusOK) - }) -} - -func mockListCertsResponse(t *testing.T, lbID int) { - th.Mux.HandleFunc(_certURL(lbID, 0), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "certificateMappings": [ - { - "certificateMapping": { - "id": 123, - "hostName": "rackspace.com" - } - }, - { - "certificateMapping": { - "id": 124, - "hostName": "*.rackspace.com" - } - } - ] -} -`) - }) -} - -func mockAddCertResponse(t *testing.T, lbID int) { - th.Mux.HandleFunc(_certURL(lbID, 0), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "certificateMapping": { - "hostName": "rackspace.com", - "privateKey":"-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEAwIudSMpRZx7TS0/AtDVX3DgXwLD9g+XrNaoazlhwhpYALgzJ\nLAbAnOxT6OT0gTpkPus/B7QhW6y6Auf2cdBeW31XoIwPsSoyNhxgErGBxzNARRB9\nlI1HCa1ojFrcULluj4W6rpaOycI5soDBJiJHin/hbZBPZq6vhPCuNP7Ya48Zd/2X\nCQ9ft3XKfmbs1SdrdROIhigse/SGRbMrCorn/vhNIuohr7yOlHG3GcVcUI9k6ZSZ\nBbqF+ZA4ApSF/Q6/cumieEgofhkYbx5fg02s9Jwr4IWnIR2bSHs7UQ6sVgKYzjs7\nPd3Unpa74jFw6/H6shABoO2CIYLotGmQbFgnpwIDAQABAoIBAQCBCQ+PCIclJHNV\ntUzfeCA5ZR4F9JbxHdRTUnxEbOB8UWotckQfTScoAvj4yvdQ42DrCZxj/UOdvFOs\nPufZvlp91bIz1alugWjE+p8n5+2hIaegoTyHoWZKBfxak0myj5KYfHZvKlbmv1ML\nXV4TwEVRfAIG+v87QTY/UUxuF5vR+BpKIbgUJLfPUFFvJUdl84qsJ44pToxaYUd/\nh5YAGC00U4ay1KVSAUnTkkPNZ0lPG/rWU6w6WcTvNRLMd8DzFLTKLOgQfHhbExAF\n+sXPWjWSzbBRP1O7fHqq96QQh4VFiY/7w9W+sDKQyV6Ul17OSXs6aZ4f+lq4rJTI\n1FG96YiBAoGBAO1tiH0h1oWDBYfJB3KJJ6CQQsDGwtHo/DEgznFVP4XwEVbZ98Ha\nBfBCn3sAybbaikyCV1Hwj7kfHMZPDHbrcUSFX7quu/2zPK+wO3lZKXSyu4YsguSa\nRedInN33PpdnlPhLyQdWSuD5sVHJDF6xn22vlyxeILH3ooLg2WOFMPmVAoGBAM+b\nUG/a7iyfpAQKYyuFAsXz6SeFaDY+ZYeX45L112H8Pu+Ie/qzon+bzLB9FIH8GP6+\nQpQgmm/p37U2gD1zChUv7iW6OfQBKk9rWvMpfRF6d7YHquElejhizfTZ+ntBV/VY\ndOYEczxhrdW7keLpatYaaWUy/VboRZmlz/9JGqVLAoGAHfqNmFc0cgk4IowEj7a3\ntTNh6ltub/i+FynwRykfazcDyXaeLPDtfQe8gVh5H8h6W+y9P9BjJVnDVVrX1RAn\nbiJ1EupLPF5sVDapW8ohTOXgfbGTGXBNUUW+4Nv+IDno+mz/RhjkPYHpnM0I7c/5\ntGzOZsC/2hjNgT8I0+MWav0CgYEAuULdJeQVlKalI6HtW2Gn1uRRVJ49H+LQkY6e\nW3+cw2jo9LI0CMWSphNvNrN3wIMp/vHj0fHCP0pSApDvIWbuQXfzKaGko7UCf7rK\nf6GvZRCHkV4IREBAb97j8bMvThxClMNqFfU0rFZyXP+0MOyhFQyertswrgQ6T+Fi\n2mnvKD8CgYAmJHP3NTDRMoMRyAzonJ6nEaGUbAgNmivTaUWMe0+leCvAdwD89gzC\nTKbm3eDUg/6Va3X6ANh3wsfIOe4RXXxcbcFDk9R4zO2M5gfLSjYm5Q87EBZ2hrdj\nM2gLI7dt6thx0J8lR8xRHBEMrVBdgwp0g1gQzo5dAV88/kpkZVps8Q==\n-----END RSA PRIVATE KEY-----\n", - "certificate":"-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIGATTEAjK3MA0GCSqGSIb3DQEBBQUAMIGDMRkwFwYDVQQD\nExBUZXN0IENBIFNUdWIgS2V5MRcwFQYDVQQLEw5QbGF0Zm9ybSBMYmFhczEaMBgG\nA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFDASBgNVBAcTC1NhbiBBbnRvbmlvMQ4w\nDAYDVQQIEwVUZXhhczELMAkGA1UEBhMCVVMwHhcNMTIwMTA5MTk0NjQ1WhcNMTQw\nMTA4MTk0NjQ1WjCBgjELMAkGA1UEBhMCVVMxDjAMBgNVBAgTBVRleGFzMRQwEgYD\nVQQHEwtTYW4gQW50b25pbzEaMBgGA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFzAV\nBgNVBAsTDlBsYXRmb3JtIExiYWFzMRgwFgYDVQQDEw9UZXN0IENsaWVudCBLZXkw\nggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDAi51IylFnHtNLT8C0NVfc\nOBfAsP2D5es1qhrOWHCGlgAuDMksBsCc7FPo5PSBOmQ+6z8HtCFbrLoC5/Zx0F5b\nfVegjA+xKjI2HGASsYHHM0BFEH2UjUcJrWiMWtxQuW6Phbqulo7JwjmygMEmIkeK\nf+FtkE9mrq+E8K40/thrjxl3/ZcJD1+3dcp+ZuzVJ2t1E4iGKCx79IZFsysKiuf+\n+E0i6iGvvI6UcbcZxVxQj2TplJkFuoX5kDgClIX9Dr9y6aJ4SCh+GRhvHl+DTaz0\nnCvghachHZtIeztRDqxWApjOOzs93dSelrviMXDr8fqyEAGg7YIhgui0aZBsWCen\nAgMBAAGjgdUwgdIwgbAGA1UdIwSBqDCBpYAUNpx1Pc6cGA7KqEwHMmHBTZMA7lSh\ngYmkgYYwgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVU4IBATAd\nBgNVHQ4EFgQULueOfsjZZOHwJHZwBy6u0swnpccwDQYJKoZIhvcNAQEFBQADggEB\nAFNuqSVUaotUJoWDv4z7Kbi6JFpTjDht5ORw4BdVYlRD4h9DACAFzPrPV2ym/Osp\nhNMdZq6msZku7MdOSQVhdeGWrSNk3M8O9Hg7cVzPNXOF3iNoo3irQ5tURut44xs4\nWw5YWQqS9WyUY5snD8tm7Y1rQTPfhg+678xIq/zWCv/u+FSnfVv1nlhLVQkEeG/Y\ngh1uMaTIpUKTGEjIAGtpGP7wwIcXptR/HyfzhTUSTaWc1Ef7zoKT9LL5z3IV1hC2\njVWz+RwYs98LjMuksJFoHqRfWyYhCIym0jb6GTwaEmpxAjc+d7OLNQdnoEGoUYGP\nYjtfkRYg265ESMA+Kww4Xy8=\n-----END CERTIFICATE-----\n", - "intermediateCertificate":"-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzEZMBcGA1UEAxMQVGVz\ndCBDQSBTVHViIEtleTEXMBUGA1UECxMOUGxhdGZvcm0gTGJhYXMxGjAYBgNVBAoT\nEVJhY2tzcGFjZSBIb3N0aW5nMRQwEgYDVQQHEwtTYW4gQW50b25pbzEOMAwGA1UE\nCBMFVGV4YXMxCzAJBgNVBAYTAlVTMB4XDTEyMDEwOTE5NDU0OVoXDTE0MDEwODE5\nNDU0OVowgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVUzCCASIw\nDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANNh55lwTVwQvNoEZjq1zGdYz9jA\nXXdjizn8AJhjHLOAallfPtvCfTEgKanhdoyz5FnhQE8HbDAop/KNS1lN2UMvdl5f\nZNLTSjJrNtedqxQwxN/i3bpyBxNVejUH2NjV1mmyj+5CJYwCzWalvI/gLPq/A3as\nO2EQqtf3U8unRgn0zXLRdYxV9MrUzNAmdipPNvNrsVdrCgA42rgF/8KsyRVQfJCX\nfN7PGCfrsC3YaUvhymraWxNnXIzMYTNa9wEeBZLUw8SlEtpa1Zsvui+TPXu3USNZ\nVnWH8Lb6ENlnoX0VBwo62fjOG3JzhNKoJawi3bRqyDdINOvafr7iPrrs/T8CAwEA\nAaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUNpx1Pc6cGA7KqEwHMmHB\nTZMA7lQwDQYJKoZIhvcNAQEFBQADggEBAMoRgH3iTG3t317viLKoY+lNMHUgHuR7\nb3mn9MidJKyYVewe6hCDIN6WY4fUojmMW9wFJWJIo0hRMNHL3n3tq8HP2j20Mxy8\nacPdfGZJa+jiBw72CrIGdobKaFduIlIEDBA1pNdZIJ+EulrtqrMesnIt92WaypIS\n8JycbIgDMCiyC0ENHEk8UWlC6429c7OZAsplMTbHME/1R4btxjkdfrYZJjdJ2yL2\n8cjZDUDMCPTdW/ycP07Gkq30RB5tACB5aZdaCn2YaKC8FsEdhff4X7xEOfOEHWEq\nSRxADDj8Lx1MT6QpR07hCiDyHfTCtbqzI0iGjX63Oh7xXSa0f+JVTa8=\n-----END CERTIFICATE-----\n" - } -} - `) - - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "certificateMapping": { - "id": 123, - "hostName": "rackspace.com", - "certificate":"-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIGATTEAjK3MA0GCSqGSIb3DQEBBQUAMIGDMRkwFwYDVQQD\nExBUZXN0IENBIFNUdWIgS2V5MRcwFQYDVQQLEw5QbGF0Zm9ybSBMYmFhczEaMBgG\nA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFDASBgNVBAcTC1NhbiBBbnRvbmlvMQ4w\nDAYDVQQIEwVUZXhhczELMAkGA1UEBhMCVVMwHhcNMTIwMTA5MTk0NjQ1WhcNMTQw\nMTA4MTk0NjQ1WjCBgjELMAkGA1UEBhMCVVMxDjAMBgNVBAgTBVRleGFzMRQwEgYD\nVQQHEwtTYW4gQW50b25pbzEaMBgGA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFzAV\nBgNVBAsTDlBsYXRmb3JtIExiYWFzMRgwFgYDVQQDEw9UZXN0IENsaWVudCBLZXkw\nggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDAi51IylFnHtNLT8C0NVfc\nOBfAsP2D5es1qhrOWHCGlgAuDMksBsCc7FPo5PSBOmQ+6z8HtCFbrLoC5/Zx0F5b\nfVegjA+xKjI2HGASsYHHM0BFEH2UjUcJrWiMWtxQuW6Phbqulo7JwjmygMEmIkeK\nf+FtkE9mrq+E8K40/thrjxl3/ZcJD1+3dcp+ZuzVJ2t1E4iGKCx79IZFsysKiuf+\n+E0i6iGvvI6UcbcZxVxQj2TplJkFuoX5kDgClIX9Dr9y6aJ4SCh+GRhvHl+DTaz0\nnCvghachHZtIeztRDqxWApjOOzs93dSelrviMXDr8fqyEAGg7YIhgui0aZBsWCen\nAgMBAAGjgdUwgdIwgbAGA1UdIwSBqDCBpYAUNpx1Pc6cGA7KqEwHMmHBTZMA7lSh\ngYmkgYYwgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVU4IBATAd\nBgNVHQ4EFgQULueOfsjZZOHwJHZwBy6u0swnpccwDQYJKoZIhvcNAQEFBQADggEB\nAFNuqSVUaotUJoWDv4z7Kbi6JFpTjDht5ORw4BdVYlRD4h9DACAFzPrPV2ym/Osp\nhNMdZq6msZku7MdOSQVhdeGWrSNk3M8O9Hg7cVzPNXOF3iNoo3irQ5tURut44xs4\nWw5YWQqS9WyUY5snD8tm7Y1rQTPfhg+678xIq/zWCv/u+FSnfVv1nlhLVQkEeG/Y\ngh1uMaTIpUKTGEjIAGtpGP7wwIcXptR/HyfzhTUSTaWc1Ef7zoKT9LL5z3IV1hC2\njVWz+RwYs98LjMuksJFoHqRfWyYhCIym0jb6GTwaEmpxAjc+d7OLNQdnoEGoUYGP\nYjtfkRYg265ESMA+Kww4Xy8=\n-----END CERTIFICATE-----\n", - "intermediateCertificate":"-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzEZMBcGA1UEAxMQVGVz\ndCBDQSBTVHViIEtleTEXMBUGA1UECxMOUGxhdGZvcm0gTGJhYXMxGjAYBgNVBAoT\nEVJhY2tzcGFjZSBIb3N0aW5nMRQwEgYDVQQHEwtTYW4gQW50b25pbzEOMAwGA1UE\nCBMFVGV4YXMxCzAJBgNVBAYTAlVTMB4XDTEyMDEwOTE5NDU0OVoXDTE0MDEwODE5\nNDU0OVowgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVUzCCASIw\nDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANNh55lwTVwQvNoEZjq1zGdYz9jA\nXXdjizn8AJhjHLOAallfPtvCfTEgKanhdoyz5FnhQE8HbDAop/KNS1lN2UMvdl5f\nZNLTSjJrNtedqxQwxN/i3bpyBxNVejUH2NjV1mmyj+5CJYwCzWalvI/gLPq/A3as\nO2EQqtf3U8unRgn0zXLRdYxV9MrUzNAmdipPNvNrsVdrCgA42rgF/8KsyRVQfJCX\nfN7PGCfrsC3YaUvhymraWxNnXIzMYTNa9wEeBZLUw8SlEtpa1Zsvui+TPXu3USNZ\nVnWH8Lb6ENlnoX0VBwo62fjOG3JzhNKoJawi3bRqyDdINOvafr7iPrrs/T8CAwEA\nAaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUNpx1Pc6cGA7KqEwHMmHB\nTZMA7lQwDQYJKoZIhvcNAQEFBQADggEBAMoRgH3iTG3t317viLKoY+lNMHUgHuR7\nb3mn9MidJKyYVewe6hCDIN6WY4fUojmMW9wFJWJIo0hRMNHL3n3tq8HP2j20Mxy8\nacPdfGZJa+jiBw72CrIGdobKaFduIlIEDBA1pNdZIJ+EulrtqrMesnIt92WaypIS\n8JycbIgDMCiyC0ENHEk8UWlC6429c7OZAsplMTbHME/1R4btxjkdfrYZJjdJ2yL2\n8cjZDUDMCPTdW/ycP07Gkq30RB5tACB5aZdaCn2YaKC8FsEdhff4X7xEOfOEHWEq\nSRxADDj8Lx1MT6QpR07hCiDyHfTCtbqzI0iGjX63Oh7xXSa0f+JVTa8=\n-----END CERTIFICATE-----\n" - } -} - `) - }) -} - -func mockGetCertResponse(t *testing.T, lbID, certID int) { - th.Mux.HandleFunc(_certURL(lbID, certID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "certificateMapping": { - "id": 123, - "hostName": "rackspace.com", - "certificate":"-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIGATTEAjK3MA0GCSqGSIb3DQEBBQUAMIGDMRkwFwYDVQQD\nExBUZXN0IENBIFNUdWIgS2V5MRcwFQYDVQQLEw5QbGF0Zm9ybSBMYmFhczEaMBgG\nA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFDASBgNVBAcTC1NhbiBBbnRvbmlvMQ4w\nDAYDVQQIEwVUZXhhczELMAkGA1UEBhMCVVMwHhcNMTIwMTA5MTk0NjQ1WhcNMTQw\nMTA4MTk0NjQ1WjCBgjELMAkGA1UEBhMCVVMxDjAMBgNVBAgTBVRleGFzMRQwEgYD\nVQQHEwtTYW4gQW50b25pbzEaMBgGA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFzAV\nBgNVBAsTDlBsYXRmb3JtIExiYWFzMRgwFgYDVQQDEw9UZXN0IENsaWVudCBLZXkw\nggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDAi51IylFnHtNLT8C0NVfc\nOBfAsP2D5es1qhrOWHCGlgAuDMksBsCc7FPo5PSBOmQ+6z8HtCFbrLoC5/Zx0F5b\nfVegjA+xKjI2HGASsYHHM0BFEH2UjUcJrWiMWtxQuW6Phbqulo7JwjmygMEmIkeK\nf+FtkE9mrq+E8K40/thrjxl3/ZcJD1+3dcp+ZuzVJ2t1E4iGKCx79IZFsysKiuf+\n+E0i6iGvvI6UcbcZxVxQj2TplJkFuoX5kDgClIX9Dr9y6aJ4SCh+GRhvHl+DTaz0\nnCvghachHZtIeztRDqxWApjOOzs93dSelrviMXDr8fqyEAGg7YIhgui0aZBsWCen\nAgMBAAGjgdUwgdIwgbAGA1UdIwSBqDCBpYAUNpx1Pc6cGA7KqEwHMmHBTZMA7lSh\ngYmkgYYwgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVU4IBATAd\nBgNVHQ4EFgQULueOfsjZZOHwJHZwBy6u0swnpccwDQYJKoZIhvcNAQEFBQADggEB\nAFNuqSVUaotUJoWDv4z7Kbi6JFpTjDht5ORw4BdVYlRD4h9DACAFzPrPV2ym/Osp\nhNMdZq6msZku7MdOSQVhdeGWrSNk3M8O9Hg7cVzPNXOF3iNoo3irQ5tURut44xs4\nWw5YWQqS9WyUY5snD8tm7Y1rQTPfhg+678xIq/zWCv/u+FSnfVv1nlhLVQkEeG/Y\ngh1uMaTIpUKTGEjIAGtpGP7wwIcXptR/HyfzhTUSTaWc1Ef7zoKT9LL5z3IV1hC2\njVWz+RwYs98LjMuksJFoHqRfWyYhCIym0jb6GTwaEmpxAjc+d7OLNQdnoEGoUYGP\nYjtfkRYg265ESMA+Kww4Xy8=\n-----END CERTIFICATE-----\n", - "intermediateCertificate":"-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzEZMBcGA1UEAxMQVGVz\ndCBDQSBTVHViIEtleTEXMBUGA1UECxMOUGxhdGZvcm0gTGJhYXMxGjAYBgNVBAoT\nEVJhY2tzcGFjZSBIb3N0aW5nMRQwEgYDVQQHEwtTYW4gQW50b25pbzEOMAwGA1UE\nCBMFVGV4YXMxCzAJBgNVBAYTAlVTMB4XDTEyMDEwOTE5NDU0OVoXDTE0MDEwODE5\nNDU0OVowgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVUzCCASIw\nDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANNh55lwTVwQvNoEZjq1zGdYz9jA\nXXdjizn8AJhjHLOAallfPtvCfTEgKanhdoyz5FnhQE8HbDAop/KNS1lN2UMvdl5f\nZNLTSjJrNtedqxQwxN/i3bpyBxNVejUH2NjV1mmyj+5CJYwCzWalvI/gLPq/A3as\nO2EQqtf3U8unRgn0zXLRdYxV9MrUzNAmdipPNvNrsVdrCgA42rgF/8KsyRVQfJCX\nfN7PGCfrsC3YaUvhymraWxNnXIzMYTNa9wEeBZLUw8SlEtpa1Zsvui+TPXu3USNZ\nVnWH8Lb6ENlnoX0VBwo62fjOG3JzhNKoJawi3bRqyDdINOvafr7iPrrs/T8CAwEA\nAaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUNpx1Pc6cGA7KqEwHMmHB\nTZMA7lQwDQYJKoZIhvcNAQEFBQADggEBAMoRgH3iTG3t317viLKoY+lNMHUgHuR7\nb3mn9MidJKyYVewe6hCDIN6WY4fUojmMW9wFJWJIo0hRMNHL3n3tq8HP2j20Mxy8\nacPdfGZJa+jiBw72CrIGdobKaFduIlIEDBA1pNdZIJ+EulrtqrMesnIt92WaypIS\n8JycbIgDMCiyC0ENHEk8UWlC6429c7OZAsplMTbHME/1R4btxjkdfrYZJjdJ2yL2\n8cjZDUDMCPTdW/ycP07Gkq30RB5tACB5aZdaCn2YaKC8FsEdhff4X7xEOfOEHWEq\nSRxADDj8Lx1MT6QpR07hCiDyHfTCtbqzI0iGjX63Oh7xXSa0f+JVTa8=\n-----END CERTIFICATE-----\n" - } -} -`) - }) -} - -func mockUpdateCertResponse(t *testing.T, lbID, certID int) { - th.Mux.HandleFunc(_certURL(lbID, certID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PUT") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "certificateMapping": { - "hostName": "rackspace.com", - "privateKey":"-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEAwIudSMpRZx7TS0/AtDVX3DgXwLD9g+XrNaoazlhwhpYALgzJ\nLAbAnOxT6OT0gTpkPus/B7QhW6y6Auf2cdBeW31XoIwPsSoyNhxgErGBxzNARRB9\nlI1HCa1ojFrcULluj4W6rpaOycI5soDBJiJHin/hbZBPZq6vhPCuNP7Ya48Zd/2X\nCQ9ft3XKfmbs1SdrdROIhigse/SGRbMrCorn/vhNIuohr7yOlHG3GcVcUI9k6ZSZ\nBbqF+ZA4ApSF/Q6/cumieEgofhkYbx5fg02s9Jwr4IWnIR2bSHs7UQ6sVgKYzjs7\nPd3Unpa74jFw6/H6shABoO2CIYLotGmQbFgnpwIDAQABAoIBAQCBCQ+PCIclJHNV\ntUzfeCA5ZR4F9JbxHdRTUnxEbOB8UWotckQfTScoAvj4yvdQ42DrCZxj/UOdvFOs\nPufZvlp91bIz1alugWjE+p8n5+2hIaegoTyHoWZKBfxak0myj5KYfHZvKlbmv1ML\nXV4TwEVRfAIG+v87QTY/UUxuF5vR+BpKIbgUJLfPUFFvJUdl84qsJ44pToxaYUd/\nh5YAGC00U4ay1KVSAUnTkkPNZ0lPG/rWU6w6WcTvNRLMd8DzFLTKLOgQfHhbExAF\n+sXPWjWSzbBRP1O7fHqq96QQh4VFiY/7w9W+sDKQyV6Ul17OSXs6aZ4f+lq4rJTI\n1FG96YiBAoGBAO1tiH0h1oWDBYfJB3KJJ6CQQsDGwtHo/DEgznFVP4XwEVbZ98Ha\nBfBCn3sAybbaikyCV1Hwj7kfHMZPDHbrcUSFX7quu/2zPK+wO3lZKXSyu4YsguSa\nRedInN33PpdnlPhLyQdWSuD5sVHJDF6xn22vlyxeILH3ooLg2WOFMPmVAoGBAM+b\nUG/a7iyfpAQKYyuFAsXz6SeFaDY+ZYeX45L112H8Pu+Ie/qzon+bzLB9FIH8GP6+\nQpQgmm/p37U2gD1zChUv7iW6OfQBKk9rWvMpfRF6d7YHquElejhizfTZ+ntBV/VY\ndOYEczxhrdW7keLpatYaaWUy/VboRZmlz/9JGqVLAoGAHfqNmFc0cgk4IowEj7a3\ntTNh6ltub/i+FynwRykfazcDyXaeLPDtfQe8gVh5H8h6W+y9P9BjJVnDVVrX1RAn\nbiJ1EupLPF5sVDapW8ohTOXgfbGTGXBNUUW+4Nv+IDno+mz/RhjkPYHpnM0I7c/5\ntGzOZsC/2hjNgT8I0+MWav0CgYEAuULdJeQVlKalI6HtW2Gn1uRRVJ49H+LQkY6e\nW3+cw2jo9LI0CMWSphNvNrN3wIMp/vHj0fHCP0pSApDvIWbuQXfzKaGko7UCf7rK\nf6GvZRCHkV4IREBAb97j8bMvThxClMNqFfU0rFZyXP+0MOyhFQyertswrgQ6T+Fi\n2mnvKD8CgYAmJHP3NTDRMoMRyAzonJ6nEaGUbAgNmivTaUWMe0+leCvAdwD89gzC\nTKbm3eDUg/6Va3X6ANh3wsfIOe4RXXxcbcFDk9R4zO2M5gfLSjYm5Q87EBZ2hrdj\nM2gLI7dt6thx0J8lR8xRHBEMrVBdgwp0g1gQzo5dAV88/kpkZVps8Q==\n-----END RSA PRIVATE KEY-----\n", - "certificate":"-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIGATTEAjK3MA0GCSqGSIb3DQEBBQUAMIGDMRkwFwYDVQQD\nExBUZXN0IENBIFNUdWIgS2V5MRcwFQYDVQQLEw5QbGF0Zm9ybSBMYmFhczEaMBgG\nA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFDASBgNVBAcTC1NhbiBBbnRvbmlvMQ4w\nDAYDVQQIEwVUZXhhczELMAkGA1UEBhMCVVMwHhcNMTIwMTA5MTk0NjQ1WhcNMTQw\nMTA4MTk0NjQ1WjCBgjELMAkGA1UEBhMCVVMxDjAMBgNVBAgTBVRleGFzMRQwEgYD\nVQQHEwtTYW4gQW50b25pbzEaMBgGA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFzAV\nBgNVBAsTDlBsYXRmb3JtIExiYWFzMRgwFgYDVQQDEw9UZXN0IENsaWVudCBLZXkw\nggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDAi51IylFnHtNLT8C0NVfc\nOBfAsP2D5es1qhrOWHCGlgAuDMksBsCc7FPo5PSBOmQ+6z8HtCFbrLoC5/Zx0F5b\nfVegjA+xKjI2HGASsYHHM0BFEH2UjUcJrWiMWtxQuW6Phbqulo7JwjmygMEmIkeK\nf+FtkE9mrq+E8K40/thrjxl3/ZcJD1+3dcp+ZuzVJ2t1E4iGKCx79IZFsysKiuf+\n+E0i6iGvvI6UcbcZxVxQj2TplJkFuoX5kDgClIX9Dr9y6aJ4SCh+GRhvHl+DTaz0\nnCvghachHZtIeztRDqxWApjOOzs93dSelrviMXDr8fqyEAGg7YIhgui0aZBsWCen\nAgMBAAGjgdUwgdIwgbAGA1UdIwSBqDCBpYAUNpx1Pc6cGA7KqEwHMmHBTZMA7lSh\ngYmkgYYwgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVU4IBATAd\nBgNVHQ4EFgQULueOfsjZZOHwJHZwBy6u0swnpccwDQYJKoZIhvcNAQEFBQADggEB\nAFNuqSVUaotUJoWDv4z7Kbi6JFpTjDht5ORw4BdVYlRD4h9DACAFzPrPV2ym/Osp\nhNMdZq6msZku7MdOSQVhdeGWrSNk3M8O9Hg7cVzPNXOF3iNoo3irQ5tURut44xs4\nWw5YWQqS9WyUY5snD8tm7Y1rQTPfhg+678xIq/zWCv/u+FSnfVv1nlhLVQkEeG/Y\ngh1uMaTIpUKTGEjIAGtpGP7wwIcXptR/HyfzhTUSTaWc1Ef7zoKT9LL5z3IV1hC2\njVWz+RwYs98LjMuksJFoHqRfWyYhCIym0jb6GTwaEmpxAjc+d7OLNQdnoEGoUYGP\nYjtfkRYg265ESMA+Kww4Xy8=\n-----END CERTIFICATE-----\n", - "intermediateCertificate":"-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzEZMBcGA1UEAxMQVGVz\ndCBDQSBTVHViIEtleTEXMBUGA1UECxMOUGxhdGZvcm0gTGJhYXMxGjAYBgNVBAoT\nEVJhY2tzcGFjZSBIb3N0aW5nMRQwEgYDVQQHEwtTYW4gQW50b25pbzEOMAwGA1UE\nCBMFVGV4YXMxCzAJBgNVBAYTAlVTMB4XDTEyMDEwOTE5NDU0OVoXDTE0MDEwODE5\nNDU0OVowgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVUzCCASIw\nDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANNh55lwTVwQvNoEZjq1zGdYz9jA\nXXdjizn8AJhjHLOAallfPtvCfTEgKanhdoyz5FnhQE8HbDAop/KNS1lN2UMvdl5f\nZNLTSjJrNtedqxQwxN/i3bpyBxNVejUH2NjV1mmyj+5CJYwCzWalvI/gLPq/A3as\nO2EQqtf3U8unRgn0zXLRdYxV9MrUzNAmdipPNvNrsVdrCgA42rgF/8KsyRVQfJCX\nfN7PGCfrsC3YaUvhymraWxNnXIzMYTNa9wEeBZLUw8SlEtpa1Zsvui+TPXu3USNZ\nVnWH8Lb6ENlnoX0VBwo62fjOG3JzhNKoJawi3bRqyDdINOvafr7iPrrs/T8CAwEA\nAaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUNpx1Pc6cGA7KqEwHMmHB\nTZMA7lQwDQYJKoZIhvcNAQEFBQADggEBAMoRgH3iTG3t317viLKoY+lNMHUgHuR7\nb3mn9MidJKyYVewe6hCDIN6WY4fUojmMW9wFJWJIo0hRMNHL3n3tq8HP2j20Mxy8\nacPdfGZJa+jiBw72CrIGdobKaFduIlIEDBA1pNdZIJ+EulrtqrMesnIt92WaypIS\n8JycbIgDMCiyC0ENHEk8UWlC6429c7OZAsplMTbHME/1R4btxjkdfrYZJjdJ2yL2\n8cjZDUDMCPTdW/ycP07Gkq30RB5tACB5aZdaCn2YaKC8FsEdhff4X7xEOfOEHWEq\nSRxADDj8Lx1MT6QpR07hCiDyHfTCtbqzI0iGjX63Oh7xXSa0f+JVTa8=\n-----END CERTIFICATE-----\n" - } -} - `) - - w.WriteHeader(http.StatusAccepted) - - fmt.Fprintf(w, ` -{ - "certificateMapping": { - "id": 123, - "hostName": "rackspace.com", - "certificate":"-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIGATTEAjK3MA0GCSqGSIb3DQEBBQUAMIGDMRkwFwYDVQQD\nExBUZXN0IENBIFNUdWIgS2V5MRcwFQYDVQQLEw5QbGF0Zm9ybSBMYmFhczEaMBgG\nA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFDASBgNVBAcTC1NhbiBBbnRvbmlvMQ4w\nDAYDVQQIEwVUZXhhczELMAkGA1UEBhMCVVMwHhcNMTIwMTA5MTk0NjQ1WhcNMTQw\nMTA4MTk0NjQ1WjCBgjELMAkGA1UEBhMCVVMxDjAMBgNVBAgTBVRleGFzMRQwEgYD\nVQQHEwtTYW4gQW50b25pbzEaMBgGA1UEChMRUmFja3NwYWNlIEhvc3RpbmcxFzAV\nBgNVBAsTDlBsYXRmb3JtIExiYWFzMRgwFgYDVQQDEw9UZXN0IENsaWVudCBLZXkw\nggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDAi51IylFnHtNLT8C0NVfc\nOBfAsP2D5es1qhrOWHCGlgAuDMksBsCc7FPo5PSBOmQ+6z8HtCFbrLoC5/Zx0F5b\nfVegjA+xKjI2HGASsYHHM0BFEH2UjUcJrWiMWtxQuW6Phbqulo7JwjmygMEmIkeK\nf+FtkE9mrq+E8K40/thrjxl3/ZcJD1+3dcp+ZuzVJ2t1E4iGKCx79IZFsysKiuf+\n+E0i6iGvvI6UcbcZxVxQj2TplJkFuoX5kDgClIX9Dr9y6aJ4SCh+GRhvHl+DTaz0\nnCvghachHZtIeztRDqxWApjOOzs93dSelrviMXDr8fqyEAGg7YIhgui0aZBsWCen\nAgMBAAGjgdUwgdIwgbAGA1UdIwSBqDCBpYAUNpx1Pc6cGA7KqEwHMmHBTZMA7lSh\ngYmkgYYwgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVU4IBATAd\nBgNVHQ4EFgQULueOfsjZZOHwJHZwBy6u0swnpccwDQYJKoZIhvcNAQEFBQADggEB\nAFNuqSVUaotUJoWDv4z7Kbi6JFpTjDht5ORw4BdVYlRD4h9DACAFzPrPV2ym/Osp\nhNMdZq6msZku7MdOSQVhdeGWrSNk3M8O9Hg7cVzPNXOF3iNoo3irQ5tURut44xs4\nWw5YWQqS9WyUY5snD8tm7Y1rQTPfhg+678xIq/zWCv/u+FSnfVv1nlhLVQkEeG/Y\ngh1uMaTIpUKTGEjIAGtpGP7wwIcXptR/HyfzhTUSTaWc1Ef7zoKT9LL5z3IV1hC2\njVWz+RwYs98LjMuksJFoHqRfWyYhCIym0jb6GTwaEmpxAjc+d7OLNQdnoEGoUYGP\nYjtfkRYg265ESMA+Kww4Xy8=\n-----END CERTIFICATE-----\n", - "intermediateCertificate":"-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzEZMBcGA1UEAxMQVGVz\ndCBDQSBTVHViIEtleTEXMBUGA1UECxMOUGxhdGZvcm0gTGJhYXMxGjAYBgNVBAoT\nEVJhY2tzcGFjZSBIb3N0aW5nMRQwEgYDVQQHEwtTYW4gQW50b25pbzEOMAwGA1UE\nCBMFVGV4YXMxCzAJBgNVBAYTAlVTMB4XDTEyMDEwOTE5NDU0OVoXDTE0MDEwODE5\nNDU0OVowgYMxGTAXBgNVBAMTEFRlc3QgQ0EgU1R1YiBLZXkxFzAVBgNVBAsTDlBs\nYXRmb3JtIExiYWFzMRowGAYDVQQKExFSYWNrc3BhY2UgSG9zdGluZzEUMBIGA1UE\nBxMLU2FuIEFudG9uaW8xDjAMBgNVBAgTBVRleGFzMQswCQYDVQQGEwJVUzCCASIw\nDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANNh55lwTVwQvNoEZjq1zGdYz9jA\nXXdjizn8AJhjHLOAallfPtvCfTEgKanhdoyz5FnhQE8HbDAop/KNS1lN2UMvdl5f\nZNLTSjJrNtedqxQwxN/i3bpyBxNVejUH2NjV1mmyj+5CJYwCzWalvI/gLPq/A3as\nO2EQqtf3U8unRgn0zXLRdYxV9MrUzNAmdipPNvNrsVdrCgA42rgF/8KsyRVQfJCX\nfN7PGCfrsC3YaUvhymraWxNnXIzMYTNa9wEeBZLUw8SlEtpa1Zsvui+TPXu3USNZ\nVnWH8Lb6ENlnoX0VBwo62fjOG3JzhNKoJawi3bRqyDdINOvafr7iPrrs/T8CAwEA\nAaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUNpx1Pc6cGA7KqEwHMmHB\nTZMA7lQwDQYJKoZIhvcNAQEFBQADggEBAMoRgH3iTG3t317viLKoY+lNMHUgHuR7\nb3mn9MidJKyYVewe6hCDIN6WY4fUojmMW9wFJWJIo0hRMNHL3n3tq8HP2j20Mxy8\nacPdfGZJa+jiBw72CrIGdobKaFduIlIEDBA1pNdZIJ+EulrtqrMesnIt92WaypIS\n8JycbIgDMCiyC0ENHEk8UWlC6429c7OZAsplMTbHME/1R4btxjkdfrYZJjdJ2yL2\n8cjZDUDMCPTdW/ycP07Gkq30RB5tACB5aZdaCn2YaKC8FsEdhff4X7xEOfOEHWEq\nSRxADDj8Lx1MT6QpR07hCiDyHfTCtbqzI0iGjX63Oh7xXSa0f+JVTa8=\n-----END CERTIFICATE-----\n" - } -} - `) - }) -} - -func mockDeleteCertResponse(t *testing.T, lbID, certID int) { - th.Mux.HandleFunc(_certURL(lbID, certID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.WriteHeader(http.StatusOK) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/ssl/requests.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/ssl/requests.go deleted file mode 100644 index bb53ef8960..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/ssl/requests.go +++ /dev/null @@ -1,247 +0,0 @@ -package ssl - -import ( - "errors" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -var ( - errPrivateKey = errors.New("PrivateKey is a required field") - errCertificate = errors.New("Certificate is a required field") - errIntCertificate = errors.New("IntCertificate is a required field") -) - -// UpdateOptsBuilder is the interface options structs have to satisfy in order -// to be used in the main Update operation in this package. -type UpdateOptsBuilder interface { - ToSSLUpdateMap() (map[string]interface{}, error) -} - -// UpdateOpts is the common options struct used in this package's Update -// operation. -type UpdateOpts struct { - // Required - consult the SSLTermConfig struct for more info. - SecurePort int - - // Required - consult the SSLTermConfig struct for more info. - PrivateKey string - - // Required - consult the SSLTermConfig struct for more info. - Certificate string - - // Required - consult the SSLTermConfig struct for more info. - IntCertificate string - - // Optional - consult the SSLTermConfig struct for more info. - Enabled *bool - - // Optional - consult the SSLTermConfig struct for more info. - SecureTrafficOnly *bool -} - -// ToSSLUpdateMap casts a CreateOpts struct to a map. -func (opts UpdateOpts) ToSSLUpdateMap() (map[string]interface{}, error) { - ssl := make(map[string]interface{}) - - if opts.SecurePort == 0 { - return ssl, errors.New("SecurePort needs to be an integer greater than 0") - } - if opts.PrivateKey == "" { - return ssl, errPrivateKey - } - if opts.Certificate == "" { - return ssl, errCertificate - } - if opts.IntCertificate == "" { - return ssl, errIntCertificate - } - - ssl["securePort"] = opts.SecurePort - ssl["privateKey"] = opts.PrivateKey - ssl["certificate"] = opts.Certificate - ssl["intermediateCertificate"] = opts.IntCertificate - - if opts.Enabled != nil { - ssl["enabled"] = &opts.Enabled - } - - if opts.SecureTrafficOnly != nil { - ssl["secureTrafficOnly"] = &opts.SecureTrafficOnly - } - - return map[string]interface{}{"sslTermination": ssl}, nil -} - -// Update is the operation responsible for updating the SSL Termination -// configuration for a load balancer. -func Update(c *gophercloud.ServiceClient, lbID int, opts UpdateOptsBuilder) UpdateResult { - var res UpdateResult - - reqBody, err := opts.ToSSLUpdateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = c.Put(rootURL(c, lbID), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - return res -} - -// Get is the operation responsible for showing the details of the SSL -// Termination configuration for a load balancer. -func Get(c *gophercloud.ServiceClient, lbID int) GetResult { - var res GetResult - _, res.Err = c.Get(rootURL(c, lbID), &res.Body, nil) - return res -} - -// Delete is the operation responsible for deleting the SSL Termination -// configuration for a load balancer. -func Delete(c *gophercloud.ServiceClient, lbID int) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(rootURL(c, lbID), &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - return res -} - -// ListCerts will list all of the certificate mappings associated with a -// SSL-terminated HTTP load balancer. -func ListCerts(c *gophercloud.ServiceClient, lbID int) pagination.Pager { - url := certURL(c, lbID) - return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page { - return CertPage{pagination.LinkedPageBase{PageResult: r}} - }) -} - -// CreateCertOptsBuilder is the interface options structs have to satisfy in -// order to be used in the AddCert operation in this package. -type CreateCertOptsBuilder interface { - ToCertCreateMap() (map[string]interface{}, error) -} - -// CreateCertOpts represents the options used when adding a new certificate mapping. -type CreateCertOpts struct { - HostName string - PrivateKey string - Certificate string - IntCertificate string -} - -// ToCertCreateMap will cast an CreateCertOpts struct to a map for JSON serialization. -func (opts CreateCertOpts) ToCertCreateMap() (map[string]interface{}, error) { - cm := make(map[string]interface{}) - - if opts.HostName == "" { - return cm, errors.New("HostName is a required option") - } - if opts.PrivateKey == "" { - return cm, errPrivateKey - } - if opts.Certificate == "" { - return cm, errCertificate - } - - cm["hostName"] = opts.HostName - cm["privateKey"] = opts.PrivateKey - cm["certificate"] = opts.Certificate - - if opts.IntCertificate != "" { - cm["intermediateCertificate"] = opts.IntCertificate - } - - return map[string]interface{}{"certificateMapping": cm}, nil -} - -// CreateCert will add a new SSL certificate and allow an SSL-terminated HTTP -// load balancer to use it. This feature is useful because it allows multiple -// certificates to be used. The maximum number of certificates that can be -// stored per LB is 20. -func CreateCert(c *gophercloud.ServiceClient, lbID int, opts CreateCertOptsBuilder) CreateCertResult { - var res CreateCertResult - - reqBody, err := opts.ToCertCreateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = c.Post(certURL(c, lbID), reqBody, &res.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - - return res -} - -// GetCert will show the details of an existing SSL certificate. -func GetCert(c *gophercloud.ServiceClient, lbID, certID int) GetCertResult { - var res GetCertResult - _, res.Err = c.Get(certResourceURL(c, lbID, certID), &res.Body, nil) - return res -} - -// UpdateCertOptsBuilder is the interface options structs have to satisfy in -// order to be used in the UpdateCert operation in this package. -type UpdateCertOptsBuilder interface { - ToCertUpdateMap() (map[string]interface{}, error) -} - -// UpdateCertOpts represents the options needed to update a SSL certificate. -type UpdateCertOpts struct { - HostName string - PrivateKey string - Certificate string - IntCertificate string -} - -// ToCertUpdateMap will cast an UpdateCertOpts struct into a map for JSON -// seralization. -func (opts UpdateCertOpts) ToCertUpdateMap() (map[string]interface{}, error) { - cm := make(map[string]interface{}) - - if opts.HostName != "" { - cm["hostName"] = opts.HostName - } - if opts.PrivateKey != "" { - cm["privateKey"] = opts.PrivateKey - } - if opts.Certificate != "" { - cm["certificate"] = opts.Certificate - } - if opts.IntCertificate != "" { - cm["intermediateCertificate"] = opts.IntCertificate - } - - return map[string]interface{}{"certificateMapping": cm}, nil -} - -// UpdateCert is the operation responsible for updating the details of an -// existing SSL certificate. -func UpdateCert(c *gophercloud.ServiceClient, lbID, certID int, opts UpdateCertOptsBuilder) UpdateCertResult { - var res UpdateCertResult - - reqBody, err := opts.ToCertUpdateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = c.Put(certResourceURL(c, lbID, certID), reqBody, &res.Body, nil) - return res -} - -// DeleteCert is the operation responsible for permanently removing a SSL -// certificate. -func DeleteCert(c *gophercloud.ServiceClient, lbID, certID int) DeleteResult { - var res DeleteResult - - _, res.Err = c.Delete(certResourceURL(c, lbID, certID), &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/ssl/results.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/ssl/results.go deleted file mode 100644 index ead9fcd37e..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/ssl/results.go +++ /dev/null @@ -1,148 +0,0 @@ -package ssl - -import ( - "github.com/mitchellh/mapstructure" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// SSLTermConfig represents the SSL configuration for a particular load balancer. -type SSLTermConfig struct { - // The port on which the SSL termination load balancer listens for secure - // traffic. The value must be unique to the existing LB protocol/port - // combination - SecurePort int `mapstructure:"securePort"` - - // The private key for the SSL certificate which is validated and verified - // against the provided certificates. - PrivateKey string `mapstructure:"privatekey"` - - // The certificate used for SSL termination, which is validated and verified - // against the key and intermediate certificate if provided. - Certificate string - - // The intermediate certificate (for the user). The intermediate certificate - // is validated and verified against the key and certificate credentials - // provided. A user may only provide this value when accompanied by a - // Certificate, PrivateKey, and SecurePort. It may not be added or updated as - // a single attribute in a future operation. - IntCertificate string `mapstructure:"intermediatecertificate"` - - // Determines if the load balancer is enabled to terminate SSL traffic or not. - // If this is set to false, the load balancer retains its specified SSL - // attributes but does not terminate SSL traffic. - Enabled bool - - // Determines if the load balancer can only accept secure traffic. If set to - // true, the load balancer will not accept non-secure traffic. - SecureTrafficOnly bool -} - -// DeleteResult represents the result of a delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} - -// UpdateResult represents the result of an update operation. -type UpdateResult struct { - gophercloud.ErrResult -} - -// GetResult represents the result of a get operation. -type GetResult struct { - gophercloud.Result -} - -// Extract interprets a GetResult as a SSLTermConfig struct, if possible. -func (r GetResult) Extract() (*SSLTermConfig, error) { - if r.Err != nil { - return nil, r.Err - } - - var response struct { - SSL SSLTermConfig `mapstructure:"sslTermination"` - } - - err := mapstructure.Decode(r.Body, &response) - - return &response.SSL, err -} - -// Certificate represents an SSL certificate associated with an SSL-terminated -// HTTP load balancer. -type Certificate struct { - ID int - HostName string - Certificate string - IntCertificate string `mapstructure:"intermediateCertificate"` -} - -// CertPage represents a page of certificates. -type CertPage struct { - pagination.LinkedPageBase -} - -// IsEmpty checks whether a CertMappingPage struct is empty. -func (p CertPage) IsEmpty() (bool, error) { - is, err := ExtractCerts(p) - if err != nil { - return true, nil - } - return len(is) == 0, nil -} - -// ExtractCerts accepts a Page struct, specifically a CertPage struct, and -// extracts the elements into a slice of Cert structs. In other words, a generic -// collection is mapped into a relevant slice. -func ExtractCerts(page pagination.Page) ([]Certificate, error) { - type NestedMap struct { - Cert Certificate `mapstructure:"certificateMapping" json:"certificateMapping"` - } - var resp struct { - Certs []NestedMap `mapstructure:"certificateMappings" json:"certificateMappings"` - } - - err := mapstructure.Decode(page.(CertPage).Body, &resp) - - slice := []Certificate{} - for _, cert := range resp.Certs { - slice = append(slice, cert.Cert) - } - - return slice, err -} - -type certResult struct { - gophercloud.Result -} - -// Extract interprets a result as a CertMapping struct, if possible. -func (r certResult) Extract() (*Certificate, error) { - if r.Err != nil { - return nil, r.Err - } - - var response struct { - Cert Certificate `mapstructure:"certificateMapping"` - } - - err := mapstructure.Decode(r.Body, &response) - - return &response.Cert, err -} - -// CreateCertResult represents the result of an CreateCert operation. -type CreateCertResult struct { - certResult -} - -// GetCertResult represents the result of a GetCert operation. -type GetCertResult struct { - certResult -} - -// UpdateCertResult represents the result of an UpdateCert operation. -type UpdateCertResult struct { - certResult -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/ssl/urls.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/ssl/urls.go deleted file mode 100644 index aa814b3583..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/ssl/urls.go +++ /dev/null @@ -1,25 +0,0 @@ -package ssl - -import ( - "strconv" - - "github.com/rackspace/gophercloud" -) - -const ( - path = "loadbalancers" - sslPath = "ssltermination" - certPath = "certificatemappings" -) - -func rootURL(c *gophercloud.ServiceClient, id int) string { - return c.ServiceURL(path, strconv.Itoa(id), sslPath) -} - -func certURL(c *gophercloud.ServiceClient, id int) string { - return c.ServiceURL(path, strconv.Itoa(id), sslPath, certPath) -} - -func certResourceURL(c *gophercloud.ServiceClient, id, certID int) string { - return c.ServiceURL(path, strconv.Itoa(id), sslPath, certPath, strconv.Itoa(certID)) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/throttle/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/throttle/doc.go deleted file mode 100644 index 1ed605d362..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/throttle/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -/* -Package throttle provides information and interaction with the Connection -Throttling feature of the Rackspace Cloud Load Balancer service. -*/ -package throttle diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/throttle/fixtures.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/throttle/fixtures.go deleted file mode 100644 index 40223f60a6..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/throttle/fixtures.go +++ /dev/null @@ -1,61 +0,0 @@ -package throttle - -import ( - "fmt" - "net/http" - "strconv" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -func _rootURL(id int) string { - return "/loadbalancers/" + strconv.Itoa(id) + "/connectionthrottle" -} - -func mockGetResponse(t *testing.T, lbID int) { - th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "connectionThrottle": { - "maxConnections": 100 - } -} -`) - }) -} - -func mockCreateResponse(t *testing.T, lbID int) { - th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "PUT") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "connectionThrottle": { - "maxConnectionRate": 0, - "maxConnections": 200, - "minConnections": 0, - "rateInterval": 0 - } -} - `) - - w.WriteHeader(http.StatusAccepted) - }) -} - -func mockDeleteResponse(t *testing.T, lbID int) { - th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.WriteHeader(http.StatusAccepted) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/throttle/requests.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/throttle/requests.go deleted file mode 100644 index 0446b97a14..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/throttle/requests.go +++ /dev/null @@ -1,76 +0,0 @@ -package throttle - -import ( - "errors" - - "github.com/rackspace/gophercloud" -) - -// CreateOptsBuilder is the interface options structs have to satisfy in order -// to be used in the main Create operation in this package. -type CreateOptsBuilder interface { - ToCTCreateMap() (map[string]interface{}, error) -} - -// CreateOpts is the common options struct used in this package's Create -// operation. -type CreateOpts struct { - // Required - the maximum amount of connections per IP address to allow per LB. - MaxConnections int - - // Deprecated as of v1.22. - MaxConnectionRate int - - // Deprecated as of v1.22. - MinConnections int - - // Deprecated as of v1.22. - RateInterval int -} - -// ToCTCreateMap casts a CreateOpts struct to a map. -func (opts CreateOpts) ToCTCreateMap() (map[string]interface{}, error) { - ct := make(map[string]interface{}) - - if opts.MaxConnections < 0 || opts.MaxConnections > 100000 { - return ct, errors.New("MaxConnections must be an int between 0 and 100000") - } - - ct["maxConnections"] = opts.MaxConnections - ct["maxConnectionRate"] = opts.MaxConnectionRate - ct["minConnections"] = opts.MinConnections - ct["rateInterval"] = opts.RateInterval - - return map[string]interface{}{"connectionThrottle": ct}, nil -} - -// Create is the operation responsible for creating or updating the connection -// throttling configuration for a load balancer. -func Create(c *gophercloud.ServiceClient, lbID int, opts CreateOptsBuilder) CreateResult { - var res CreateResult - - reqBody, err := opts.ToCTCreateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = c.Put(rootURL(c, lbID), reqBody, &res.Body, nil) - return res -} - -// Get is the operation responsible for showing the details of the connection -// throttling configuration for a load balancer. -func Get(c *gophercloud.ServiceClient, lbID int) GetResult { - var res GetResult - _, res.Err = c.Get(rootURL(c, lbID), &res.Body, nil) - return res -} - -// Delete is the operation responsible for deleting the connection throttling -// configuration for a load balancer. -func Delete(c *gophercloud.ServiceClient, lbID int) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(rootURL(c, lbID), nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/throttle/results.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/throttle/results.go deleted file mode 100644 index db93c6f3f4..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/throttle/results.go +++ /dev/null @@ -1,43 +0,0 @@ -package throttle - -import ( - "github.com/mitchellh/mapstructure" - - "github.com/rackspace/gophercloud" -) - -// ConnectionThrottle represents the connection throttle configuration for a -// particular load balancer. -type ConnectionThrottle struct { - MaxConnections int -} - -// CreateResult represents the result of a create operation. -type CreateResult struct { - gophercloud.ErrResult -} - -// DeleteResult represents the result of a delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} - -// GetResult represents the result of a get operation. -type GetResult struct { - gophercloud.Result -} - -// Extract interprets a GetResult as a SP, if possible. -func (r GetResult) Extract() (*ConnectionThrottle, error) { - if r.Err != nil { - return nil, r.Err - } - - var response struct { - CT ConnectionThrottle `mapstructure:"connectionThrottle"` - } - - err := mapstructure.Decode(r.Body, &response) - - return &response.CT, err -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/throttle/urls.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/throttle/urls.go deleted file mode 100644 index b77f0ac1c7..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/throttle/urls.go +++ /dev/null @@ -1,16 +0,0 @@ -package throttle - -import ( - "strconv" - - "github.com/rackspace/gophercloud" -) - -const ( - path = "loadbalancers" - ctPath = "connectionthrottle" -) - -func rootURL(c *gophercloud.ServiceClient, id int) string { - return c.ServiceURL(path, strconv.Itoa(id), ctPath) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/vips/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/vips/doc.go deleted file mode 100644 index 5c3846d44d..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/vips/doc.go +++ /dev/null @@ -1,13 +0,0 @@ -/* -Package vips provides information and interaction with the Virtual IP API -resource for the Rackspace Cloud Load Balancer service. - -A virtual IP (VIP) makes a load balancer accessible by clients. The load -balancing service supports either a public VIP, routable on the public Internet, -or a ServiceNet address, routable only within the region in which the load -balancer resides. - -All load balancers must have at least one virtual IP associated with them at -all times. -*/ -package vips diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/vips/fixtures.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/vips/fixtures.go deleted file mode 100644 index 158759f7fa..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/vips/fixtures.go +++ /dev/null @@ -1,88 +0,0 @@ -package vips - -import ( - "fmt" - "net/http" - "strconv" - "testing" - - th "github.com/rackspace/gophercloud/testhelper" - fake "github.com/rackspace/gophercloud/testhelper/client" -) - -func _rootURL(lbID int) string { - return "/loadbalancers/" + strconv.Itoa(lbID) + "/virtualips" -} - -func mockListResponse(t *testing.T, lbID int) { - th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "GET") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - - fmt.Fprintf(w, ` -{ - "virtualIps": [ - { - "id": 1000, - "address": "206.10.10.210", - "type": "PUBLIC" - } - ] -} - `) - }) -} - -func mockCreateResponse(t *testing.T, lbID int) { - th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "POST") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - th.TestJSONRequest(t, r, ` -{ - "type":"PUBLIC", - "ipVersion":"IPV6" -} - `) - - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(http.StatusAccepted) - - fmt.Fprintf(w, ` -{ - "address":"fd24:f480:ce44:91bc:1af2:15ff:0000:0002", - "id":9000134, - "type":"PUBLIC", - "ipVersion":"IPV6" -} - `) - }) -} - -func mockBatchDeleteResponse(t *testing.T, lbID int, ids []int) { - th.Mux.HandleFunc(_rootURL(lbID), func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - - r.ParseForm() - - for k, v := range ids { - fids := r.Form["id"] - th.AssertEquals(t, strconv.Itoa(v), fids[k]) - } - - w.WriteHeader(http.StatusAccepted) - }) -} - -func mockDeleteResponse(t *testing.T, lbID, vipID int) { - url := _rootURL(lbID) + "/" + strconv.Itoa(vipID) - th.Mux.HandleFunc(url, func(w http.ResponseWriter, r *http.Request) { - th.TestMethod(t, r, "DELETE") - th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) - w.WriteHeader(http.StatusAccepted) - }) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/vips/requests.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/vips/requests.go deleted file mode 100644 index 2bc924f293..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/vips/requests.go +++ /dev/null @@ -1,97 +0,0 @@ -package vips - -import ( - "errors" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// List is the operation responsible for returning a paginated collection of -// load balancer virtual IP addresses. -func List(client *gophercloud.ServiceClient, loadBalancerID int) pagination.Pager { - url := rootURL(client, loadBalancerID) - return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { - return VIPPage{pagination.SinglePageBase(r)} - }) -} - -// CreateOptsBuilder is the interface options structs have to satisfy in order -// to be used in the main Create operation in this package. Since many -// extensions decorate or modify the common logic, it is useful for them to -// satisfy a basic interface in order for them to be used. -type CreateOptsBuilder interface { - ToVIPCreateMap() (map[string]interface{}, error) -} - -// CreateOpts is the common options struct used in this package's Create -// operation. -type CreateOpts struct { - // Optional - the ID of an existing virtual IP. By doing this, you are - // allowing load balancers to share IPV6 addresses. - ID string - - // Optional - the type of address. - Type Type - - // Optional - the version of address. - Version Version -} - -// ToVIPCreateMap casts a CreateOpts struct to a map. -func (opts CreateOpts) ToVIPCreateMap() (map[string]interface{}, error) { - lb := make(map[string]interface{}) - - if opts.ID != "" { - lb["id"] = opts.ID - } - if opts.Type != "" { - lb["type"] = opts.Type - } - if opts.Version != "" { - lb["ipVersion"] = opts.Version - } - - return lb, nil -} - -// Create is the operation responsible for assigning a new Virtual IP to an -// existing load balancer resource. Currently, only version 6 IP addresses may -// be added. -func Create(c *gophercloud.ServiceClient, lbID int, opts CreateOptsBuilder) CreateResult { - var res CreateResult - - reqBody, err := opts.ToVIPCreateMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = c.Post(rootURL(c, lbID), reqBody, &res.Body, nil) - return res -} - -// BulkDelete is the operation responsible for batch deleting multiple VIPs in -// a single operation. It accepts a slice of integer IDs and will remove them -// from the load balancer. The maximum limit is 10 VIP removals at once. -func BulkDelete(c *gophercloud.ServiceClient, loadBalancerID int, vipIDs []int) DeleteResult { - var res DeleteResult - - if len(vipIDs) > 10 || len(vipIDs) == 0 { - res.Err = errors.New("You must provide a minimum of 1 and a maximum of 10 VIP IDs") - return res - } - - url := rootURL(c, loadBalancerID) - url += gophercloud.IDSliceToQueryString("id", vipIDs) - - _, res.Err = c.Delete(url, nil) - return res -} - -// Delete is the operation responsible for permanently deleting a VIP. -func Delete(c *gophercloud.ServiceClient, lbID, vipID int) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(resourceURL(c, lbID, vipID), nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/vips/results.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/vips/results.go deleted file mode 100644 index 678b2aff79..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/vips/results.go +++ /dev/null @@ -1,89 +0,0 @@ -package vips - -import ( - "github.com/mitchellh/mapstructure" - - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// VIP represents a Virtual IP API resource. -type VIP struct { - Address string `json:"address,omitempty"` - ID int `json:"id,omitempty"` - Type Type `json:"type,omitempty"` - Version Version `json:"ipVersion,omitempty" mapstructure:"ipVersion"` -} - -// Version represents the version of a VIP. -type Version string - -// Convenient constants to use for type -const ( - IPV4 Version = "IPV4" - IPV6 Version = "IPV6" -) - -// Type represents the type of a VIP. -type Type string - -const ( - // PUBLIC indicates a VIP type that is routable on the public Internet. - PUBLIC Type = "PUBLIC" - - // PRIVATE indicates a VIP type that is routable only on ServiceNet. - PRIVATE Type = "SERVICENET" -) - -// VIPPage is the page returned by a pager when traversing over a collection -// of VIPs. -type VIPPage struct { - pagination.SinglePageBase -} - -// IsEmpty checks whether a VIPPage struct is empty. -func (p VIPPage) IsEmpty() (bool, error) { - is, err := ExtractVIPs(p) - if err != nil { - return true, nil - } - return len(is) == 0, nil -} - -// ExtractVIPs accepts a Page struct, specifically a VIPPage struct, and -// extracts the elements into a slice of VIP structs. In other words, a -// generic collection is mapped into a relevant slice. -func ExtractVIPs(page pagination.Page) ([]VIP, error) { - var resp struct { - VIPs []VIP `mapstructure:"virtualIps" json:"virtualIps"` - } - - err := mapstructure.Decode(page.(VIPPage).Body, &resp) - - return resp.VIPs, err -} - -type commonResult struct { - gophercloud.Result -} - -func (r commonResult) Extract() (*VIP, error) { - if r.Err != nil { - return nil, r.Err - } - - resp := &VIP{} - err := mapstructure.Decode(r.Body, resp) - - return resp, err -} - -// CreateResult represents the result of a create operation. -type CreateResult struct { - commonResult -} - -// DeleteResult represents the result of a delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/vips/urls.go b/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/vips/urls.go deleted file mode 100644 index 28f063a0f7..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/lb/v1/vips/urls.go +++ /dev/null @@ -1,20 +0,0 @@ -package vips - -import ( - "strconv" - - "github.com/rackspace/gophercloud" -) - -const ( - lbPath = "loadbalancers" - vipPath = "virtualips" -) - -func resourceURL(c *gophercloud.ServiceClient, lbID, nodeID int) string { - return c.ServiceURL(lbPath, strconv.Itoa(lbID), vipPath, strconv.Itoa(nodeID)) -} - -func rootURL(c *gophercloud.ServiceClient, lbID int) string { - return c.ServiceURL(lbPath, strconv.Itoa(lbID), vipPath) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/common/common_tests.go b/vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/common/common_tests.go deleted file mode 100644 index 129cd63aee..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/common/common_tests.go +++ /dev/null @@ -1,12 +0,0 @@ -package common - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/testhelper/client" -) - -const TokenID = client.TokenID - -func ServiceClient() *gophercloud.ServiceClient { - return client.ServiceClient() -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/networks/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/networks/delegate.go deleted file mode 100644 index dcb0855dba..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/networks/delegate.go +++ /dev/null @@ -1,41 +0,0 @@ -package networks - -import ( - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/networking/v2/networks" - "github.com/rackspace/gophercloud/pagination" -) - -// List returns a Pager which allows you to iterate over a collection of -// networks. It accepts a ListOpts struct, which allows you to filter and sort -// the returned collection for greater efficiency. -func List(c *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager { - return os.List(c, opts) -} - -// Get retrieves a specific network based on its unique ID. -func Get(c *gophercloud.ServiceClient, networkID string) os.GetResult { - return os.Get(c, networkID) -} - -// Create accepts a CreateOpts struct and creates a new network using the values -// provided. This operation does not actually require a request body, i.e. the -// CreateOpts struct argument can be empty. -// -// The tenant ID that is contained in the URI is the tenant that creates the -// network. An admin user, however, has the option of specifying another tenant -// ID in the CreateOpts struct. -func Create(c *gophercloud.ServiceClient, opts os.CreateOptsBuilder) os.CreateResult { - return os.Create(c, opts) -} - -// Update accepts a UpdateOpts struct and updates an existing network using the -// values provided. For more information, see the Create function. -func Update(c *gophercloud.ServiceClient, networkID string, opts os.UpdateOptsBuilder) os.UpdateResult { - return os.Update(c, networkID, opts) -} - -// Delete accepts a unique ID and deletes the network associated with it. -func Delete(c *gophercloud.ServiceClient, networkID string) os.DeleteResult { - return os.Delete(c, networkID) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/ports/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/ports/delegate.go deleted file mode 100644 index 95728d1855..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/ports/delegate.go +++ /dev/null @@ -1,43 +0,0 @@ -package ports - -import ( - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/networking/v2/ports" - "github.com/rackspace/gophercloud/pagination" -) - -// List returns a Pager which allows you to iterate over a collection of -// ports. It accepts a ListOpts struct, which allows you to filter and sort -// the returned collection for greater efficiency. -// -// Default policy settings return only those ports that are owned by the tenant -// who submits the request, unless the request is submitted by a user with -// administrative rights. -func List(c *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager { - return os.List(c, opts) -} - -// Get retrieves a specific port based on its unique ID. -func Get(c *gophercloud.ServiceClient, networkID string) os.GetResult { - return os.Get(c, networkID) -} - -// Create accepts a CreateOpts struct and creates a new network using the values -// provided. You must remember to provide a NetworkID value. -// -// NOTE: Currently the SecurityGroup option is not implemented to work with -// Rackspace. -func Create(c *gophercloud.ServiceClient, opts os.CreateOptsBuilder) os.CreateResult { - return os.Create(c, opts) -} - -// Update accepts a UpdateOpts struct and updates an existing port using the -// values provided. -func Update(c *gophercloud.ServiceClient, networkID string, opts os.UpdateOptsBuilder) os.UpdateResult { - return os.Update(c, networkID, opts) -} - -// Delete accepts a unique ID and deletes the port associated with it. -func Delete(c *gophercloud.ServiceClient, networkID string) os.DeleteResult { - return os.Delete(c, networkID) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/security/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/security/doc.go deleted file mode 100644 index 31f744ccd7..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/security/doc.go +++ /dev/null @@ -1,32 +0,0 @@ -// Package security contains functionality to work with security group and -// security group rules Neutron resources. -// -// Security groups and security group rules allows administrators and tenants -// the ability to specify the type of traffic and direction (ingress/egress) -// that is allowed to pass through a port. A security group is a container for -// security group rules. -// -// When a port is created in Networking it is associated with a security group. -// If a security group is not specified the port is associated with a 'default' -// security group. By default, this group drops all ingress traffic and allows -// all egress. Rules can be added to this group in order to change the behaviour. -// -// The basic characteristics of Neutron Security Groups are: -// -// For ingress traffic (to an instance) -// - Only traffic matched with security group rules are allowed. -// - When there is no rule defined, all traffic is dropped. -// -// For egress traffic (from an instance) -// - Only traffic matched with security group rules are allowed. -// - When there is no rule defined, all egress traffic are dropped. -// - When a new security group is created, rules to allow all egress traffic -// is automatically added. -// -// "default security group" is defined for each tenant. -// - For the default security group a rule which allows intercommunication -// among hosts associated with the default security group is defined by default. -// - As a result, all egress traffic and intercommunication in the default -// group are allowed and all ingress from outside of the default group is -// dropped by default (in the default security group). -package security diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/security/groups/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/security/groups/delegate.go deleted file mode 100644 index 1e9a23a05a..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/security/groups/delegate.go +++ /dev/null @@ -1,30 +0,0 @@ -package groups - -import ( - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/groups" - "github.com/rackspace/gophercloud/pagination" -) - -// List returns a Pager which allows you to iterate over a collection of -// security groups. It accepts a ListOpts struct, which allows you to filter -// and sort the returned collection for greater efficiency. -func List(c *gophercloud.ServiceClient, opts os.ListOpts) pagination.Pager { - return os.List(c, opts) -} - -// Create is an operation which provisions a new security group with default -// security group rules for the IPv4 and IPv6 ether types. -func Create(c *gophercloud.ServiceClient, opts os.CreateOpts) os.CreateResult { - return os.Create(c, opts) -} - -// Get retrieves a particular security group based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) os.GetResult { - return os.Get(c, id) -} - -// Delete will permanently delete a particular security group based on its unique ID. -func Delete(c *gophercloud.ServiceClient, id string) os.DeleteResult { - return os.Delete(c, id) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/security/rules/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/security/rules/delegate.go deleted file mode 100644 index 23b4b318e2..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/security/rules/delegate.go +++ /dev/null @@ -1,30 +0,0 @@ -package rules - -import ( - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/rules" - "github.com/rackspace/gophercloud/pagination" -) - -// List returns a Pager which allows you to iterate over a collection of -// security group rules. It accepts a ListOpts struct, which allows you to filter -// and sort the returned collection for greater efficiency. -func List(c *gophercloud.ServiceClient, opts os.ListOpts) pagination.Pager { - return os.List(c, opts) -} - -// Create is an operation which provisions a new security group with default -// security group rules for the IPv4 and IPv6 ether types. -func Create(c *gophercloud.ServiceClient, opts os.CreateOpts) os.CreateResult { - return os.Create(c, opts) -} - -// Get retrieves a particular security group based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) os.GetResult { - return os.Get(c, id) -} - -// Delete will permanently delete a particular security group based on its unique ID. -func Delete(c *gophercloud.ServiceClient, id string) os.DeleteResult { - return os.Delete(c, id) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/subnets/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/subnets/delegate.go deleted file mode 100644 index a7fb7bb15f..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/networking/v2/subnets/delegate.go +++ /dev/null @@ -1,40 +0,0 @@ -package subnets - -import ( - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/networking/v2/subnets" - "github.com/rackspace/gophercloud/pagination" -) - -// List returns a Pager which allows you to iterate over a collection of -// subnets. It accepts a ListOpts struct, which allows you to filter and sort -// the returned collection for greater efficiency. -// -// Default policy settings return only those subnets that are owned by the tenant -// who submits the request, unless the request is submitted by a user with -// administrative rights. -func List(c *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager { - return os.List(c, opts) -} - -// Get retrieves a specific subnet based on its unique ID. -func Get(c *gophercloud.ServiceClient, networkID string) os.GetResult { - return os.Get(c, networkID) -} - -// Create accepts a CreateOpts struct and creates a new subnet using the values -// provided. You must remember to provide a valid NetworkID, CIDR and IP version. -func Create(c *gophercloud.ServiceClient, opts os.CreateOptsBuilder) os.CreateResult { - return os.Create(c, opts) -} - -// Update accepts a UpdateOpts struct and updates an existing subnet using the -// values provided. -func Update(c *gophercloud.ServiceClient, networkID string, opts os.UpdateOptsBuilder) os.UpdateResult { - return os.Update(c, networkID, opts) -} - -// Delete accepts a unique ID and deletes the subnet associated with it. -func Delete(c *gophercloud.ServiceClient, networkID string) os.DeleteResult { - return os.Delete(c, networkID) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/accounts/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/accounts/delegate.go deleted file mode 100644 index 94739308fa..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/accounts/delegate.go +++ /dev/null @@ -1,39 +0,0 @@ -package accounts - -import ( - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts" -) - -// Get is a function that retrieves an account's metadata. To extract just the -// custom metadata, call the ExtractMetadata method on the GetResult. To extract -// all the headers that are returned (including the metadata), call the -// ExtractHeader method on the GetResult. -func Get(c *gophercloud.ServiceClient) os.GetResult { - return os.Get(c, nil) -} - -// UpdateOpts is a structure that contains parameters for updating, creating, or -// deleting an account's metadata. -type UpdateOpts struct { - Metadata map[string]string - TempURLKey string `h:"X-Account-Meta-Temp-URL-Key"` - TempURLKey2 string `h:"X-Account-Meta-Temp-URL-Key-2"` -} - -// ToAccountUpdateMap formats an UpdateOpts into a map[string]string of headers. -func (opts UpdateOpts) ToAccountUpdateMap() (map[string]string, error) { - headers, err := gophercloud.BuildHeaders(opts) - if err != nil { - return nil, err - } - for k, v := range opts.Metadata { - headers["X-Account-Meta-"+k] = v - } - return headers, err -} - -// Update will update an account's metadata with the Metadata in the UpdateOptsBuilder. -func Update(c *gophercloud.ServiceClient, opts os.UpdateOptsBuilder) os.UpdateResult { - return os.Update(c, opts) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/accounts/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/accounts/doc.go deleted file mode 100644 index 293a93088a..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/accounts/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package accounts provides information and interaction with the account -// API resource for the Rackspace Cloud Files service. -package accounts diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/bulk/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/bulk/doc.go deleted file mode 100644 index 9c89e22b21..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/bulk/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package bulk provides functionality for working with bulk operations in the -// Rackspace Cloud Files service. -package bulk diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/bulk/requests.go b/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/bulk/requests.go deleted file mode 100644 index 898b73b0bd..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/bulk/requests.go +++ /dev/null @@ -1,49 +0,0 @@ -package bulk - -import ( - "net/url" - "strings" - - "github.com/rackspace/gophercloud" -) - -// DeleteOptsBuilder allows extensions to add additional parameters to the -// Delete request. -type DeleteOptsBuilder interface { - ToBulkDeleteBody() (string, error) -} - -// DeleteOpts is a structure that holds parameters for deleting an object. -type DeleteOpts []string - -// ToBulkDeleteBody formats a DeleteOpts into a request body. -func (opts DeleteOpts) ToBulkDeleteBody() (string, error) { - return url.QueryEscape(strings.Join(opts, "\n")), nil -} - -// Delete will delete objects or containers in bulk. -func Delete(c *gophercloud.ServiceClient, opts DeleteOptsBuilder) DeleteResult { - var res DeleteResult - - if opts == nil { - return res - } - - reqString, err := opts.ToBulkDeleteBody() - if err != nil { - res.Err = err - return res - } - - reqBody := strings.NewReader(reqString) - - resp, err := c.Request("DELETE", deleteURL(c), gophercloud.RequestOpts{ - MoreHeaders: map[string]string{"Content-Type": "text/plain"}, - OkCodes: []int{200}, - JSONBody: reqBody, - JSONResponse: &res.Body, - }) - res.Header = resp.Header - res.Err = err - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/bulk/results.go b/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/bulk/results.go deleted file mode 100644 index fddc125ac6..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/bulk/results.go +++ /dev/null @@ -1,28 +0,0 @@ -package bulk - -import ( - "github.com/rackspace/gophercloud" - - "github.com/mitchellh/mapstructure" -) - -// DeleteResult represents the result of a bulk delete operation. -type DeleteResult struct { - gophercloud.Result -} - -// DeleteRespBody is the form of the response body returned by a bulk delete request. -type DeleteRespBody struct { - NumberNotFound int `mapstructure:"Number Not Found"` - ResponseStatus string `mapstructure:"Response Status"` - Errors []string `mapstructure:"Errors"` - NumberDeleted int `mapstructure:"Number Deleted"` - ResponseBody string `mapstructure:"Response Body"` -} - -// ExtractBody will extract the body returned by the bulk extract request. -func (dr DeleteResult) ExtractBody() (DeleteRespBody, error) { - var resp DeleteRespBody - err := mapstructure.Decode(dr.Body, &resp) - return resp, err -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/bulk/urls.go b/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/bulk/urls.go deleted file mode 100644 index 2e112033be..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/bulk/urls.go +++ /dev/null @@ -1,11 +0,0 @@ -package bulk - -import "github.com/rackspace/gophercloud" - -func deleteURL(c *gophercloud.ServiceClient) string { - return c.Endpoint + "?bulk-delete" -} - -func extractURL(c *gophercloud.ServiceClient, ext string) string { - return c.Endpoint + "?extract-archive=" + ext -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers/delegate.go deleted file mode 100644 index 89adb83965..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers/delegate.go +++ /dev/null @@ -1,38 +0,0 @@ -package cdncontainers - -import ( - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers" - "github.com/rackspace/gophercloud/pagination" -) - -// ExtractNames interprets a page of List results when just the container -// names are requested. -func ExtractNames(page pagination.Page) ([]string, error) { - return os.ExtractNames(page) -} - -// ListOpts are options for listing Rackspace CDN containers. -type ListOpts struct { - EndMarker string `q:"end_marker"` - Format string `q:"format"` - Limit int `q:"limit"` - Marker string `q:"marker"` -} - -// ToContainerListParams formats a ListOpts into a query string and boolean -// representing whether to list complete information for each container. -func (opts ListOpts) ToContainerListParams() (bool, string, error) { - q, err := gophercloud.BuildQueryString(opts) - if err != nil { - return false, "", err - } - return false, q.String(), nil -} - -// List is a function that retrieves containers associated with the account as -// well as account metadata. It returns a pager which can be iterated with the -// EachPage function. -func List(c *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager { - return os.List(c, opts) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers/doc.go deleted file mode 100644 index 7b0930eeea..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package cdncontainers provides information and interaction with the CDN -// Container API resource for the Rackspace Cloud Files service. -package cdncontainers diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers/requests.go b/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers/requests.go deleted file mode 100644 index 8e4abbe436..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers/requests.go +++ /dev/null @@ -1,155 +0,0 @@ -package cdncontainers - -import ( - "strconv" - - "github.com/rackspace/gophercloud" -) - -// EnableOptsBuilder allows extensions to add additional parameters to the Enable -// request. -type EnableOptsBuilder interface { - ToCDNContainerEnableMap() (map[string]string, error) -} - -// EnableOpts is a structure that holds options for enabling a CDN container. -type EnableOpts struct { - // CDNEnabled indicates whether or not the container is CDN enabled. Set to - // `true` to enable the container. Note that changing this setting from true - // to false will disable the container in the CDN but only after the TTL has - // expired. - CDNEnabled bool `h:"X-Cdn-Enabled"` - // TTL is the time-to-live for the container (in seconds). - TTL int `h:"X-Ttl"` -} - -// ToCDNContainerEnableMap formats an EnableOpts into a map of headers. -func (opts EnableOpts) ToCDNContainerEnableMap() (map[string]string, error) { - h, err := gophercloud.BuildHeaders(opts) - if err != nil { - return nil, err - } - return h, nil -} - -// Enable is a function that enables/disables a CDN container. -func Enable(c *gophercloud.ServiceClient, containerName string, opts EnableOptsBuilder) EnableResult { - var res EnableResult - h := c.AuthenticatedHeaders() - - if opts != nil { - headers, err := opts.ToCDNContainerEnableMap() - if err != nil { - res.Err = err - return res - } - - for k, v := range headers { - h[k] = v - } - } - - resp, err := c.Request("PUT", enableURL(c, containerName), gophercloud.RequestOpts{ - MoreHeaders: h, - OkCodes: []int{201, 202, 204}, - }) - res.Header = resp.Header - res.Err = err - return res -} - -// Get is a function that retrieves the metadata of a container. To extract just -// the custom metadata, pass the GetResult response to the ExtractMetadata -// function. -func Get(c *gophercloud.ServiceClient, containerName string) GetResult { - var res GetResult - resp, err := c.Request("HEAD", getURL(c, containerName), gophercloud.RequestOpts{ - OkCodes: []int{200, 204}, - }) - res.Header = resp.Header - res.Err = err - return res -} - -// State is the state of an option. It is a pointer to a boolean to enable checking for -// a zero-value of nil instead of false, which is a valid option. -type State *bool - -var ( - iTrue = true - iFalse = false - - // Enabled is used for a true value for options in request bodies. - Enabled State = &iTrue - // Disabled is used for a false value for options in request bodies. - Disabled State = &iFalse -) - -// UpdateOptsBuilder allows extensions to add additional parameters to the -// Update request. -type UpdateOptsBuilder interface { - ToContainerUpdateMap() (map[string]string, error) -} - -// UpdateOpts is a structure that holds parameters for updating, creating, or -// deleting a container's metadata. -type UpdateOpts struct { - // Whether or not to CDN-enable a container. Prefer using XCDNEnabled, which - // is of type *bool underneath. - // TODO v2.0: change type to Enabled/Disabled (*bool) - CDNEnabled bool `h:"X-Cdn-Enabled"` - // Whether or not to enable log retention. Prefer using XLogRetention, which - // is of type *bool underneath. - // TODO v2.0: change type to Enabled/Disabled (*bool) - LogRetention bool `h:"X-Log-Retention"` - XCDNEnabled *bool - XLogRetention *bool - TTL int `h:"X-Ttl"` -} - -// ToContainerUpdateMap formats a CreateOpts into a map of headers. -func (opts UpdateOpts) ToContainerUpdateMap() (map[string]string, error) { - h, err := gophercloud.BuildHeaders(opts) - if err != nil { - return nil, err - } - h["X-Cdn-Enabled"] = strconv.FormatBool(opts.CDNEnabled) - h["X-Log-Retention"] = strconv.FormatBool(opts.LogRetention) - - if opts.XCDNEnabled != nil { - h["X-Cdn-Enabled"] = strconv.FormatBool(*opts.XCDNEnabled) - } - - if opts.XLogRetention != nil { - h["X-Log-Retention"] = strconv.FormatBool(*opts.XLogRetention) - } - - return h, nil -} - -// Update is a function that creates, updates, or deletes a container's -// metadata. -func Update(c *gophercloud.ServiceClient, containerName string, opts UpdateOptsBuilder) UpdateResult { - var res UpdateResult - h := c.AuthenticatedHeaders() - - if opts != nil { - headers, err := opts.ToContainerUpdateMap() - if err != nil { - res.Err = err - return res - } - - for k, v := range headers { - h[k] = v - } - } - - resp, err := c.Request("POST", updateURL(c, containerName), gophercloud.RequestOpts{ - MoreHeaders: h, - OkCodes: []int{202, 204}, - }) - res.Header = resp.Header - res.Err = err - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers/results.go b/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers/results.go deleted file mode 100644 index cb0ad3096c..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers/results.go +++ /dev/null @@ -1,149 +0,0 @@ -package cdncontainers - -import ( - "strings" - "time" - - "github.com/rackspace/gophercloud" -) - -// EnableHeader represents the headers returned in the response from an Enable request. -type EnableHeader struct { - CDNIosURI string `mapstructure:"X-Cdn-Ios-Uri"` - CDNSslURI string `mapstructure:"X-Cdn-Ssl-Uri"` - CDNStreamingURI string `mapstructure:"X-Cdn-Streaming-Uri"` - CDNUri string `mapstructure:"X-Cdn-Uri"` - ContentLength int `mapstructure:"Content-Length"` - ContentType string `mapstructure:"Content-Type"` - Date time.Time `mapstructure:"-"` - TransID string `mapstructure:"X-Trans-Id"` -} - -// EnableResult represents the result of an Enable operation. -type EnableResult struct { - gophercloud.HeaderResult -} - -// Extract will return extract an EnableHeader from the response to an Enable -// request. To obtain a map of headers, call the ExtractHeader method on the EnableResult. -func (er EnableResult) Extract() (EnableHeader, error) { - var eh EnableHeader - if er.Err != nil { - return eh, er.Err - } - - if err := gophercloud.DecodeHeader(er.Header, &eh); err != nil { - return eh, err - } - - if date, ok := er.Header["Date"]; ok && len(date) > 0 { - t, err := time.Parse(time.RFC1123, er.Header["Date"][0]) - if err != nil { - return eh, err - } - eh.Date = t - } - - return eh, nil -} - -// GetHeader represents the headers returned in the response from a Get request. -type GetHeader struct { - CDNEnabled bool `mapstructure:"X-Cdn-Enabled"` - CDNIosURI string `mapstructure:"X-Cdn-Ios-Uri"` - CDNSslURI string `mapstructure:"X-Cdn-Ssl-Uri"` - CDNStreamingURI string `mapstructure:"X-Cdn-Streaming-Uri"` - CDNUri string `mapstructure:"X-Cdn-Uri"` - ContentLength int `mapstructure:"Content-Length"` - ContentType string `mapstructure:"Content-Type"` - Date time.Time `mapstructure:"-"` - LogRetention bool `mapstructure:"X-Log-Retention"` - TransID string `mapstructure:"X-Trans-Id"` - TTL int `mapstructure:"X-Ttl"` -} - -// GetResult represents the result of a Get operation. -type GetResult struct { - gophercloud.HeaderResult -} - -// Extract will return a struct of headers returned from a call to Get. To obtain -// a map of headers, call the ExtractHeader method on the GetResult. -func (gr GetResult) Extract() (GetHeader, error) { - var gh GetHeader - if gr.Err != nil { - return gh, gr.Err - } - - if err := gophercloud.DecodeHeader(gr.Header, &gh); err != nil { - return gh, err - } - - if date, ok := gr.Header["Date"]; ok && len(date) > 0 { - t, err := time.Parse(time.RFC1123, gr.Header["Date"][0]) - if err != nil { - return gh, err - } - gh.Date = t - } - - return gh, nil -} - -// ExtractMetadata is a function that takes a GetResult (of type *http.Response) -// and returns the custom metadata associated with the container. -func (gr GetResult) ExtractMetadata() (map[string]string, error) { - if gr.Err != nil { - return nil, gr.Err - } - metadata := make(map[string]string) - for k, v := range gr.Header { - if strings.HasPrefix(k, "X-Container-Meta-") { - key := strings.TrimPrefix(k, "X-Container-Meta-") - metadata[key] = v[0] - } - } - return metadata, nil -} - -// UpdateHeader represents the headers returned in the response from a Update request. -type UpdateHeader struct { - CDNIosURI string `mapstructure:"X-Cdn-Ios-Uri"` - CDNSslURI string `mapstructure:"X-Cdn-Ssl-Uri"` - CDNStreamingURI string `mapstructure:"X-Cdn-Streaming-Uri"` - CDNUri string `mapstructure:"X-Cdn-Uri"` - ContentLength int `mapstructure:"Content-Length"` - ContentType string `mapstructure:"Content-Type"` - Date time.Time `mapstructure:"-"` - TransID string `mapstructure:"X-Trans-Id"` -} - -// UpdateResult represents the result of an update operation. To extract the -// the headers from the HTTP response, you can invoke the 'ExtractHeader' -// method on the result struct. -type UpdateResult struct { - gophercloud.HeaderResult -} - -// Extract will return a struct of headers returned from a call to Update. To obtain -// a map of headers, call the ExtractHeader method on the UpdateResult. -func (ur UpdateResult) Extract() (UpdateHeader, error) { - var uh UpdateHeader - if ur.Err != nil { - return uh, ur.Err - } - - if err := gophercloud.DecodeHeader(ur.Header, &uh); err != nil { - return uh, err - } - - if date, ok := ur.Header["Date"]; ok && len(date) > 0 { - t, err := time.Parse(time.RFC1123, ur.Header["Date"][0]) - if err != nil { - return uh, err - } - uh.Date = t - } - - return uh, nil -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers/urls.go b/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers/urls.go deleted file mode 100644 index 541249a927..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers/urls.go +++ /dev/null @@ -1,15 +0,0 @@ -package cdncontainers - -import "github.com/rackspace/gophercloud" - -func enableURL(c *gophercloud.ServiceClient, containerName string) string { - return c.ServiceURL(containerName) -} - -func getURL(c *gophercloud.ServiceClient, container string) string { - return c.ServiceURL(container) -} - -func updateURL(c *gophercloud.ServiceClient, container string) string { - return getURL(c, container) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdnobjects/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdnobjects/delegate.go deleted file mode 100644 index e9d2ff1d6f..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdnobjects/delegate.go +++ /dev/null @@ -1,11 +0,0 @@ -package cdnobjects - -import ( - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects" -) - -// Delete is a function that deletes an object from the CDN. -func Delete(c *gophercloud.ServiceClient, containerName, objectName string, opts os.DeleteOptsBuilder) os.DeleteResult { - return os.Delete(c, containerName, objectName, nil) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdnobjects/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdnobjects/doc.go deleted file mode 100644 index 90cd5c97ff..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdnobjects/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package cdnobjects provides information and interaction with the CDN -// Object API resource for the Rackspace Cloud Files service. -package cdnobjects diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdnobjects/request.go b/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdnobjects/request.go deleted file mode 100644 index 540e0cd298..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdnobjects/request.go +++ /dev/null @@ -1,15 +0,0 @@ -package cdnobjects - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers" -) - -// CDNURL returns the unique CDN URI for the given container and object. -func CDNURL(c *gophercloud.ServiceClient, containerName, objectName string) (string, error) { - h, err := cdncontainers.Get(c, containerName).Extract() - if err != nil { - return "", err - } - return h.CDNUri + "/" + objectName, nil -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/containers/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/containers/delegate.go deleted file mode 100644 index 77ed002574..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/containers/delegate.go +++ /dev/null @@ -1,93 +0,0 @@ -package containers - -import ( - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers" - "github.com/rackspace/gophercloud/pagination" -) - -// ExtractInfo interprets a page of List results when full container info -// is requested. -func ExtractInfo(page pagination.Page) ([]os.Container, error) { - return os.ExtractInfo(page) -} - -// ExtractNames interprets a page of List results when just the container -// names are requested. -func ExtractNames(page pagination.Page) ([]string, error) { - return os.ExtractNames(page) -} - -// List is a function that retrieves containers associated with the account as -// well as account metadata. It returns a pager which can be iterated with the -// EachPage function. -func List(c *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager { - return os.List(c, opts) -} - -// CreateOpts is a structure that holds parameters for creating a container. -type CreateOpts struct { - Metadata map[string]string - ContainerRead string `h:"X-Container-Read"` - ContainerWrite string `h:"X-Container-Write"` - VersionsLocation string `h:"X-Versions-Location"` -} - -// ToContainerCreateMap formats a CreateOpts into a map of headers. -func (opts CreateOpts) ToContainerCreateMap() (map[string]string, error) { - h, err := gophercloud.BuildHeaders(opts) - if err != nil { - return nil, err - } - for k, v := range opts.Metadata { - h["X-Container-Meta-"+k] = v - } - return h, nil -} - -// Create is a function that creates a new container. -func Create(c *gophercloud.ServiceClient, containerName string, opts os.CreateOptsBuilder) os.CreateResult { - return os.Create(c, containerName, opts) -} - -// Delete is a function that deletes a container. -func Delete(c *gophercloud.ServiceClient, containerName string) os.DeleteResult { - return os.Delete(c, containerName) -} - -// UpdateOpts is a structure that holds parameters for updating or creating a -// container's metadata. -type UpdateOpts struct { - Metadata map[string]string - ContainerRead string `h:"X-Container-Read"` - ContainerWrite string `h:"X-Container-Write"` - ContentType string `h:"Content-Type"` - DetectContentType bool `h:"X-Detect-Content-Type"` - RemoveVersionsLocation string `h:"X-Remove-Versions-Location"` - VersionsLocation string `h:"X-Versions-Location"` -} - -// ToContainerUpdateMap formats a CreateOpts into a map of headers. -func (opts UpdateOpts) ToContainerUpdateMap() (map[string]string, error) { - h, err := gophercloud.BuildHeaders(opts) - if err != nil { - return nil, err - } - for k, v := range opts.Metadata { - h["X-Container-Meta-"+k] = v - } - return h, nil -} - -// Update is a function that creates, updates, or deletes a container's -// metadata. -func Update(c *gophercloud.ServiceClient, containerName string, opts os.UpdateOptsBuilder) os.UpdateResult { - return os.Update(c, containerName, opts) -} - -// Get is a function that retrieves the metadata of a container. To extract just -// the custom metadata, pass the GetResult response to the ExtractMetadata -// function. -func Get(c *gophercloud.ServiceClient, containerName string) os.GetResult { - return os.Get(c, containerName) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/containers/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/containers/doc.go deleted file mode 100644 index d132a07382..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/containers/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package containers provides information and interaction with the Container -// API resource for the Rackspace Cloud Files service. -package containers diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/objects/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/objects/delegate.go deleted file mode 100644 index 028d66a0ab..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/objects/delegate.go +++ /dev/null @@ -1,94 +0,0 @@ -package objects - -import ( - "io" - - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects" - "github.com/rackspace/gophercloud/pagination" -) - -// ExtractInfo is a function that takes a page of objects and returns their full information. -func ExtractInfo(page pagination.Page) ([]os.Object, error) { - return os.ExtractInfo(page) -} - -// ExtractNames is a function that takes a page of objects and returns only their names. -func ExtractNames(page pagination.Page) ([]string, error) { - return os.ExtractNames(page) -} - -// List is a function that retrieves objects in the container as -// well as container metadata. It returns a pager which can be iterated with the -// EachPage function. -func List(c *gophercloud.ServiceClient, containerName string, opts os.ListOptsBuilder) pagination.Pager { - return os.List(c, containerName, opts) -} - -// Download is a function that retrieves the content and metadata for an object. -// To extract just the content, pass the DownloadResult response to the -// ExtractContent function. -func Download(c *gophercloud.ServiceClient, containerName, objectName string, opts os.DownloadOptsBuilder) os.DownloadResult { - return os.Download(c, containerName, objectName, opts) -} - -// Create is a function that creates a new object or replaces an existing object. -func Create(c *gophercloud.ServiceClient, containerName, objectName string, content io.Reader, opts os.CreateOptsBuilder) os.CreateResult { - return os.Create(c, containerName, objectName, content, opts) -} - -// CopyOpts is a structure that holds parameters for copying one object to -// another. -type CopyOpts struct { - Metadata map[string]string - ContentDisposition string `h:"Content-Disposition"` - ContentEncoding string `h:"Content-Encoding"` - ContentLength int `h:"Content-Length"` - ContentType string `h:"Content-Type"` - CopyFrom string `h:"X-Copy_From"` - Destination string `h:"Destination"` - DetectContentType bool `h:"X-Detect-Content-Type"` -} - -// ToObjectCopyMap formats a CopyOpts into a map of headers. -func (opts CopyOpts) ToObjectCopyMap() (map[string]string, error) { - h, err := gophercloud.BuildHeaders(opts) - if err != nil { - return nil, err - } - for k, v := range opts.Metadata { - h["X-Object-Meta-"+k] = v - } - // `Content-Length` is required and a value of "0" is acceptable, but calling `gophercloud.BuildHeaders` - // will remove the `Content-Length` header if it's set to 0 (or equivalently not set). This will add - // the header if it's not already set. - if _, ok := h["Content-Length"]; !ok { - h["Content-Length"] = "0" - } - return h, nil -} - -// Copy is a function that copies one object to another. -func Copy(c *gophercloud.ServiceClient, containerName, objectName string, opts os.CopyOptsBuilder) os.CopyResult { - return os.Copy(c, containerName, objectName, opts) -} - -// Delete is a function that deletes an object. -func Delete(c *gophercloud.ServiceClient, containerName, objectName string, opts os.DeleteOptsBuilder) os.DeleteResult { - return os.Delete(c, containerName, objectName, opts) -} - -// Get is a function that retrieves the metadata of an object. To extract just the custom -// metadata, pass the GetResult response to the ExtractMetadata function. -func Get(c *gophercloud.ServiceClient, containerName, objectName string, opts os.GetOptsBuilder) os.GetResult { - return os.Get(c, containerName, objectName, opts) -} - -// Update is a function that creates, updates, or deletes an object's metadata. -func Update(c *gophercloud.ServiceClient, containerName, objectName string, opts os.UpdateOptsBuilder) os.UpdateResult { - return os.Update(c, containerName, objectName, opts) -} - -func CreateTempURL(c *gophercloud.ServiceClient, containerName, objectName string, opts os.CreateTempURLOpts) (string, error) { - return os.CreateTempURL(c, containerName, objectName, opts) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/objects/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/objects/doc.go deleted file mode 100644 index 781984bee2..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/objectstorage/v1/objects/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package objects provides information and interaction with the Object -// API resource for the Rackspace Cloud Files service. -package objects diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/buildinfo/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/buildinfo/delegate.go deleted file mode 100644 index c834e5c7d3..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/buildinfo/delegate.go +++ /dev/null @@ -1,11 +0,0 @@ -package buildinfo - -import ( - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/orchestration/v1/buildinfo" -) - -// Get retreives build info data for the Heat deployment. -func Get(c *gophercloud.ServiceClient) os.GetResult { - return os.Get(c) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/buildinfo/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/buildinfo/doc.go deleted file mode 100644 index 183e8dfa76..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/buildinfo/doc.go +++ /dev/null @@ -1,2 +0,0 @@ -// Package buildinfo provides build information about heat deployments. -package buildinfo diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stackevents/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stackevents/delegate.go deleted file mode 100644 index 08675deac7..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stackevents/delegate.go +++ /dev/null @@ -1,27 +0,0 @@ -package stackevents - -import ( - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/orchestration/v1/stackevents" - "github.com/rackspace/gophercloud/pagination" -) - -// Find retreives stack events for the given stack name. -func Find(c *gophercloud.ServiceClient, stackName string) os.FindResult { - return os.Find(c, stackName) -} - -// List makes a request against the API to list resources for the given stack. -func List(c *gophercloud.ServiceClient, stackName, stackID string, opts os.ListOptsBuilder) pagination.Pager { - return os.List(c, stackName, stackID, opts) -} - -// ListResourceEvents makes a request against the API to list resources for the given stack. -func ListResourceEvents(c *gophercloud.ServiceClient, stackName, stackID, resourceName string, opts os.ListResourceEventsOptsBuilder) pagination.Pager { - return os.ListResourceEvents(c, stackName, stackID, resourceName, opts) -} - -// Get retreives data for the given stack resource. -func Get(c *gophercloud.ServiceClient, stackName, stackID, resourceName, eventID string) os.GetResult { - return os.Get(c, stackName, stackID, resourceName, eventID) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stackevents/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stackevents/doc.go deleted file mode 100644 index dfd6ef6605..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stackevents/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package stackevents provides operations for finding, listing, and retrieving -// stack events. -package stackevents diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stackresources/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stackresources/delegate.go deleted file mode 100644 index cb7be28b78..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stackresources/delegate.go +++ /dev/null @@ -1,42 +0,0 @@ -package stackresources - -import ( - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/orchestration/v1/stackresources" - "github.com/rackspace/gophercloud/pagination" -) - -// Find retreives stack resources for the given stack name. -func Find(c *gophercloud.ServiceClient, stackName string) os.FindResult { - return os.Find(c, stackName) -} - -// List makes a request against the API to list resources for the given stack. -func List(c *gophercloud.ServiceClient, stackName, stackID string, opts os.ListOptsBuilder) pagination.Pager { - return os.List(c, stackName, stackID, opts) -} - -// Get retreives data for the given stack resource. -func Get(c *gophercloud.ServiceClient, stackName, stackID, resourceName string) os.GetResult { - return os.Get(c, stackName, stackID, resourceName) -} - -// Metadata retreives the metadata for the given stack resource. -func Metadata(c *gophercloud.ServiceClient, stackName, stackID, resourceName string) os.MetadataResult { - return os.Metadata(c, stackName, stackID, resourceName) -} - -// ListTypes makes a request against the API to list resource types. -func ListTypes(c *gophercloud.ServiceClient) pagination.Pager { - return os.ListTypes(c) -} - -// Schema retreives the schema for the given resource type. -func Schema(c *gophercloud.ServiceClient, resourceType string) os.SchemaResult { - return os.Schema(c, resourceType) -} - -// Template retreives the template representation for the given resource type. -func Template(c *gophercloud.ServiceClient, resourceType string) os.TemplateResult { - return os.Template(c, resourceType) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stackresources/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stackresources/doc.go deleted file mode 100644 index e4f8b08dcc..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stackresources/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -// Package stackresources provides operations for working with stack resources. -// A resource is a template artifact that represents some component of your -// desired architecture (a Cloud Server, a group of scaled Cloud Servers, a load -// balancer, some configuration management system, and so forth). -package stackresources diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stacks/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stacks/delegate.go deleted file mode 100644 index f7e387f8f7..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stacks/delegate.go +++ /dev/null @@ -1,49 +0,0 @@ -package stacks - -import ( - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks" - "github.com/rackspace/gophercloud/pagination" -) - -// Create accepts an os.CreateOpts struct and creates a new stack using the values -// provided. -func Create(c *gophercloud.ServiceClient, opts os.CreateOptsBuilder) os.CreateResult { - return os.Create(c, opts) -} - -// Adopt accepts an os.AdoptOpts struct and creates a new stack from existing stack -// resources using the values provided. -func Adopt(c *gophercloud.ServiceClient, opts os.AdoptOptsBuilder) os.AdoptResult { - return os.Adopt(c, opts) -} - -// List accepts an os.ListOpts struct and lists stacks based on the options provided. -func List(c *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager { - return os.List(c, opts) -} - -// Get retreives a stack based on the stack name and stack ID. -func Get(c *gophercloud.ServiceClient, stackName, stackID string) os.GetResult { - return os.Get(c, stackName, stackID) -} - -// Update accepts an os.UpdateOpts struct and updates a stack based on the options provided. -func Update(c *gophercloud.ServiceClient, stackName, stackID string, opts os.UpdateOptsBuilder) os.UpdateResult { - return os.Update(c, stackName, stackID, opts) -} - -// Delete deletes a stack based on the stack name and stack ID provided. -func Delete(c *gophercloud.ServiceClient, stackName, stackID string) os.DeleteResult { - return os.Delete(c, stackName, stackID) -} - -// Preview provides a preview of a stack based on the options provided. -func Preview(c *gophercloud.ServiceClient, opts os.PreviewOptsBuilder) os.PreviewResult { - return os.Preview(c, opts) -} - -// Abandon abandons a stack, keeping the resources available. -func Abandon(c *gophercloud.ServiceClient, stackName, stackID string) os.AbandonResult { - return os.Abandon(c, stackName, stackID) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stacks/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stacks/doc.go deleted file mode 100644 index 19231b5137..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stacks/doc.go +++ /dev/null @@ -1,8 +0,0 @@ -// Package stacks provides operation for working with Heat stacks. A stack is a -// group of resources (servers, load balancers, databases, and so forth) -// combined to fulfill a useful purpose. Based on a template, Heat orchestration -// engine creates an instantiated set of resources (a stack) to run the -// application framework or component specified (in the template). A stack is a -// running instance of a template. The result of creating a stack is a deployment -// of the application framework or component. -package stacks diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stacks/fixtures.go b/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stacks/fixtures.go deleted file mode 100644 index c9afeb156f..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stacks/fixtures.go +++ /dev/null @@ -1,32 +0,0 @@ -package stacks - -import ( - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/orchestration/v1/stacks" -) - -// CreateExpected represents the expected object from a Create request. -var CreateExpected = &os.CreatedStack{ - ID: "b663e18a-4767-4cdf-9db5-9c8cc13cc38a", - Links: []gophercloud.Link{ - gophercloud.Link{ - Href: "https://ord.orchestration.api.rackspacecloud.com/v1/864477/stacks/stackcreated/b663e18a-4767-4cdf-9db5-9c8cc13cc38a", - Rel: "self", - }, - }, -} - -// CreateOutput represents the response body from a Create request. -const CreateOutput = ` -{ - "stack": { - "id": "b663e18a-4767-4cdf-9db5-9c8cc13cc38a", - "links": [ - { - "href": "https://ord.orchestration.api.rackspacecloud.com/v1/864477/stacks/stackcreated/b663e18a-4767-4cdf-9db5-9c8cc13cc38a", - "rel": "self" - } - ] - } -} -` diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stacktemplates/delegate.go b/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stacktemplates/delegate.go deleted file mode 100644 index 3b5d46e1c9..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stacktemplates/delegate.go +++ /dev/null @@ -1,16 +0,0 @@ -package stacktemplates - -import ( - "github.com/rackspace/gophercloud" - os "github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates" -) - -// Get retreives data for the given stack template. -func Get(c *gophercloud.ServiceClient, stackName, stackID string) os.GetResult { - return os.Get(c, stackName, stackID) -} - -// Validate validates the given stack template. -func Validate(c *gophercloud.ServiceClient, opts os.ValidateOptsBuilder) os.ValidateResult { - return os.Validate(c, opts) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stacktemplates/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stacktemplates/doc.go deleted file mode 100644 index 5af0bd62a1..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/orchestration/v1/stacktemplates/doc.go +++ /dev/null @@ -1,8 +0,0 @@ -// Package stacktemplates provides operations for working with Heat templates. -// A Cloud Orchestration template is a portable file, written in a user-readable -// language, that describes how a set of resources should be assembled and what -// software should be installed in order to produce a working stack. The template -// specifies what resources should be used, what attributes can be set, and other -// parameters that are critical to the successful, repeatable automation of a -// specific application stack. -package stacktemplates diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/cloudnetworks/requests.go b/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/cloudnetworks/requests.go deleted file mode 100644 index 58843030ae..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/cloudnetworks/requests.go +++ /dev/null @@ -1,24 +0,0 @@ -package cloudnetworks - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// List returns all cloud networks that are associated with RackConnect. The ID -// returned for each network is the same as the ID returned by the networks package. -func List(c *gophercloud.ServiceClient) pagination.Pager { - url := listURL(c) - createPage := func(r pagination.PageResult) pagination.Page { - return CloudNetworkPage{pagination.SinglePageBase(r)} - } - return pagination.NewPager(c, url, createPage) -} - -// Get retrieves a specific cloud network (that is associated with RackConnect) -// based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) GetResult { - var res GetResult - _, res.Err = c.Get(getURL(c, id), &res.Body, nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/cloudnetworks/results.go b/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/cloudnetworks/results.go deleted file mode 100644 index f554a0d75b..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/cloudnetworks/results.go +++ /dev/null @@ -1,113 +0,0 @@ -package cloudnetworks - -import ( - "fmt" - "reflect" - "time" - - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// CloudNetwork represents a network associated with a RackConnect configuration. -type CloudNetwork struct { - // Specifies the ID of the newtork. - ID string `mapstructure:"id"` - // Specifies the user-provided name of the network. - Name string `mapstructure:"name"` - // Specifies the IP range for this network. - CIDR string `mapstructure:"cidr"` - // Specifies the time the network was created. - CreatedAt time.Time `mapstructure:"-"` - // Specifies the time the network was last updated. - UpdatedAt time.Time `mapstructure:"-"` -} - -// CloudNetworkPage is the page returned by a pager when traversing over a -// collection of CloudNetworks. -type CloudNetworkPage struct { - pagination.SinglePageBase -} - -// IsEmpty returns true if a CloudNetworkPage contains no CloudNetworks. -func (r CloudNetworkPage) IsEmpty() (bool, error) { - cns, err := ExtractCloudNetworks(r) - if err != nil { - return true, err - } - return len(cns) == 0, nil -} - -// ExtractCloudNetworks extracts and returns CloudNetworks. It is used while iterating over -// a cloudnetworks.List call. -func ExtractCloudNetworks(page pagination.Page) ([]CloudNetwork, error) { - var res []CloudNetwork - casted := page.(CloudNetworkPage).Body - err := mapstructure.Decode(casted, &res) - - var rawNets []interface{} - switch casted.(type) { - case interface{}: - rawNets = casted.([]interface{}) - default: - return res, fmt.Errorf("Unknown type: %v", reflect.TypeOf(casted)) - } - - for i := range rawNets { - thisNet := (rawNets[i]).(map[string]interface{}) - - if t, ok := thisNet["created"].(string); ok && t != "" { - creationTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return res, err - } - res[i].CreatedAt = creationTime - } - - if t, ok := thisNet["updated"].(string); ok && t != "" { - updatedTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return res, err - } - res[i].UpdatedAt = updatedTime - } - } - - return res, err -} - -// GetResult represents the result of a Get operation. -type GetResult struct { - gophercloud.Result -} - -// Extract is a function that extracts a CloudNetwork from a GetResult. -func (r GetResult) Extract() (*CloudNetwork, error) { - if r.Err != nil { - return nil, r.Err - } - var res CloudNetwork - - err := mapstructure.Decode(r.Body, &res) - - b := r.Body.(map[string]interface{}) - - if date, ok := b["created"]; ok && date != nil { - t, err := time.Parse(time.RFC3339, date.(string)) - if err != nil { - return nil, err - } - res.CreatedAt = t - } - - if date, ok := b["updated"]; ok && date != nil { - t, err := time.Parse(time.RFC3339, date.(string)) - if err != nil { - return nil, err - } - res.UpdatedAt = t - } - - return &res, err -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/cloudnetworks/urls.go b/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/cloudnetworks/urls.go deleted file mode 100644 index bd6b098dad..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/cloudnetworks/urls.go +++ /dev/null @@ -1,11 +0,0 @@ -package cloudnetworks - -import "github.com/rackspace/gophercloud" - -func listURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL("cloud_networks") -} - -func getURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL("cloud_networks", id) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/doc.go deleted file mode 100644 index 3a8279e109..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -// Package rackconnect allows Rackspace cloud accounts to leverage version 3 of -// RackConnect, Rackspace's hybrid connectivity solution connecting dedicated -// and cloud servers. -package rackconnect diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/lbpools/doc.go b/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/lbpools/doc.go deleted file mode 100644 index f4319b8ff3..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/lbpools/doc.go +++ /dev/null @@ -1,14 +0,0 @@ -// Package lbpools provides access to load balancer pools associated with a -// RackConnect configuration. Load Balancer Pools must be configured in advance -// by your Network Security team to be eligible for use with RackConnect. -// If you do not see a pool that you expect to see, contact your Support team -// for further assistance. The Load Balancer Pool id returned by these calls is -// automatically generated by the RackConnect automation and will remain constant -// unless the Load Balancer Pool is renamed on your hardware load balancer. -// All Load Balancer Pools will currently return a status of ACTIVE. Future -// features may introduce additional statuses. -// Node status values are ADDING, ACTIVE, REMOVING, ADD_FAILED, and REMOVE_FAILED. -// The cloud_servers node count will only include Cloud Servers from the specified -// cloud account. Any dedicated servers or cloud servers from another cloud account -// on the same RackConnect Configuration will be counted as external nodes. -package lbpools diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/lbpools/requests.go b/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/lbpools/requests.go deleted file mode 100644 index c300c56c1e..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/lbpools/requests.go +++ /dev/null @@ -1,146 +0,0 @@ -package lbpools - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// List returns all load balancer pools that are associated with RackConnect. -func List(c *gophercloud.ServiceClient) pagination.Pager { - url := listURL(c) - createPage := func(r pagination.PageResult) pagination.Page { - return PoolPage{pagination.SinglePageBase(r)} - } - return pagination.NewPager(c, url, createPage) -} - -// Get retrieves a specific load balancer pool (that is associated with RackConnect) -// based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) GetResult { - var res GetResult - _, res.Err = c.Get(getURL(c, id), &res.Body, nil) - return res -} - -// ListNodes returns all load balancer pool nodes that are associated with RackConnect -// for the given LB pool ID. -func ListNodes(c *gophercloud.ServiceClient, id string) pagination.Pager { - url := listNodesURL(c, id) - createPage := func(r pagination.PageResult) pagination.Page { - return NodePage{pagination.SinglePageBase(r)} - } - return pagination.NewPager(c, url, createPage) -} - -// CreateNode adds the cloud server with the given serverID to the load balancer -// pool with the given poolID. -func CreateNode(c *gophercloud.ServiceClient, poolID, serverID string) CreateNodeResult { - var res CreateNodeResult - reqBody := map[string]interface{}{ - "cloud_server": map[string]string{ - "id": serverID, - }, - } - _, res.Err = c.Post(createNodeURL(c, poolID), reqBody, &res.Body, nil) - return res -} - -// ListNodesDetails returns all load balancer pool nodes that are associated with RackConnect -// for the given LB pool ID with all their details. -func ListNodesDetails(c *gophercloud.ServiceClient, id string) pagination.Pager { - url := listNodesDetailsURL(c, id) - createPage := func(r pagination.PageResult) pagination.Page { - return NodeDetailsPage{pagination.SinglePageBase(r)} - } - return pagination.NewPager(c, url, createPage) -} - -// GetNode retrieves a specific LB pool node (that is associated with RackConnect) -// based on its unique ID and the LB pool's unique ID. -func GetNode(c *gophercloud.ServiceClient, poolID, nodeID string) GetNodeResult { - var res GetNodeResult - _, res.Err = c.Get(nodeURL(c, poolID, nodeID), &res.Body, nil) - return res -} - -// DeleteNode removes the node with the given nodeID from the LB pool with the -// given poolID. -func DeleteNode(c *gophercloud.ServiceClient, poolID, nodeID string) DeleteNodeResult { - var res DeleteNodeResult - _, res.Err = c.Delete(deleteNodeURL(c, poolID, nodeID), nil) - return res -} - -// GetNodeDetails retrieves a specific LB pool node's details based on its unique -// ID and the LB pool's unique ID. -func GetNodeDetails(c *gophercloud.ServiceClient, poolID, nodeID string) GetNodeDetailsResult { - var res GetNodeDetailsResult - _, res.Err = c.Get(nodeDetailsURL(c, poolID, nodeID), &res.Body, nil) - return res -} - -// NodeOpts are options for bulk adding/deleting nodes to LB pools. -type NodeOpts struct { - ServerID string - PoolID string -} - -// NodesOpts are a slice of NodeOpts, passed as options for bulk operations. -type NodesOpts []NodeOpts - -// ToLBPoolCreateNodesMap serializes a NodesOpts into a map to send in the request. -func (o NodesOpts) ToLBPoolCreateNodesMap() ([]map[string]interface{}, error) { - m := make([]map[string]interface{}, len(o)) - for i := range o { - m[i] = map[string]interface{}{ - "cloud_server": map[string]string{ - "id": o[i].ServerID, - }, - "load_balancer_pool": map[string]string{ - "id": o[i].PoolID, - }, - } - } - return m, nil -} - -// CreateNodes adds the cloud servers with the given serverIDs to the corresponding -// load balancer pools with the given poolIDs. -func CreateNodes(c *gophercloud.ServiceClient, opts NodesOpts) CreateNodesResult { - var res CreateNodesResult - reqBody, err := opts.ToLBPoolCreateNodesMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = c.Post(createNodesURL(c), reqBody, &res.Body, nil) - return res -} - -// DeleteNodes removes the cloud servers with the given serverIDs to the corresponding -// load balancer pools with the given poolIDs. -func DeleteNodes(c *gophercloud.ServiceClient, opts NodesOpts) DeleteNodesResult { - var res DeleteNodesResult - reqBody, err := opts.ToLBPoolCreateNodesMap() - if err != nil { - res.Err = err - return res - } - - _, res.Err = c.Request("DELETE", createNodesURL(c), gophercloud.RequestOpts{ - JSONBody: &reqBody, - OkCodes: []int{204}, - }) - return res -} - -// ListNodesDetailsForServer is similar to ListNodesDetails but only returns nodes -// for the given serverID. -func ListNodesDetailsForServer(c *gophercloud.ServiceClient, serverID string) pagination.Pager { - url := listNodesForServerURL(c, serverID) - createPage := func(r pagination.PageResult) pagination.Page { - return NodeDetailsForServerPage{pagination.SinglePageBase(r)} - } - return pagination.NewPager(c, url, createPage) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/lbpools/results.go b/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/lbpools/results.go deleted file mode 100644 index e5e914b1e2..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/lbpools/results.go +++ /dev/null @@ -1,505 +0,0 @@ -package lbpools - -import ( - "fmt" - "reflect" - "time" - - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// Pool represents a load balancer pool associated with a RackConnect configuration. -type Pool struct { - // The unique ID of the load balancer pool. - ID string `mapstructure:"id"` - // The name of the load balancer pool. - Name string `mapstructure:"name"` - // The node counts associated witht the load balancer pool. - NodeCounts struct { - // The number of nodes associated with this LB pool for this account. - CloudServers int `mapstructure:"cloud_servers"` - // The number of nodes associated with this LB pool from other accounts. - External int `mapstructure:"external"` - // The total number of nodes associated with this LB pool. - Total int `mapstructure:"total"` - } `mapstructure:"node_counts"` - // The port of the LB pool - Port int `mapstructure:"port"` - // The status of the LB pool - Status string `mapstructure:"status"` - // The details of the status of the LB pool - StatusDetail string `mapstructure:"status_detail"` - // The virtual IP of the LB pool - VirtualIP string `mapstructure:"virtual_ip"` -} - -// PoolPage is the page returned by a pager when traversing over a -// collection of Pools. -type PoolPage struct { - pagination.SinglePageBase -} - -// IsEmpty returns true if a PoolPage contains no Pools. -func (r PoolPage) IsEmpty() (bool, error) { - cns, err := ExtractPools(r) - if err != nil { - return true, err - } - return len(cns) == 0, nil -} - -// ExtractPools extracts and returns Pools. It is used while iterating over -// an lbpools.List call. -func ExtractPools(page pagination.Page) ([]Pool, error) { - var res []Pool - err := mapstructure.Decode(page.(PoolPage).Body, &res) - return res, err -} - -// GetResult represents the result of a Get operation. -type GetResult struct { - gophercloud.Result -} - -// Extract is a function that extracts an LBPool from a GetResult. -func (r GetResult) Extract() (*Pool, error) { - if r.Err != nil { - return nil, r.Err - } - var res Pool - err := mapstructure.Decode(r.Body, &res) - return &res, err -} - -// Node represents a load balancer pool node associated with a RackConnect configuration. -type Node struct { - // The unique ID of the LB node. - ID string `mapstructure:"id"` - // The cloud server (node) of the load balancer pool. - CloudServer struct { - // The cloud server ID. - ID string `mapstructure:"id"` - } `mapstructure:"cloud_server"` - // The load balancer pool. - LoadBalancerPool struct { - // The LB pool ID. - ID string `mapstructure:"id"` - } `mapstructure:"load_balancer_pool"` - // The status of the LB pool. - Status string `mapstructure:"status"` - // The details of the status of the LB pool. - StatusDetail string `mapstructure:"status_detail"` - // The time the LB node was created. - CreatedAt time.Time `mapstructure:"-"` - // The time the LB node was last updated. - UpdatedAt time.Time `mapstructure:"-"` -} - -// NodePage is the page returned by a pager when traversing over a -// collection of Nodes. -type NodePage struct { - pagination.SinglePageBase -} - -// IsEmpty returns true if a NodePage contains no Nodes. -func (r NodePage) IsEmpty() (bool, error) { - n, err := ExtractNodes(r) - if err != nil { - return true, err - } - return len(n) == 0, nil -} - -// ExtractNodes extracts and returns a slice of Nodes. It is used while iterating over -// an lbpools.ListNodes call. -func ExtractNodes(page pagination.Page) ([]Node, error) { - var res []Node - casted := page.(NodePage).Body - err := mapstructure.Decode(casted, &res) - - var rawNodes []interface{} - switch casted.(type) { - case interface{}: - rawNodes = casted.([]interface{}) - default: - return res, fmt.Errorf("Unknown type: %v", reflect.TypeOf(casted)) - } - - for i := range rawNodes { - thisNode := (rawNodes[i]).(map[string]interface{}) - - if t, ok := thisNode["created"].(string); ok && t != "" { - creationTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return res, err - } - res[i].CreatedAt = creationTime - } - - if t, ok := thisNode["updated"].(string); ok && t != "" { - updatedTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return res, err - } - res[i].UpdatedAt = updatedTime - } - } - - return res, err -} - -// NodeResult represents a result that can be extracted as a Node. -type NodeResult struct { - gophercloud.Result -} - -// CreateNodeResult represents the result of an CreateNode operation. -type CreateNodeResult struct { - NodeResult -} - -// GetNodeResult represents the result of an GetNode operation. -type GetNodeResult struct { - NodeResult -} - -// Extract is a function that extracts a Node from a NodeResult. -func (r NodeResult) Extract() (*Node, error) { - if r.Err != nil { - return nil, r.Err - } - var res Node - err := mapstructure.Decode(r.Body, &res) - - b := r.Body.(map[string]interface{}) - - if date, ok := b["created"]; ok && date != nil { - t, err := time.Parse(time.RFC3339, date.(string)) - if err != nil { - return nil, err - } - res.CreatedAt = t - } - - if date, ok := b["updated"]; ok && date != nil { - t, err := time.Parse(time.RFC3339, date.(string)) - if err != nil { - return nil, err - } - res.UpdatedAt = t - } - - return &res, err -} - -// NodeDetails represents a load balancer pool node associated with a RackConnect configuration -// with all its details. -type NodeDetails struct { - // The unique ID of the LB node. - ID string `mapstructure:"id"` - // The cloud server (node) of the load balancer pool. - CloudServer struct { - // The cloud server ID. - ID string `mapstructure:"id"` - // The name of the server. - Name string `mapstructure:"name"` - // The cloud network for the cloud server. - CloudNetwork struct { - // The network ID. - ID string `mapstructure:"id"` - // The network name. - Name string `mapstructure:"name"` - // The network's private IPv4 address. - PrivateIPv4 string `mapstructure:"private_ip_v4"` - // The IP range for the network. - CIDR string `mapstructure:"cidr"` - // The datetime the network was created. - CreatedAt time.Time `mapstructure:"-"` - // The last datetime the network was updated. - UpdatedAt time.Time `mapstructure:"-"` - } `mapstructure:"cloud_network"` - // The datetime the server was created. - CreatedAt time.Time `mapstructure:"-"` - // The datetime the server was last updated. - UpdatedAt time.Time `mapstructure:"-"` - } `mapstructure:"cloud_server"` - // The load balancer pool. - LoadBalancerPool Pool `mapstructure:"load_balancer_pool"` - // The status of the LB pool. - Status string `mapstructure:"status"` - // The details of the status of the LB pool. - StatusDetail string `mapstructure:"status_detail"` - // The time the LB node was created. - CreatedAt time.Time `mapstructure:"-"` - // The time the LB node was last updated. - UpdatedAt time.Time `mapstructure:"-"` -} - -// NodeDetailsPage is the page returned by a pager when traversing over a -// collection of NodeDetails. -type NodeDetailsPage struct { - pagination.SinglePageBase -} - -// IsEmpty returns true if a NodeDetailsPage contains no NodeDetails. -func (r NodeDetailsPage) IsEmpty() (bool, error) { - n, err := ExtractNodesDetails(r) - if err != nil { - return true, err - } - return len(n) == 0, nil -} - -// ExtractNodesDetails extracts and returns a slice of NodeDetails. It is used while iterating over -// an lbpools.ListNodesDetails call. -func ExtractNodesDetails(page pagination.Page) ([]NodeDetails, error) { - var res []NodeDetails - casted := page.(NodeDetailsPage).Body - err := mapstructure.Decode(casted, &res) - - var rawNodesDetails []interface{} - switch casted.(type) { - case interface{}: - rawNodesDetails = casted.([]interface{}) - default: - return res, fmt.Errorf("Unknown type: %v", reflect.TypeOf(casted)) - } - - for i := range rawNodesDetails { - thisNodeDetails := (rawNodesDetails[i]).(map[string]interface{}) - - if t, ok := thisNodeDetails["created"].(string); ok && t != "" { - creationTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return res, err - } - res[i].CreatedAt = creationTime - } - - if t, ok := thisNodeDetails["updated"].(string); ok && t != "" { - updatedTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return res, err - } - res[i].UpdatedAt = updatedTime - } - - if cs, ok := thisNodeDetails["cloud_server"].(map[string]interface{}); ok { - if t, ok := cs["created"].(string); ok && t != "" { - creationTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return res, err - } - res[i].CloudServer.CreatedAt = creationTime - } - if t, ok := cs["updated"].(string); ok && t != "" { - updatedTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return res, err - } - res[i].CloudServer.UpdatedAt = updatedTime - } - if cn, ok := cs["cloud_network"].(map[string]interface{}); ok { - if t, ok := cn["created"].(string); ok && t != "" { - creationTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return res, err - } - res[i].CloudServer.CloudNetwork.CreatedAt = creationTime - } - if t, ok := cn["updated"].(string); ok && t != "" { - updatedTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return res, err - } - res[i].CloudServer.CloudNetwork.UpdatedAt = updatedTime - } - } - } - } - - return res, err -} - -// GetNodeDetailsResult represents the result of an NodeDetails operation. -type GetNodeDetailsResult struct { - gophercloud.Result -} - -// Extract is a function that extracts a NodeDetails from a NodeDetailsResult. -func (r GetNodeDetailsResult) Extract() (*NodeDetails, error) { - if r.Err != nil { - return nil, r.Err - } - var res NodeDetails - err := mapstructure.Decode(r.Body, &res) - - b := r.Body.(map[string]interface{}) - - if date, ok := b["created"]; ok && date != nil { - t, err := time.Parse(time.RFC3339, date.(string)) - if err != nil { - return nil, err - } - res.CreatedAt = t - } - - if date, ok := b["updated"]; ok && date != nil { - t, err := time.Parse(time.RFC3339, date.(string)) - if err != nil { - return nil, err - } - res.UpdatedAt = t - } - - if cs, ok := b["cloud_server"].(map[string]interface{}); ok { - if t, ok := cs["created"].(string); ok && t != "" { - creationTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return &res, err - } - res.CloudServer.CreatedAt = creationTime - } - if t, ok := cs["updated"].(string); ok && t != "" { - updatedTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return &res, err - } - res.CloudServer.UpdatedAt = updatedTime - } - if cn, ok := cs["cloud_network"].(map[string]interface{}); ok { - if t, ok := cn["created"].(string); ok && t != "" { - creationTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return &res, err - } - res.CloudServer.CloudNetwork.CreatedAt = creationTime - } - if t, ok := cn["updated"].(string); ok && t != "" { - updatedTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return &res, err - } - res.CloudServer.CloudNetwork.UpdatedAt = updatedTime - } - } - } - - return &res, err -} - -// DeleteNodeResult represents the result of a DeleteNode operation. -type DeleteNodeResult struct { - gophercloud.ErrResult -} - -// CreateNodesResult represents the result of a CreateNodes operation. -type CreateNodesResult struct { - gophercloud.Result -} - -// Extract is a function that extracts a slice of Nodes from a CreateNodesResult. -func (r CreateNodesResult) Extract() ([]Node, error) { - if r.Err != nil { - return nil, r.Err - } - var res []Node - err := mapstructure.Decode(r.Body, &res) - - b := r.Body.([]interface{}) - for i := range b { - if date, ok := b[i].(map[string]interface{})["created"]; ok && date != nil { - t, err := time.Parse(time.RFC3339, date.(string)) - if err != nil { - return nil, err - } - res[i].CreatedAt = t - } - if date, ok := b[i].(map[string]interface{})["updated"]; ok && date != nil { - t, err := time.Parse(time.RFC3339, date.(string)) - if err != nil { - return nil, err - } - res[i].UpdatedAt = t - } - } - - return res, err -} - -// DeleteNodesResult represents the result of a DeleteNodes operation. -type DeleteNodesResult struct { - gophercloud.ErrResult -} - -// NodeDetailsForServer represents a load balancer pool node associated with a RackConnect configuration -// with all its details for a particular server. -type NodeDetailsForServer struct { - // The unique ID of the LB node. - ID string `mapstructure:"id"` - // The load balancer pool. - LoadBalancerPool Pool `mapstructure:"load_balancer_pool"` - // The status of the LB pool. - Status string `mapstructure:"status"` - // The details of the status of the LB pool. - StatusDetail string `mapstructure:"status_detail"` - // The time the LB node was created. - CreatedAt time.Time `mapstructure:"-"` - // The time the LB node was last updated. - UpdatedAt time.Time `mapstructure:"-"` -} - -// NodeDetailsForServerPage is the page returned by a pager when traversing over a -// collection of NodeDetailsForServer. -type NodeDetailsForServerPage struct { - pagination.SinglePageBase -} - -// IsEmpty returns true if a NodeDetailsForServerPage contains no NodeDetailsForServer. -func (r NodeDetailsForServerPage) IsEmpty() (bool, error) { - n, err := ExtractNodesDetailsForServer(r) - if err != nil { - return true, err - } - return len(n) == 0, nil -} - -// ExtractNodesDetailsForServer extracts and returns a slice of NodeDetailsForServer. It is used while iterating over -// an lbpools.ListNodesDetailsForServer call. -func ExtractNodesDetailsForServer(page pagination.Page) ([]NodeDetailsForServer, error) { - var res []NodeDetailsForServer - casted := page.(NodeDetailsForServerPage).Body - err := mapstructure.Decode(casted, &res) - - var rawNodesDetails []interface{} - switch casted.(type) { - case interface{}: - rawNodesDetails = casted.([]interface{}) - default: - return res, fmt.Errorf("Unknown type: %v", reflect.TypeOf(casted)) - } - - for i := range rawNodesDetails { - thisNodeDetails := (rawNodesDetails[i]).(map[string]interface{}) - - if t, ok := thisNodeDetails["created"].(string); ok && t != "" { - creationTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return res, err - } - res[i].CreatedAt = creationTime - } - - if t, ok := thisNodeDetails["updated"].(string); ok && t != "" { - updatedTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return res, err - } - res[i].UpdatedAt = updatedTime - } - } - - return res, err -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/lbpools/urls.go b/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/lbpools/urls.go deleted file mode 100644 index c238239f61..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/lbpools/urls.go +++ /dev/null @@ -1,49 +0,0 @@ -package lbpools - -import "github.com/rackspace/gophercloud" - -var root = "load_balancer_pools" - -func listURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(root) -} - -func getURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(root, id) -} - -func listNodesURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(root, id, "nodes") -} - -func createNodeURL(c *gophercloud.ServiceClient, id string) string { - return listNodesURL(c, id) -} - -func listNodesDetailsURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(root, id, "nodes", "details") -} - -func nodeURL(c *gophercloud.ServiceClient, poolID, nodeID string) string { - return c.ServiceURL(root, poolID, "nodes", nodeID) -} - -func deleteNodeURL(c *gophercloud.ServiceClient, poolID, nodeID string) string { - return nodeURL(c, poolID, nodeID) -} - -func nodeDetailsURL(c *gophercloud.ServiceClient, poolID, nodeID string) string { - return c.ServiceURL(root, poolID, "nodes", nodeID, "details") -} - -func createNodesURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(root, "nodes") -} - -func deleteNodesURL(c *gophercloud.ServiceClient) string { - return createNodesURL(c) -} - -func listNodesForServerURL(c *gophercloud.ServiceClient, serverID string) string { - return c.ServiceURL(root, "nodes", "details?cloud_server_id="+serverID) -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/publicips/requests.go b/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/publicips/requests.go deleted file mode 100644 index 1164260109..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/publicips/requests.go +++ /dev/null @@ -1,50 +0,0 @@ -package publicips - -import ( - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// List returns all public IPs. -func List(c *gophercloud.ServiceClient) pagination.Pager { - url := listURL(c) - createPage := func(r pagination.PageResult) pagination.Page { - return PublicIPPage{pagination.SinglePageBase(r)} - } - return pagination.NewPager(c, url, createPage) -} - -// Create adds a public IP to the server with the given serverID. -func Create(c *gophercloud.ServiceClient, serverID string) CreateResult { - var res CreateResult - reqBody := map[string]interface{}{ - "cloud_server": map[string]string{ - "id": serverID, - }, - } - _, res.Err = c.Post(createURL(c), reqBody, &res.Body, nil) - return res -} - -// ListForServer returns all public IPs for the server with the given serverID. -func ListForServer(c *gophercloud.ServiceClient, serverID string) pagination.Pager { - url := listForServerURL(c, serverID) - createPage := func(r pagination.PageResult) pagination.Page { - return PublicIPPage{pagination.SinglePageBase(r)} - } - return pagination.NewPager(c, url, createPage) -} - -// Get retrieves the public IP with the given id. -func Get(c *gophercloud.ServiceClient, id string) GetResult { - var res GetResult - _, res.Err = c.Get(getURL(c, id), &res.Body, nil) - return res -} - -// Delete removes the public IP with the given id. -func Delete(c *gophercloud.ServiceClient, id string) DeleteResult { - var res DeleteResult - _, res.Err = c.Delete(deleteURL(c, id), nil) - return res -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/publicips/results.go b/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/publicips/results.go deleted file mode 100644 index 132cf770a0..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/publicips/results.go +++ /dev/null @@ -1,221 +0,0 @@ -package publicips - -import ( - "fmt" - "reflect" - "time" - - "github.com/mitchellh/mapstructure" - "github.com/rackspace/gophercloud" - "github.com/rackspace/gophercloud/pagination" -) - -// PublicIP represents a public IP address. -type PublicIP struct { - // The unique ID of the public IP. - ID string `mapstructure:"id"` - // The IPv4 address of the public IP. - PublicIPv4 string `mapstructure:"public_ip_v4"` - // The cloud server (node) of the public IP. - CloudServer struct { - // The cloud server ID. - ID string `mapstructure:"id"` - // The name of the server. - Name string `mapstructure:"name"` - // The cloud network for the cloud server. - CloudNetwork struct { - // The network ID. - ID string `mapstructure:"id"` - // The network name. - Name string `mapstructure:"name"` - // The network's private IPv4 address. - PrivateIPv4 string `mapstructure:"private_ip_v4"` - // The IP range for the network. - CIDR string `mapstructure:"cidr"` - // The datetime the network was created. - CreatedAt time.Time `mapstructure:"-"` - // The last datetime the network was updated. - UpdatedAt time.Time `mapstructure:"-"` - } `mapstructure:"cloud_network"` - // The datetime the server was created. - CreatedAt time.Time `mapstructure:"-"` - // The datetime the server was last updated. - UpdatedAt time.Time `mapstructure:"-"` - } `mapstructure:"cloud_server"` - // The status of the public IP. - Status string `mapstructure:"status"` - // The details of the status of the public IP. - StatusDetail string `mapstructure:"status_detail"` - // The time the public IP was created. - CreatedAt time.Time `mapstructure:"-"` - // The time the public IP was last updated. - UpdatedAt time.Time `mapstructure:"-"` -} - -// PublicIPPage is the page returned by a pager when traversing over a -// collection of PublicIPs. -type PublicIPPage struct { - pagination.SinglePageBase -} - -// IsEmpty returns true if a PublicIPPage contains no PublicIPs. -func (r PublicIPPage) IsEmpty() (bool, error) { - n, err := ExtractPublicIPs(r) - if err != nil { - return true, err - } - return len(n) == 0, nil -} - -// ExtractPublicIPs extracts and returns a slice of PublicIPs. It is used while iterating over -// a publicips.List call. -func ExtractPublicIPs(page pagination.Page) ([]PublicIP, error) { - var res []PublicIP - casted := page.(PublicIPPage).Body - err := mapstructure.Decode(casted, &res) - - var rawNodesDetails []interface{} - switch casted.(type) { - case interface{}: - rawNodesDetails = casted.([]interface{}) - default: - return res, fmt.Errorf("Unknown type: %v", reflect.TypeOf(casted)) - } - - for i := range rawNodesDetails { - thisNodeDetails := (rawNodesDetails[i]).(map[string]interface{}) - - if t, ok := thisNodeDetails["created"].(string); ok && t != "" { - creationTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return res, err - } - res[i].CreatedAt = creationTime - } - - if t, ok := thisNodeDetails["updated"].(string); ok && t != "" { - updatedTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return res, err - } - res[i].UpdatedAt = updatedTime - } - - if cs, ok := thisNodeDetails["cloud_server"].(map[string]interface{}); ok { - if t, ok := cs["created"].(string); ok && t != "" { - creationTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return res, err - } - res[i].CloudServer.CreatedAt = creationTime - } - if t, ok := cs["updated"].(string); ok && t != "" { - updatedTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return res, err - } - res[i].CloudServer.UpdatedAt = updatedTime - } - if cn, ok := cs["cloud_network"].(map[string]interface{}); ok { - if t, ok := cn["created"].(string); ok && t != "" { - creationTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return res, err - } - res[i].CloudServer.CloudNetwork.CreatedAt = creationTime - } - if t, ok := cn["updated"].(string); ok && t != "" { - updatedTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return res, err - } - res[i].CloudServer.CloudNetwork.UpdatedAt = updatedTime - } - } - } - } - - return res, err -} - -// PublicIPResult represents a result that can be extracted into a PublicIP. -type PublicIPResult struct { - gophercloud.Result -} - -// CreateResult represents the result of a Create operation. -type CreateResult struct { - PublicIPResult -} - -// GetResult represents the result of a Get operation. -type GetResult struct { - PublicIPResult -} - -// Extract is a function that extracts a PublicIP from a PublicIPResult. -func (r PublicIPResult) Extract() (*PublicIP, error) { - if r.Err != nil { - return nil, r.Err - } - var res PublicIP - err := mapstructure.Decode(r.Body, &res) - - b := r.Body.(map[string]interface{}) - - if date, ok := b["created"]; ok && date != nil { - t, err := time.Parse(time.RFC3339, date.(string)) - if err != nil { - return nil, err - } - res.CreatedAt = t - } - - if date, ok := b["updated"]; ok && date != nil { - t, err := time.Parse(time.RFC3339, date.(string)) - if err != nil { - return nil, err - } - res.UpdatedAt = t - } - - if cs, ok := b["cloud_server"].(map[string]interface{}); ok { - if t, ok := cs["created"].(string); ok && t != "" { - creationTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return &res, err - } - res.CloudServer.CreatedAt = creationTime - } - if t, ok := cs["updated"].(string); ok && t != "" { - updatedTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return &res, err - } - res.CloudServer.UpdatedAt = updatedTime - } - if cn, ok := cs["cloud_network"].(map[string]interface{}); ok { - if t, ok := cn["created"].(string); ok && t != "" { - creationTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return &res, err - } - res.CloudServer.CloudNetwork.CreatedAt = creationTime - } - if t, ok := cn["updated"].(string); ok && t != "" { - updatedTime, err := time.Parse(time.RFC3339, t) - if err != nil { - return &res, err - } - res.CloudServer.CloudNetwork.UpdatedAt = updatedTime - } - } - } - - return &res, err -} - -// DeleteResult represents the result of a Delete operation. -type DeleteResult struct { - gophercloud.ErrResult -} diff --git a/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/publicips/urls.go b/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/publicips/urls.go deleted file mode 100644 index 6f310be4e8..0000000000 --- a/vendor/github.com/rackspace/gophercloud/rackspace/rackconnect/v3/publicips/urls.go +++ /dev/null @@ -1,25 +0,0 @@ -package publicips - -import "github.com/rackspace/gophercloud" - -var root = "public_ips" - -func listURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(root) -} - -func createURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(root) -} - -func listForServerURL(c *gophercloud.ServiceClient, serverID string) string { - return c.ServiceURL(root + "?cloud_server_id=" + serverID) -} - -func getURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(root, id) -} - -func deleteURL(c *gophercloud.ServiceClient, id string) string { - return getURL(c, id) -} diff --git a/vendor/github.com/vmware/govmomi/vim25/mo/fixtures/cluster_host_property.xml b/vendor/github.com/vmware/govmomi/vim25/mo/fixtures/cluster_host_property.xml deleted file mode 100644 index be218c0521..0000000000 --- a/vendor/github.com/vmware/govmomi/vim25/mo/fixtures/cluster_host_property.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - domain-c7 - - host - - host-14 - host-17 - host-19 - host-52 - - - - diff --git a/vendor/github.com/vmware/govmomi/vim25/mo/fixtures/hostsystem_list_name_property.xml b/vendor/github.com/vmware/govmomi/vim25/mo/fixtures/hostsystem_list_name_property.xml deleted file mode 100644 index 05d369d85d..0000000000 --- a/vendor/github.com/vmware/govmomi/vim25/mo/fixtures/hostsystem_list_name_property.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - host-10 - - name - host-01.example.com - - - - host-30 - - name - host-02.example.com - - - diff --git a/vendor/github.com/vmware/govmomi/vim25/mo/fixtures/nested_property.xml b/vendor/github.com/vmware/govmomi/vim25/mo/fixtures/nested_property.xml deleted file mode 100644 index ed44167f45..0000000000 --- a/vendor/github.com/vmware/govmomi/vim25/mo/fixtures/nested_property.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - vm-411 - - config.name - kubernetes-master - - - config.uuid - 422ec880-ab06-06b4-23f3-beb7a052a4c9 - - - diff --git a/vendor/github.com/vmware/govmomi/vim25/mo/fixtures/not_authenticated_fault.xml b/vendor/github.com/vmware/govmomi/vim25/mo/fixtures/not_authenticated_fault.xml deleted file mode 100644 index 2a7fcdbdfa..0000000000 --- a/vendor/github.com/vmware/govmomi/vim25/mo/fixtures/not_authenticated_fault.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - SessionManager - - defaultLocale - en - - - messageLocaleList - - ja - zh_CN - en - de - zh_TW - ko - fr - - - - message - - - group-d1 - System.View - - - - - - sessionList - - - group-d1 - Sessions.TerminateSession - - - - - - diff --git a/vendor/github.com/vmware/govmomi/vim25/mo/fixtures/pointer_property.xml b/vendor/github.com/vmware/govmomi/vim25/mo/fixtures/pointer_property.xml deleted file mode 100644 index 54baaf5ffa..0000000000 --- a/vendor/github.com/vmware/govmomi/vim25/mo/fixtures/pointer_property.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - vm-411 - - config.bootOptions - - 0 - false - false - 10000 - - - - diff --git a/vendor/google.golang.org/appengine/.travis.yml b/vendor/google.golang.org/appengine/.travis.yml new file mode 100644 index 0000000000..7715209771 --- /dev/null +++ b/vendor/google.golang.org/appengine/.travis.yml @@ -0,0 +1,18 @@ +language: go +sudo: false + +go: + - 1.4 + +install: + - go get -v -t -d google.golang.org/appengine/... + - mkdir sdk + - curl -o sdk.zip "https://storage.googleapis.com/appengine-sdks/featured/go_appengine_sdk_linux_amd64-1.9.24.zip" + - unzip sdk.zip -d sdk + - export APPENGINE_DEV_APPSERVER=$(pwd)/sdk/go_appengine/dev_appserver.py + +script: + - go version + - go test -v google.golang.org/appengine/... + - go test -v -race google.golang.org/appengine/... + - sdk/go_appengine/goapp test -v google.golang.org/appengine/... diff --git a/vendor/google.golang.org/appengine/LICENSE b/vendor/google.golang.org/appengine/LICENSE new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/vendor/google.golang.org/appengine/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/vendor/google.golang.org/appengine/README.md b/vendor/google.golang.org/appengine/README.md new file mode 100644 index 0000000000..1dbb3341f0 --- /dev/null +++ b/vendor/google.golang.org/appengine/README.md @@ -0,0 +1,73 @@ +# Go App Engine packages + +[![Build Status](https://travis-ci.org/golang/appengine.svg)](https://travis-ci.org/golang/appengine) + +This repository supports the Go runtime on App Engine, +including both classic App Engine and Managed VMs. +It provides APIs for interacting with App Engine services. +Its canonical import path is `google.golang.org/appengine`. + +See https://cloud.google.com/appengine/docs/go/ +for more information. + +File issue reports and feature requests on the [Google App Engine issue +tracker](https://code.google.com/p/googleappengine/issues/entry?template=Go%20defect). + +## Directory structure +The top level directory of this repository is the `appengine` package. It +contains the +basic APIs (e.g. `appengine.NewContext`) that apply across APIs. Specific API +packages are in subdirectories (e.g. `datastore`). + +There is an `internal` subdirectory that contains service protocol buffers, +plus packages required for connectivity to make API calls. App Engine apps +should not directly import any package under `internal`. + +## Updating a Go App Engine app + +This section describes how to update a traditional Go App Engine app to use +these packages. + +### 1. Update YAML files (Managed VMs only) + +The `app.yaml` file (and YAML files for modules) should have these new lines added: +``` +vm: true +``` +See https://cloud.google.com/appengine/docs/go/modules/#Go_Instance_scaling_and_class for details. + +### 2. Update import paths + +The import paths for App Engine packages are now fully qualified, based at `google.golang.org/appengine`. +You will need to update your code to use import paths starting with that; for instance, +code importing `appengine/datastore` will now need to import `google.golang.org/appengine/datastore`. +You can do that manually, or by running this command to recursively update all Go source files in the current directory: +(may require GNU sed) +``` +sed -i '/"appengine/{s,"appengine,"google.golang.org/appengine,;s,appengine_,appengine/,}' \ + $(find . -name '*.go') +``` + +### 3. Update code using deprecated, removed or modified APIs + +Most App Engine services are available with exactly the same API. +A few APIs were cleaned up, and some are not available yet. +This list summarises the differences: + +* `appengine.Context` has been replaced with the `Context` type from `golang.org/x/net/context`. +* Logging methods that were on `appengine.Context` are now functions in `google.golang.org/appengine/log`. +* `appengine.Timeout` has been removed. Use `context.WithTimeout` instead. +* `appengine.Datacenter` now takes a `context.Context` argument. +* `datastore.PropertyLoadSaver` has been simplified to use slices in place of channels. +* `delay.Call` now returns an error. +* `search.FieldLoadSaver` now handles document metadata. +* `urlfetch.Transport` no longer has a Deadline field; set a deadline on the + `context.Context` instead. +* `aetest` no longer declares its own Context type, and uses the standard one instead. +* `taskqueue.QueueStats` no longer takes a maxTasks argument. That argument has been + deprecated and unused for a long time. +* `appengine.BackendHostname` and `appengine.BackendInstance` were for the deprecated backends feature. + Use `appengine.ModuleHostname`and `appengine.ModuleName` instead. +* Most of `appengine/file` and parts of `appengine/blobstore` are deprecated. + Use [Google Cloud Storage](https://godoc.org/google.golang.org/cloud/storage) instead. +* `appengine/socket` is not required on Managed VMs. Use the standard `net` package instead. diff --git a/vendor/google.golang.org/appengine/appengine.go b/vendor/google.golang.org/appengine/appengine.go new file mode 100644 index 0000000000..52e6ee3f29 --- /dev/null +++ b/vendor/google.golang.org/appengine/appengine.go @@ -0,0 +1,76 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +// Package appengine provides basic functionality for Google App Engine. +// +// For more information on how to write Go apps for Google App Engine, see: +// https://cloud.google.com/appengine/docs/go/ +package appengine + +import ( + "net/http" + + "github.com/golang/protobuf/proto" + "golang.org/x/net/context" + + "google.golang.org/appengine/internal" +) + +// IsDevAppServer reports whether the App Engine app is running in the +// development App Server. +func IsDevAppServer() bool { + return internal.IsDevAppServer() +} + +// NewContext returns a context for an in-flight HTTP request. +// This function is cheap. +func NewContext(req *http.Request) context.Context { + return WithContext(context.Background(), req) +} + +// WithContext returns a copy of the parent context +// and associates it with an in-flight HTTP request. +// This function is cheap. +func WithContext(parent context.Context, req *http.Request) context.Context { + return internal.WithContext(parent, req) +} + +// TODO(dsymonds): Add a Call function here? Otherwise other packages can't access internal.Call. + +// BlobKey is a key for a blobstore blob. +// +// Conceptually, this type belongs in the blobstore package, but it lives in +// the appengine package to avoid a circular dependency: blobstore depends on +// datastore, and datastore needs to refer to the BlobKey type. +type BlobKey string + +// GeoPoint represents a location as latitude/longitude in degrees. +type GeoPoint struct { + Lat, Lng float64 +} + +// Valid returns whether a GeoPoint is within [-90, 90] latitude and [-180, 180] longitude. +func (g GeoPoint) Valid() bool { + return -90 <= g.Lat && g.Lat <= 90 && -180 <= g.Lng && g.Lng <= 180 +} + +// APICallFunc defines a function type for handling an API call. +// See WithCallOverride. +type APICallFunc func(ctx context.Context, service, method string, in, out proto.Message) error + +// WithCallOverride returns a copy of the parent context +// that will cause API calls to invoke f instead of their normal operation. +// +// This is intended for advanced users only. +func WithAPICallFunc(ctx context.Context, f APICallFunc) context.Context { + return internal.WithCallOverride(ctx, internal.CallOverrideFunc(f)) +} + +// APICall performs an API call. +// +// This is not intended for general use; it is exported for use in conjunction +// with WithAPICallFunc. +func APICall(ctx context.Context, service, method string, in, out proto.Message) error { + return internal.Call(ctx, service, method, in, out) +} diff --git a/vendor/google.golang.org/appengine/appengine_vm.go b/vendor/google.golang.org/appengine/appengine_vm.go new file mode 100644 index 0000000000..2f7759067f --- /dev/null +++ b/vendor/google.golang.org/appengine/appengine_vm.go @@ -0,0 +1,56 @@ +// Copyright 2015 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +// +build !appengine + +package appengine + +import ( + "golang.org/x/net/context" + + "google.golang.org/appengine/internal" +) + +// The comment below must not be changed. +// It is used by go-app-builder to recognise that this package has +// the Main function to use in the synthetic main. +// The gophers party all night; the rabbits provide the beats. + +// Main is the principal entry point for a Managed VMs app. +// It installs a trivial health checker if one isn't already registered, +// and starts listening on port 8080 (overridden by the $PORT environment +// variable). +// +// See https://cloud.google.com/appengine/docs/managed-vms/custom-runtimes#health_check_requests +// for details on how to do your own health checking. +// +// Main never returns. +// +// Main is designed so that the app's main package looks like this: +// +// package main +// +// import ( +// "google.golang.org/appengine" +// +// _ "myapp/package0" +// _ "myapp/package1" +// ) +// +// func main() { +// appengine.Main() +// } +// +// The "myapp/packageX" packages are expected to register HTTP handlers +// in their init functions. +func Main() { + internal.Main() +} + +// BackgroundContext returns a context not associated with a request. +// This should only be used when not servicing a request. +// This only works on Managed VMs. +func BackgroundContext() context.Context { + return internal.BackgroundContext() +} diff --git a/vendor/google.golang.org/appengine/errors.go b/vendor/google.golang.org/appengine/errors.go new file mode 100644 index 0000000000..16d0772e2a --- /dev/null +++ b/vendor/google.golang.org/appengine/errors.go @@ -0,0 +1,46 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +// This file provides error functions for common API failure modes. + +package appengine + +import ( + "fmt" + + "google.golang.org/appengine/internal" +) + +// IsOverQuota reports whether err represents an API call failure +// due to insufficient available quota. +func IsOverQuota(err error) bool { + callErr, ok := err.(*internal.CallError) + return ok && callErr.Code == 4 +} + +// MultiError is returned by batch operations when there are errors with +// particular elements. Errors will be in a one-to-one correspondence with +// the input elements; successful elements will have a nil entry. +type MultiError []error + +func (m MultiError) Error() string { + s, n := "", 0 + for _, e := range m { + if e != nil { + if n == 0 { + s = e.Error() + } + n++ + } + } + switch n { + case 0: + return "(0 errors)" + case 1: + return s + case 2: + return s + " (and 1 other error)" + } + return fmt.Sprintf("%s (and %d other errors)", s, n-1) +} diff --git a/vendor/google.golang.org/appengine/identity.go b/vendor/google.golang.org/appengine/identity.go new file mode 100644 index 0000000000..b8dcf8f361 --- /dev/null +++ b/vendor/google.golang.org/appengine/identity.go @@ -0,0 +1,142 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package appengine + +import ( + "time" + + "golang.org/x/net/context" + + "google.golang.org/appengine/internal" + pb "google.golang.org/appengine/internal/app_identity" + modpb "google.golang.org/appengine/internal/modules" +) + +// AppID returns the application ID for the current application. +// The string will be a plain application ID (e.g. "appid"), with a +// domain prefix for custom domain deployments (e.g. "example.com:appid"). +func AppID(c context.Context) string { return internal.AppID(c) } + +// DefaultVersionHostname returns the standard hostname of the default version +// of the current application (e.g. "my-app.appspot.com"). This is suitable for +// use in constructing URLs. +func DefaultVersionHostname(c context.Context) string { + return internal.DefaultVersionHostname(c) +} + +// ModuleName returns the module name of the current instance. +func ModuleName(c context.Context) string { + return internal.ModuleName(c) +} + +// ModuleHostname returns a hostname of a module instance. +// If module is the empty string, it refers to the module of the current instance. +// If version is empty, it refers to the version of the current instance if valid, +// or the default version of the module of the current instance. +// If instance is empty, ModuleHostname returns the load-balancing hostname. +func ModuleHostname(c context.Context, module, version, instance string) (string, error) { + req := &modpb.GetHostnameRequest{} + if module != "" { + req.Module = &module + } + if version != "" { + req.Version = &version + } + if instance != "" { + req.Instance = &instance + } + res := &modpb.GetHostnameResponse{} + if err := internal.Call(c, "modules", "GetHostname", req, res); err != nil { + return "", err + } + return *res.Hostname, nil +} + +// VersionID returns the version ID for the current application. +// It will be of the form "X.Y", where X is specified in app.yaml, +// and Y is a number generated when each version of the app is uploaded. +// It does not include a module name. +func VersionID(c context.Context) string { return internal.VersionID(c) } + +// InstanceID returns a mostly-unique identifier for this instance. +func InstanceID() string { return internal.InstanceID() } + +// Datacenter returns an identifier for the datacenter that the instance is running in. +func Datacenter(c context.Context) string { return internal.Datacenter(c) } + +// ServerSoftware returns the App Engine release version. +// In production, it looks like "Google App Engine/X.Y.Z". +// In the development appserver, it looks like "Development/X.Y". +func ServerSoftware() string { return internal.ServerSoftware() } + +// RequestID returns a string that uniquely identifies the request. +func RequestID(c context.Context) string { return internal.RequestID(c) } + +// AccessToken generates an OAuth2 access token for the specified scopes on +// behalf of service account of this application. This token will expire after +// the returned time. +func AccessToken(c context.Context, scopes ...string) (token string, expiry time.Time, err error) { + req := &pb.GetAccessTokenRequest{Scope: scopes} + res := &pb.GetAccessTokenResponse{} + + err = internal.Call(c, "app_identity_service", "GetAccessToken", req, res) + if err != nil { + return "", time.Time{}, err + } + return res.GetAccessToken(), time.Unix(res.GetExpirationTime(), 0), nil +} + +// Certificate represents a public certificate for the app. +type Certificate struct { + KeyName string + Data []byte // PEM-encoded X.509 certificate +} + +// PublicCertificates retrieves the public certificates for the app. +// They can be used to verify a signature returned by SignBytes. +func PublicCertificates(c context.Context) ([]Certificate, error) { + req := &pb.GetPublicCertificateForAppRequest{} + res := &pb.GetPublicCertificateForAppResponse{} + if err := internal.Call(c, "app_identity_service", "GetPublicCertificatesForApp", req, res); err != nil { + return nil, err + } + var cs []Certificate + for _, pc := range res.PublicCertificateList { + cs = append(cs, Certificate{ + KeyName: pc.GetKeyName(), + Data: []byte(pc.GetX509CertificatePem()), + }) + } + return cs, nil +} + +// ServiceAccount returns a string representing the service account name, in +// the form of an email address (typically app_id@appspot.gserviceaccount.com). +func ServiceAccount(c context.Context) (string, error) { + req := &pb.GetServiceAccountNameRequest{} + res := &pb.GetServiceAccountNameResponse{} + + err := internal.Call(c, "app_identity_service", "GetServiceAccountName", req, res) + if err != nil { + return "", err + } + return res.GetServiceAccountName(), err +} + +// SignBytes signs bytes using a private key unique to your application. +func SignBytes(c context.Context, bytes []byte) (keyName string, signature []byte, err error) { + req := &pb.SignForAppRequest{BytesToSign: bytes} + res := &pb.SignForAppResponse{} + + if err := internal.Call(c, "app_identity_service", "SignForApp", req, res); err != nil { + return "", nil, err + } + return res.GetKeyName(), res.GetSignatureBytes(), nil +} + +func init() { + internal.RegisterErrorCodeMap("app_identity_service", pb.AppIdentityServiceError_ErrorCode_name) + internal.RegisterErrorCodeMap("modules", modpb.ModulesServiceError_ErrorCode_name) +} diff --git a/vendor/google.golang.org/appengine/internal/api.go b/vendor/google.golang.org/appengine/internal/api.go new file mode 100644 index 0000000000..aa139d4d51 --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/api.go @@ -0,0 +1,640 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +// +build !appengine + +package internal + +import ( + "bytes" + "errors" + "fmt" + "io/ioutil" + "log" + "net" + "net/http" + "net/url" + "os" + "runtime" + "strconv" + "strings" + "sync" + "sync/atomic" + "time" + + "github.com/golang/protobuf/proto" + netcontext "golang.org/x/net/context" + + basepb "google.golang.org/appengine/internal/base" + logpb "google.golang.org/appengine/internal/log" + remotepb "google.golang.org/appengine/internal/remote_api" +) + +const ( + apiPath = "/rpc_http" +) + +var ( + // Incoming headers. + ticketHeader = http.CanonicalHeaderKey("X-AppEngine-API-Ticket") + dapperHeader = http.CanonicalHeaderKey("X-Google-DapperTraceInfo") + traceHeader = http.CanonicalHeaderKey("X-Cloud-Trace-Context") + curNamespaceHeader = http.CanonicalHeaderKey("X-AppEngine-Current-Namespace") + userIPHeader = http.CanonicalHeaderKey("X-AppEngine-User-IP") + remoteAddrHeader = http.CanonicalHeaderKey("X-AppEngine-Remote-Addr") + + // Outgoing headers. + apiEndpointHeader = http.CanonicalHeaderKey("X-Google-RPC-Service-Endpoint") + apiEndpointHeaderValue = []string{"app-engine-apis"} + apiMethodHeader = http.CanonicalHeaderKey("X-Google-RPC-Service-Method") + apiMethodHeaderValue = []string{"/VMRemoteAPI.CallRemoteAPI"} + apiDeadlineHeader = http.CanonicalHeaderKey("X-Google-RPC-Service-Deadline") + apiContentType = http.CanonicalHeaderKey("Content-Type") + apiContentTypeValue = []string{"application/octet-stream"} + logFlushHeader = http.CanonicalHeaderKey("X-AppEngine-Log-Flush-Count") + + apiHTTPClient = &http.Client{ + Transport: &http.Transport{ + Proxy: http.ProxyFromEnvironment, + Dial: limitDial, + }, + } +) + +func apiURL() *url.URL { + host, port := "appengine.googleapis.internal", "10001" + if h := os.Getenv("API_HOST"); h != "" { + host = h + } + if p := os.Getenv("API_PORT"); p != "" { + port = p + } + return &url.URL{ + Scheme: "http", + Host: host + ":" + port, + Path: apiPath, + } +} + +func handleHTTP(w http.ResponseWriter, r *http.Request) { + c := &context{ + req: r, + outHeader: w.Header(), + apiURL: apiURL(), + } + stopFlushing := make(chan int) + + ctxs.Lock() + ctxs.m[r] = c + ctxs.Unlock() + defer func() { + ctxs.Lock() + delete(ctxs.m, r) + ctxs.Unlock() + }() + + // Patch up RemoteAddr so it looks reasonable. + if addr := r.Header.Get(userIPHeader); addr != "" { + r.RemoteAddr = addr + } else if addr = r.Header.Get(remoteAddrHeader); addr != "" { + r.RemoteAddr = addr + } else { + // Should not normally reach here, but pick a sensible default anyway. + r.RemoteAddr = "127.0.0.1" + } + // The address in the headers will most likely be of these forms: + // 123.123.123.123 + // 2001:db8::1 + // net/http.Request.RemoteAddr is specified to be in "IP:port" form. + if _, _, err := net.SplitHostPort(r.RemoteAddr); err != nil { + // Assume the remote address is only a host; add a default port. + r.RemoteAddr = net.JoinHostPort(r.RemoteAddr, "80") + } + + // Start goroutine responsible for flushing app logs. + // This is done after adding c to ctx.m (and stopped before removing it) + // because flushing logs requires making an API call. + go c.logFlusher(stopFlushing) + + executeRequestSafely(c, r) + c.outHeader = nil // make sure header changes aren't respected any more + + stopFlushing <- 1 // any logging beyond this point will be dropped + + // Flush any pending logs asynchronously. + c.pendingLogs.Lock() + flushes := c.pendingLogs.flushes + if len(c.pendingLogs.lines) > 0 { + flushes++ + } + c.pendingLogs.Unlock() + go c.flushLog(false) + w.Header().Set(logFlushHeader, strconv.Itoa(flushes)) + + // Avoid nil Write call if c.Write is never called. + if c.outCode != 0 { + w.WriteHeader(c.outCode) + } + if c.outBody != nil { + w.Write(c.outBody) + } +} + +func executeRequestSafely(c *context, r *http.Request) { + defer func() { + if x := recover(); x != nil { + logf(c, 4, "%s", renderPanic(x)) // 4 == critical + c.outCode = 500 + } + }() + + http.DefaultServeMux.ServeHTTP(c, r) +} + +func renderPanic(x interface{}) string { + buf := make([]byte, 16<<10) // 16 KB should be plenty + buf = buf[:runtime.Stack(buf, false)] + + // Remove the first few stack frames: + // this func + // the recover closure in the caller + // That will root the stack trace at the site of the panic. + const ( + skipStart = "internal.renderPanic" + skipFrames = 2 + ) + start := bytes.Index(buf, []byte(skipStart)) + p := start + for i := 0; i < skipFrames*2 && p+1 < len(buf); i++ { + p = bytes.IndexByte(buf[p+1:], '\n') + p + 1 + if p < 0 { + break + } + } + if p >= 0 { + // buf[start:p+1] is the block to remove. + // Copy buf[p+1:] over buf[start:] and shrink buf. + copy(buf[start:], buf[p+1:]) + buf = buf[:len(buf)-(p+1-start)] + } + + // Add panic heading. + head := fmt.Sprintf("panic: %v\n\n", x) + if len(head) > len(buf) { + // Extremely unlikely to happen. + return head + } + copy(buf[len(head):], buf) + copy(buf, head) + + return string(buf) +} + +var ctxs = struct { + sync.Mutex + m map[*http.Request]*context + bg *context // background context, lazily initialized + // dec is used by tests to decorate the netcontext.Context returned + // for a given request. This allows tests to add overrides (such as + // WithAppIDOverride) to the context. The map is nil outside tests. + dec map[*http.Request]func(netcontext.Context) netcontext.Context +}{ + m: make(map[*http.Request]*context), +} + +// context represents the context of an in-flight HTTP request. +// It implements the appengine.Context and http.ResponseWriter interfaces. +type context struct { + req *http.Request + + outCode int + outHeader http.Header + outBody []byte + + pendingLogs struct { + sync.Mutex + lines []*logpb.UserAppLogLine + flushes int + } + + apiURL *url.URL +} + +var contextKey = "holds a *context" + +func fromContext(ctx netcontext.Context) *context { + c, _ := ctx.Value(&contextKey).(*context) + return c +} + +func withContext(parent netcontext.Context, c *context) netcontext.Context { + ctx := netcontext.WithValue(parent, &contextKey, c) + if ns := c.req.Header.Get(curNamespaceHeader); ns != "" { + ctx = withNamespace(ctx, ns) + } + return ctx +} + +func toContext(c *context) netcontext.Context { + return withContext(netcontext.Background(), c) +} + +func IncomingHeaders(ctx netcontext.Context) http.Header { + if c := fromContext(ctx); c != nil { + return c.req.Header + } + return nil +} + +func WithContext(parent netcontext.Context, req *http.Request) netcontext.Context { + ctxs.Lock() + c := ctxs.m[req] + d := ctxs.dec[req] + ctxs.Unlock() + + if d != nil { + parent = d(parent) + } + + if c == nil { + // Someone passed in an http.Request that is not in-flight. + // We panic here rather than panicking at a later point + // so that stack traces will be more sensible. + log.Panic("appengine: NewContext passed an unknown http.Request") + } + return withContext(parent, c) +} + +func BackgroundContext() netcontext.Context { + ctxs.Lock() + defer ctxs.Unlock() + + if ctxs.bg != nil { + return toContext(ctxs.bg) + } + + // Compute background security ticket. + appID := partitionlessAppID() + escAppID := strings.Replace(strings.Replace(appID, ":", "_", -1), ".", "_", -1) + majVersion := VersionID(nil) + if i := strings.Index(majVersion, "."); i > 0 { + majVersion = majVersion[:i] + } + ticket := fmt.Sprintf("%s/%s.%s.%s", escAppID, ModuleName(nil), majVersion, InstanceID()) + + ctxs.bg = &context{ + req: &http.Request{ + Header: http.Header{ + ticketHeader: []string{ticket}, + }, + }, + apiURL: apiURL(), + } + + // TODO(dsymonds): Wire up the shutdown handler to do a final flush. + go ctxs.bg.logFlusher(make(chan int)) + + return toContext(ctxs.bg) +} + +// RegisterTestRequest registers the HTTP request req for testing, such that +// any API calls are sent to the provided URL. It returns a closure to delete +// the registration. +// It should only be used by aetest package. +func RegisterTestRequest(req *http.Request, apiURL *url.URL, decorate func(netcontext.Context) netcontext.Context) func() { + c := &context{ + req: req, + apiURL: apiURL, + } + ctxs.Lock() + defer ctxs.Unlock() + if _, ok := ctxs.m[req]; ok { + log.Panic("req already associated with context") + } + if _, ok := ctxs.dec[req]; ok { + log.Panic("req already associated with context") + } + if ctxs.dec == nil { + ctxs.dec = make(map[*http.Request]func(netcontext.Context) netcontext.Context) + } + ctxs.m[req] = c + ctxs.dec[req] = decorate + + return func() { + ctxs.Lock() + delete(ctxs.m, req) + delete(ctxs.dec, req) + ctxs.Unlock() + } +} + +var errTimeout = &CallError{ + Detail: "Deadline exceeded", + Code: int32(remotepb.RpcError_CANCELLED), + Timeout: true, +} + +func (c *context) Header() http.Header { return c.outHeader } + +// Copied from $GOROOT/src/pkg/net/http/transfer.go. Some response status +// codes do not permit a response body (nor response entity headers such as +// Content-Length, Content-Type, etc). +func bodyAllowedForStatus(status int) bool { + switch { + case status >= 100 && status <= 199: + return false + case status == 204: + return false + case status == 304: + return false + } + return true +} + +func (c *context) Write(b []byte) (int, error) { + if c.outCode == 0 { + c.WriteHeader(http.StatusOK) + } + if len(b) > 0 && !bodyAllowedForStatus(c.outCode) { + return 0, http.ErrBodyNotAllowed + } + c.outBody = append(c.outBody, b...) + return len(b), nil +} + +func (c *context) WriteHeader(code int) { + if c.outCode != 0 { + logf(c, 3, "WriteHeader called multiple times on request.") // error level + return + } + c.outCode = code +} + +func (c *context) post(body []byte, timeout time.Duration) (b []byte, err error) { + hreq := &http.Request{ + Method: "POST", + URL: c.apiURL, + Header: http.Header{ + apiEndpointHeader: apiEndpointHeaderValue, + apiMethodHeader: apiMethodHeaderValue, + apiContentType: apiContentTypeValue, + apiDeadlineHeader: []string{strconv.FormatFloat(timeout.Seconds(), 'f', -1, 64)}, + }, + Body: ioutil.NopCloser(bytes.NewReader(body)), + ContentLength: int64(len(body)), + Host: c.apiURL.Host, + } + if info := c.req.Header.Get(dapperHeader); info != "" { + hreq.Header.Set(dapperHeader, info) + } + if info := c.req.Header.Get(traceHeader); info != "" { + hreq.Header.Set(traceHeader, info) + } + + tr := apiHTTPClient.Transport.(*http.Transport) + + var timedOut int32 // atomic; set to 1 if timed out + t := time.AfterFunc(timeout, func() { + atomic.StoreInt32(&timedOut, 1) + tr.CancelRequest(hreq) + }) + defer t.Stop() + defer func() { + // Check if timeout was exceeded. + if atomic.LoadInt32(&timedOut) != 0 { + err = errTimeout + } + }() + + hresp, err := apiHTTPClient.Do(hreq) + if err != nil { + return nil, &CallError{ + Detail: fmt.Sprintf("service bridge HTTP failed: %v", err), + Code: int32(remotepb.RpcError_UNKNOWN), + } + } + defer hresp.Body.Close() + hrespBody, err := ioutil.ReadAll(hresp.Body) + if hresp.StatusCode != 200 { + return nil, &CallError{ + Detail: fmt.Sprintf("service bridge returned HTTP %d (%q)", hresp.StatusCode, hrespBody), + Code: int32(remotepb.RpcError_UNKNOWN), + } + } + if err != nil { + return nil, &CallError{ + Detail: fmt.Sprintf("service bridge response bad: %v", err), + Code: int32(remotepb.RpcError_UNKNOWN), + } + } + return hrespBody, nil +} + +func Call(ctx netcontext.Context, service, method string, in, out proto.Message) error { + if f, ctx, ok := callOverrideFromContext(ctx); ok { + return f(ctx, service, method, in, out) + } + + // Handle already-done contexts quickly. + select { + case <-ctx.Done(): + return ctx.Err() + default: + } + + c := fromContext(ctx) + if c == nil { + // Give a good error message rather than a panic lower down. + return errors.New("not an App Engine context") + } + + // Apply transaction modifications if we're in a transaction. + if t := transactionFromContext(ctx); t != nil { + if t.finished { + return errors.New("transaction context has expired") + } + applyTransaction(in, &t.transaction) + } + + // Default RPC timeout is 60s. + timeout := 60 * time.Second + if deadline, ok := ctx.Deadline(); ok { + timeout = deadline.Sub(time.Now()) + } + + data, err := proto.Marshal(in) + if err != nil { + return err + } + + ticket := c.req.Header.Get(ticketHeader) + req := &remotepb.Request{ + ServiceName: &service, + Method: &method, + Request: data, + RequestId: &ticket, + } + hreqBody, err := proto.Marshal(req) + if err != nil { + return err + } + + hrespBody, err := c.post(hreqBody, timeout) + if err != nil { + return err + } + + res := &remotepb.Response{} + if err := proto.Unmarshal(hrespBody, res); err != nil { + return err + } + if res.RpcError != nil { + ce := &CallError{ + Detail: res.RpcError.GetDetail(), + Code: *res.RpcError.Code, + } + switch remotepb.RpcError_ErrorCode(ce.Code) { + case remotepb.RpcError_CANCELLED, remotepb.RpcError_DEADLINE_EXCEEDED: + ce.Timeout = true + } + return ce + } + if res.ApplicationError != nil { + return &APIError{ + Service: *req.ServiceName, + Detail: res.ApplicationError.GetDetail(), + Code: *res.ApplicationError.Code, + } + } + if res.Exception != nil || res.JavaException != nil { + // This shouldn't happen, but let's be defensive. + return &CallError{ + Detail: "service bridge returned exception", + Code: int32(remotepb.RpcError_UNKNOWN), + } + } + return proto.Unmarshal(res.Response, out) +} + +func (c *context) Request() *http.Request { + return c.req +} + +func (c *context) addLogLine(ll *logpb.UserAppLogLine) { + // Truncate long log lines. + // TODO(dsymonds): Check if this is still necessary. + const lim = 8 << 10 + if len(*ll.Message) > lim { + suffix := fmt.Sprintf("...(length %d)", len(*ll.Message)) + ll.Message = proto.String((*ll.Message)[:lim-len(suffix)] + suffix) + } + + c.pendingLogs.Lock() + c.pendingLogs.lines = append(c.pendingLogs.lines, ll) + c.pendingLogs.Unlock() +} + +var logLevelName = map[int64]string{ + 0: "DEBUG", + 1: "INFO", + 2: "WARNING", + 3: "ERROR", + 4: "CRITICAL", +} + +func logf(c *context, level int64, format string, args ...interface{}) { + s := fmt.Sprintf(format, args...) + s = strings.TrimRight(s, "\n") // Remove any trailing newline characters. + c.addLogLine(&logpb.UserAppLogLine{ + TimestampUsec: proto.Int64(time.Now().UnixNano() / 1e3), + Level: &level, + Message: &s, + }) + log.Print(logLevelName[level] + ": " + s) +} + +// flushLog attempts to flush any pending logs to the appserver. +// It should not be called concurrently. +func (c *context) flushLog(force bool) (flushed bool) { + c.pendingLogs.Lock() + // Grab up to 30 MB. We can get away with up to 32 MB, but let's be cautious. + n, rem := 0, 30<<20 + for ; n < len(c.pendingLogs.lines); n++ { + ll := c.pendingLogs.lines[n] + // Each log line will require about 3 bytes of overhead. + nb := proto.Size(ll) + 3 + if nb > rem { + break + } + rem -= nb + } + lines := c.pendingLogs.lines[:n] + c.pendingLogs.lines = c.pendingLogs.lines[n:] + c.pendingLogs.Unlock() + + if len(lines) == 0 && !force { + // Nothing to flush. + return false + } + + rescueLogs := false + defer func() { + if rescueLogs { + c.pendingLogs.Lock() + c.pendingLogs.lines = append(lines, c.pendingLogs.lines...) + c.pendingLogs.Unlock() + } + }() + + buf, err := proto.Marshal(&logpb.UserAppLogGroup{ + LogLine: lines, + }) + if err != nil { + log.Printf("internal.flushLog: marshaling UserAppLogGroup: %v", err) + rescueLogs = true + return false + } + + req := &logpb.FlushRequest{ + Logs: buf, + } + res := &basepb.VoidProto{} + c.pendingLogs.Lock() + c.pendingLogs.flushes++ + c.pendingLogs.Unlock() + if err := Call(toContext(c), "logservice", "Flush", req, res); err != nil { + log.Printf("internal.flushLog: Flush RPC: %v", err) + rescueLogs = true + return false + } + return true +} + +const ( + // Log flushing parameters. + flushInterval = 1 * time.Second + forceFlushInterval = 60 * time.Second +) + +func (c *context) logFlusher(stop <-chan int) { + lastFlush := time.Now() + tick := time.NewTicker(flushInterval) + for { + select { + case <-stop: + // Request finished. + tick.Stop() + return + case <-tick.C: + force := time.Now().Sub(lastFlush) > forceFlushInterval + if c.flushLog(force) { + lastFlush = time.Now() + } + } + } +} + +func ContextForTesting(req *http.Request) netcontext.Context { + return toContext(&context{req: req}) +} diff --git a/vendor/google.golang.org/appengine/internal/api_classic.go b/vendor/google.golang.org/appengine/internal/api_classic.go new file mode 100644 index 0000000000..1c072e9dbb --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/api_classic.go @@ -0,0 +1,133 @@ +// Copyright 2015 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +// +build appengine + +package internal + +import ( + "errors" + "net/http" + "time" + + "appengine" + "appengine_internal" + basepb "appengine_internal/base" + + "github.com/golang/protobuf/proto" + netcontext "golang.org/x/net/context" +) + +var contextKey = "holds an appengine.Context" + +func fromContext(ctx netcontext.Context) appengine.Context { + c, _ := ctx.Value(&contextKey).(appengine.Context) + return c +} + +// This is only for classic App Engine adapters. +func ClassicContextFromContext(ctx netcontext.Context) appengine.Context { + return fromContext(ctx) +} + +func withContext(parent netcontext.Context, c appengine.Context) netcontext.Context { + ctx := netcontext.WithValue(parent, &contextKey, c) + + s := &basepb.StringProto{} + c.Call("__go__", "GetNamespace", &basepb.VoidProto{}, s, nil) + if ns := s.GetValue(); ns != "" { + ctx = NamespacedContext(ctx, ns) + } + + return ctx +} + +func IncomingHeaders(ctx netcontext.Context) http.Header { + if c := fromContext(ctx); c != nil { + if req, ok := c.Request().(*http.Request); ok { + return req.Header + } + } + return nil +} + +func WithContext(parent netcontext.Context, req *http.Request) netcontext.Context { + c := appengine.NewContext(req) + return withContext(parent, c) +} + +func Call(ctx netcontext.Context, service, method string, in, out proto.Message) error { + if f, ctx, ok := callOverrideFromContext(ctx); ok { + return f(ctx, service, method, in, out) + } + + // Handle already-done contexts quickly. + select { + case <-ctx.Done(): + return ctx.Err() + default: + } + + c := fromContext(ctx) + if c == nil { + // Give a good error message rather than a panic lower down. + return errors.New("not an App Engine context") + } + + // Apply transaction modifications if we're in a transaction. + if t := transactionFromContext(ctx); t != nil { + if t.finished { + return errors.New("transaction context has expired") + } + applyTransaction(in, &t.transaction) + } + + var opts *appengine_internal.CallOptions + if d, ok := ctx.Deadline(); ok { + opts = &appengine_internal.CallOptions{ + Timeout: d.Sub(time.Now()), + } + } + + err := c.Call(service, method, in, out, opts) + switch v := err.(type) { + case *appengine_internal.APIError: + return &APIError{ + Service: v.Service, + Detail: v.Detail, + Code: v.Code, + } + case *appengine_internal.CallError: + return &CallError{ + Detail: v.Detail, + Code: v.Code, + Timeout: v.Timeout, + } + } + return err +} + +func handleHTTP(w http.ResponseWriter, r *http.Request) { + panic("handleHTTP called; this should be impossible") +} + +func logf(c appengine.Context, level int64, format string, args ...interface{}) { + var fn func(format string, args ...interface{}) + switch level { + case 0: + fn = c.Debugf + case 1: + fn = c.Infof + case 2: + fn = c.Warningf + case 3: + fn = c.Errorf + case 4: + fn = c.Criticalf + default: + // This shouldn't happen. + fn = c.Criticalf + } + fn(format, args...) +} diff --git a/vendor/google.golang.org/appengine/internal/api_common.go b/vendor/google.golang.org/appengine/internal/api_common.go new file mode 100644 index 0000000000..ec5383e660 --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/api_common.go @@ -0,0 +1,101 @@ +// Copyright 2015 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package internal + +import ( + "github.com/golang/protobuf/proto" + netcontext "golang.org/x/net/context" +) + +type CallOverrideFunc func(ctx netcontext.Context, service, method string, in, out proto.Message) error + +var callOverrideKey = "holds []CallOverrideFunc" + +func WithCallOverride(ctx netcontext.Context, f CallOverrideFunc) netcontext.Context { + // We avoid appending to any existing call override + // so we don't risk overwriting a popped stack below. + var cofs []CallOverrideFunc + if uf, ok := ctx.Value(&callOverrideKey).([]CallOverrideFunc); ok { + cofs = append(cofs, uf...) + } + cofs = append(cofs, f) + return netcontext.WithValue(ctx, &callOverrideKey, cofs) +} + +func callOverrideFromContext(ctx netcontext.Context) (CallOverrideFunc, netcontext.Context, bool) { + cofs, _ := ctx.Value(&callOverrideKey).([]CallOverrideFunc) + if len(cofs) == 0 { + return nil, nil, false + } + // We found a list of overrides; grab the last, and reconstitute a + // context that will hide it. + f := cofs[len(cofs)-1] + ctx = netcontext.WithValue(ctx, &callOverrideKey, cofs[:len(cofs)-1]) + return f, ctx, true +} + +type logOverrideFunc func(level int64, format string, args ...interface{}) + +var logOverrideKey = "holds a logOverrideFunc" + +func WithLogOverride(ctx netcontext.Context, f logOverrideFunc) netcontext.Context { + return netcontext.WithValue(ctx, &logOverrideKey, f) +} + +var appIDOverrideKey = "holds a string, being the full app ID" + +func WithAppIDOverride(ctx netcontext.Context, appID string) netcontext.Context { + return netcontext.WithValue(ctx, &appIDOverrideKey, appID) +} + +var namespaceKey = "holds the namespace string" + +func withNamespace(ctx netcontext.Context, ns string) netcontext.Context { + return netcontext.WithValue(ctx, &namespaceKey, ns) +} + +func NamespaceFromContext(ctx netcontext.Context) string { + // If there's no namespace, return the empty string. + ns, _ := ctx.Value(&namespaceKey).(string) + return ns +} + +// FullyQualifiedAppID returns the fully-qualified application ID. +// This may contain a partition prefix (e.g. "s~" for High Replication apps), +// or a domain prefix (e.g. "example.com:"). +func FullyQualifiedAppID(ctx netcontext.Context) string { + if id, ok := ctx.Value(&appIDOverrideKey).(string); ok { + return id + } + return fullyQualifiedAppID(ctx) +} + +func Logf(ctx netcontext.Context, level int64, format string, args ...interface{}) { + if f, ok := ctx.Value(&logOverrideKey).(logOverrideFunc); ok { + f(level, format, args...) + return + } + logf(fromContext(ctx), level, format, args...) +} + +// NamespacedContext wraps a Context to support namespaces. +func NamespacedContext(ctx netcontext.Context, namespace string) netcontext.Context { + n := &namespacedContext{ + namespace: namespace, + } + return withNamespace(WithCallOverride(ctx, n.call), namespace) +} + +type namespacedContext struct { + namespace string +} + +func (n *namespacedContext) call(ctx netcontext.Context, service, method string, in, out proto.Message) error { + // Apply any namespace mods. + if mod, ok := NamespaceMods[service]; ok { + mod(in, n.namespace) + } + return Call(ctx, service, method, in, out) +} diff --git a/vendor/google.golang.org/appengine/internal/app_id.go b/vendor/google.golang.org/appengine/internal/app_id.go new file mode 100644 index 0000000000..11df8c07b5 --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/app_id.go @@ -0,0 +1,28 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package internal + +import ( + "strings" +) + +func parseFullAppID(appid string) (partition, domain, displayID string) { + if i := strings.Index(appid, "~"); i != -1 { + partition, appid = appid[:i], appid[i+1:] + } + if i := strings.Index(appid, ":"); i != -1 { + domain, appid = appid[:i], appid[i+1:] + } + return partition, domain, appid +} + +// appID returns "appid" or "domain.com:appid". +func appID(fullAppID string) string { + _, dom, dis := parseFullAppID(fullAppID) + if dom != "" { + return dom + ":" + dis + } + return dis +} diff --git a/vendor/google.golang.org/appengine/internal/app_identity/app_identity_service.pb.go b/vendor/google.golang.org/appengine/internal/app_identity/app_identity_service.pb.go new file mode 100644 index 0000000000..87d9701b8d --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/app_identity/app_identity_service.pb.go @@ -0,0 +1,296 @@ +// Code generated by protoc-gen-go. +// source: google.golang.org/appengine/internal/app_identity/app_identity_service.proto +// DO NOT EDIT! + +/* +Package app_identity is a generated protocol buffer package. + +It is generated from these files: + google.golang.org/appengine/internal/app_identity/app_identity_service.proto + +It has these top-level messages: + AppIdentityServiceError + SignForAppRequest + SignForAppResponse + GetPublicCertificateForAppRequest + PublicCertificate + GetPublicCertificateForAppResponse + GetServiceAccountNameRequest + GetServiceAccountNameResponse + GetAccessTokenRequest + GetAccessTokenResponse + GetDefaultGcsBucketNameRequest + GetDefaultGcsBucketNameResponse +*/ +package app_identity + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +type AppIdentityServiceError_ErrorCode int32 + +const ( + AppIdentityServiceError_SUCCESS AppIdentityServiceError_ErrorCode = 0 + AppIdentityServiceError_UNKNOWN_SCOPE AppIdentityServiceError_ErrorCode = 9 + AppIdentityServiceError_BLOB_TOO_LARGE AppIdentityServiceError_ErrorCode = 1000 + AppIdentityServiceError_DEADLINE_EXCEEDED AppIdentityServiceError_ErrorCode = 1001 + AppIdentityServiceError_NOT_A_VALID_APP AppIdentityServiceError_ErrorCode = 1002 + AppIdentityServiceError_UNKNOWN_ERROR AppIdentityServiceError_ErrorCode = 1003 + AppIdentityServiceError_NOT_ALLOWED AppIdentityServiceError_ErrorCode = 1005 + AppIdentityServiceError_NOT_IMPLEMENTED AppIdentityServiceError_ErrorCode = 1006 +) + +var AppIdentityServiceError_ErrorCode_name = map[int32]string{ + 0: "SUCCESS", + 9: "UNKNOWN_SCOPE", + 1000: "BLOB_TOO_LARGE", + 1001: "DEADLINE_EXCEEDED", + 1002: "NOT_A_VALID_APP", + 1003: "UNKNOWN_ERROR", + 1005: "NOT_ALLOWED", + 1006: "NOT_IMPLEMENTED", +} +var AppIdentityServiceError_ErrorCode_value = map[string]int32{ + "SUCCESS": 0, + "UNKNOWN_SCOPE": 9, + "BLOB_TOO_LARGE": 1000, + "DEADLINE_EXCEEDED": 1001, + "NOT_A_VALID_APP": 1002, + "UNKNOWN_ERROR": 1003, + "NOT_ALLOWED": 1005, + "NOT_IMPLEMENTED": 1006, +} + +func (x AppIdentityServiceError_ErrorCode) Enum() *AppIdentityServiceError_ErrorCode { + p := new(AppIdentityServiceError_ErrorCode) + *p = x + return p +} +func (x AppIdentityServiceError_ErrorCode) String() string { + return proto.EnumName(AppIdentityServiceError_ErrorCode_name, int32(x)) +} +func (x *AppIdentityServiceError_ErrorCode) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(AppIdentityServiceError_ErrorCode_value, data, "AppIdentityServiceError_ErrorCode") + if err != nil { + return err + } + *x = AppIdentityServiceError_ErrorCode(value) + return nil +} + +type AppIdentityServiceError struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *AppIdentityServiceError) Reset() { *m = AppIdentityServiceError{} } +func (m *AppIdentityServiceError) String() string { return proto.CompactTextString(m) } +func (*AppIdentityServiceError) ProtoMessage() {} + +type SignForAppRequest struct { + BytesToSign []byte `protobuf:"bytes,1,opt,name=bytes_to_sign" json:"bytes_to_sign,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *SignForAppRequest) Reset() { *m = SignForAppRequest{} } +func (m *SignForAppRequest) String() string { return proto.CompactTextString(m) } +func (*SignForAppRequest) ProtoMessage() {} + +func (m *SignForAppRequest) GetBytesToSign() []byte { + if m != nil { + return m.BytesToSign + } + return nil +} + +type SignForAppResponse struct { + KeyName *string `protobuf:"bytes,1,opt,name=key_name" json:"key_name,omitempty"` + SignatureBytes []byte `protobuf:"bytes,2,opt,name=signature_bytes" json:"signature_bytes,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *SignForAppResponse) Reset() { *m = SignForAppResponse{} } +func (m *SignForAppResponse) String() string { return proto.CompactTextString(m) } +func (*SignForAppResponse) ProtoMessage() {} + +func (m *SignForAppResponse) GetKeyName() string { + if m != nil && m.KeyName != nil { + return *m.KeyName + } + return "" +} + +func (m *SignForAppResponse) GetSignatureBytes() []byte { + if m != nil { + return m.SignatureBytes + } + return nil +} + +type GetPublicCertificateForAppRequest struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetPublicCertificateForAppRequest) Reset() { *m = GetPublicCertificateForAppRequest{} } +func (m *GetPublicCertificateForAppRequest) String() string { return proto.CompactTextString(m) } +func (*GetPublicCertificateForAppRequest) ProtoMessage() {} + +type PublicCertificate struct { + KeyName *string `protobuf:"bytes,1,opt,name=key_name" json:"key_name,omitempty"` + X509CertificatePem *string `protobuf:"bytes,2,opt,name=x509_certificate_pem" json:"x509_certificate_pem,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *PublicCertificate) Reset() { *m = PublicCertificate{} } +func (m *PublicCertificate) String() string { return proto.CompactTextString(m) } +func (*PublicCertificate) ProtoMessage() {} + +func (m *PublicCertificate) GetKeyName() string { + if m != nil && m.KeyName != nil { + return *m.KeyName + } + return "" +} + +func (m *PublicCertificate) GetX509CertificatePem() string { + if m != nil && m.X509CertificatePem != nil { + return *m.X509CertificatePem + } + return "" +} + +type GetPublicCertificateForAppResponse struct { + PublicCertificateList []*PublicCertificate `protobuf:"bytes,1,rep,name=public_certificate_list" json:"public_certificate_list,omitempty"` + MaxClientCacheTimeInSecond *int64 `protobuf:"varint,2,opt,name=max_client_cache_time_in_second" json:"max_client_cache_time_in_second,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetPublicCertificateForAppResponse) Reset() { *m = GetPublicCertificateForAppResponse{} } +func (m *GetPublicCertificateForAppResponse) String() string { return proto.CompactTextString(m) } +func (*GetPublicCertificateForAppResponse) ProtoMessage() {} + +func (m *GetPublicCertificateForAppResponse) GetPublicCertificateList() []*PublicCertificate { + if m != nil { + return m.PublicCertificateList + } + return nil +} + +func (m *GetPublicCertificateForAppResponse) GetMaxClientCacheTimeInSecond() int64 { + if m != nil && m.MaxClientCacheTimeInSecond != nil { + return *m.MaxClientCacheTimeInSecond + } + return 0 +} + +type GetServiceAccountNameRequest struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetServiceAccountNameRequest) Reset() { *m = GetServiceAccountNameRequest{} } +func (m *GetServiceAccountNameRequest) String() string { return proto.CompactTextString(m) } +func (*GetServiceAccountNameRequest) ProtoMessage() {} + +type GetServiceAccountNameResponse struct { + ServiceAccountName *string `protobuf:"bytes,1,opt,name=service_account_name" json:"service_account_name,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetServiceAccountNameResponse) Reset() { *m = GetServiceAccountNameResponse{} } +func (m *GetServiceAccountNameResponse) String() string { return proto.CompactTextString(m) } +func (*GetServiceAccountNameResponse) ProtoMessage() {} + +func (m *GetServiceAccountNameResponse) GetServiceAccountName() string { + if m != nil && m.ServiceAccountName != nil { + return *m.ServiceAccountName + } + return "" +} + +type GetAccessTokenRequest struct { + Scope []string `protobuf:"bytes,1,rep,name=scope" json:"scope,omitempty"` + ServiceAccountId *int64 `protobuf:"varint,2,opt,name=service_account_id" json:"service_account_id,omitempty"` + ServiceAccountName *string `protobuf:"bytes,3,opt,name=service_account_name" json:"service_account_name,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetAccessTokenRequest) Reset() { *m = GetAccessTokenRequest{} } +func (m *GetAccessTokenRequest) String() string { return proto.CompactTextString(m) } +func (*GetAccessTokenRequest) ProtoMessage() {} + +func (m *GetAccessTokenRequest) GetScope() []string { + if m != nil { + return m.Scope + } + return nil +} + +func (m *GetAccessTokenRequest) GetServiceAccountId() int64 { + if m != nil && m.ServiceAccountId != nil { + return *m.ServiceAccountId + } + return 0 +} + +func (m *GetAccessTokenRequest) GetServiceAccountName() string { + if m != nil && m.ServiceAccountName != nil { + return *m.ServiceAccountName + } + return "" +} + +type GetAccessTokenResponse struct { + AccessToken *string `protobuf:"bytes,1,opt,name=access_token" json:"access_token,omitempty"` + ExpirationTime *int64 `protobuf:"varint,2,opt,name=expiration_time" json:"expiration_time,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetAccessTokenResponse) Reset() { *m = GetAccessTokenResponse{} } +func (m *GetAccessTokenResponse) String() string { return proto.CompactTextString(m) } +func (*GetAccessTokenResponse) ProtoMessage() {} + +func (m *GetAccessTokenResponse) GetAccessToken() string { + if m != nil && m.AccessToken != nil { + return *m.AccessToken + } + return "" +} + +func (m *GetAccessTokenResponse) GetExpirationTime() int64 { + if m != nil && m.ExpirationTime != nil { + return *m.ExpirationTime + } + return 0 +} + +type GetDefaultGcsBucketNameRequest struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetDefaultGcsBucketNameRequest) Reset() { *m = GetDefaultGcsBucketNameRequest{} } +func (m *GetDefaultGcsBucketNameRequest) String() string { return proto.CompactTextString(m) } +func (*GetDefaultGcsBucketNameRequest) ProtoMessage() {} + +type GetDefaultGcsBucketNameResponse struct { + DefaultGcsBucketName *string `protobuf:"bytes,1,opt,name=default_gcs_bucket_name" json:"default_gcs_bucket_name,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetDefaultGcsBucketNameResponse) Reset() { *m = GetDefaultGcsBucketNameResponse{} } +func (m *GetDefaultGcsBucketNameResponse) String() string { return proto.CompactTextString(m) } +func (*GetDefaultGcsBucketNameResponse) ProtoMessage() {} + +func (m *GetDefaultGcsBucketNameResponse) GetDefaultGcsBucketName() string { + if m != nil && m.DefaultGcsBucketName != nil { + return *m.DefaultGcsBucketName + } + return "" +} + +func init() { +} diff --git a/vendor/google.golang.org/appengine/internal/app_identity/app_identity_service.proto b/vendor/google.golang.org/appengine/internal/app_identity/app_identity_service.proto new file mode 100644 index 0000000000..19610ca5b7 --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/app_identity/app_identity_service.proto @@ -0,0 +1,64 @@ +syntax = "proto2"; +option go_package = "app_identity"; + +package appengine; + +message AppIdentityServiceError { + enum ErrorCode { + SUCCESS = 0; + UNKNOWN_SCOPE = 9; + BLOB_TOO_LARGE = 1000; + DEADLINE_EXCEEDED = 1001; + NOT_A_VALID_APP = 1002; + UNKNOWN_ERROR = 1003; + NOT_ALLOWED = 1005; + NOT_IMPLEMENTED = 1006; + } +} + +message SignForAppRequest { + optional bytes bytes_to_sign = 1; +} + +message SignForAppResponse { + optional string key_name = 1; + optional bytes signature_bytes = 2; +} + +message GetPublicCertificateForAppRequest { +} + +message PublicCertificate { + optional string key_name = 1; + optional string x509_certificate_pem = 2; +} + +message GetPublicCertificateForAppResponse { + repeated PublicCertificate public_certificate_list = 1; + optional int64 max_client_cache_time_in_second = 2; +} + +message GetServiceAccountNameRequest { +} + +message GetServiceAccountNameResponse { + optional string service_account_name = 1; +} + +message GetAccessTokenRequest { + repeated string scope = 1; + optional int64 service_account_id = 2; + optional string service_account_name = 3; +} + +message GetAccessTokenResponse { + optional string access_token = 1; + optional int64 expiration_time = 2; +} + +message GetDefaultGcsBucketNameRequest { +} + +message GetDefaultGcsBucketNameResponse { + optional string default_gcs_bucket_name = 1; +} diff --git a/vendor/google.golang.org/appengine/internal/base/api_base.pb.go b/vendor/google.golang.org/appengine/internal/base/api_base.pb.go new file mode 100644 index 0000000000..36a195650a --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/base/api_base.pb.go @@ -0,0 +1,133 @@ +// Code generated by protoc-gen-go. +// source: google.golang.org/appengine/internal/base/api_base.proto +// DO NOT EDIT! + +/* +Package base is a generated protocol buffer package. + +It is generated from these files: + google.golang.org/appengine/internal/base/api_base.proto + +It has these top-level messages: + StringProto + Integer32Proto + Integer64Proto + BoolProto + DoubleProto + BytesProto + VoidProto +*/ +package base + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +type StringProto struct { + Value *string `protobuf:"bytes,1,req,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *StringProto) Reset() { *m = StringProto{} } +func (m *StringProto) String() string { return proto.CompactTextString(m) } +func (*StringProto) ProtoMessage() {} + +func (m *StringProto) GetValue() string { + if m != nil && m.Value != nil { + return *m.Value + } + return "" +} + +type Integer32Proto struct { + Value *int32 `protobuf:"varint,1,req,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Integer32Proto) Reset() { *m = Integer32Proto{} } +func (m *Integer32Proto) String() string { return proto.CompactTextString(m) } +func (*Integer32Proto) ProtoMessage() {} + +func (m *Integer32Proto) GetValue() int32 { + if m != nil && m.Value != nil { + return *m.Value + } + return 0 +} + +type Integer64Proto struct { + Value *int64 `protobuf:"varint,1,req,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Integer64Proto) Reset() { *m = Integer64Proto{} } +func (m *Integer64Proto) String() string { return proto.CompactTextString(m) } +func (*Integer64Proto) ProtoMessage() {} + +func (m *Integer64Proto) GetValue() int64 { + if m != nil && m.Value != nil { + return *m.Value + } + return 0 +} + +type BoolProto struct { + Value *bool `protobuf:"varint,1,req,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *BoolProto) Reset() { *m = BoolProto{} } +func (m *BoolProto) String() string { return proto.CompactTextString(m) } +func (*BoolProto) ProtoMessage() {} + +func (m *BoolProto) GetValue() bool { + if m != nil && m.Value != nil { + return *m.Value + } + return false +} + +type DoubleProto struct { + Value *float64 `protobuf:"fixed64,1,req,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *DoubleProto) Reset() { *m = DoubleProto{} } +func (m *DoubleProto) String() string { return proto.CompactTextString(m) } +func (*DoubleProto) ProtoMessage() {} + +func (m *DoubleProto) GetValue() float64 { + if m != nil && m.Value != nil { + return *m.Value + } + return 0 +} + +type BytesProto struct { + Value []byte `protobuf:"bytes,1,req,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *BytesProto) Reset() { *m = BytesProto{} } +func (m *BytesProto) String() string { return proto.CompactTextString(m) } +func (*BytesProto) ProtoMessage() {} + +func (m *BytesProto) GetValue() []byte { + if m != nil { + return m.Value + } + return nil +} + +type VoidProto struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *VoidProto) Reset() { *m = VoidProto{} } +func (m *VoidProto) String() string { return proto.CompactTextString(m) } +func (*VoidProto) ProtoMessage() {} diff --git a/vendor/google.golang.org/appengine/internal/base/api_base.proto b/vendor/google.golang.org/appengine/internal/base/api_base.proto new file mode 100644 index 0000000000..56cd7a3cad --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/base/api_base.proto @@ -0,0 +1,33 @@ +// Built-in base types for API calls. Primarily useful as return types. + +syntax = "proto2"; +option go_package = "base"; + +package appengine.base; + +message StringProto { + required string value = 1; +} + +message Integer32Proto { + required int32 value = 1; +} + +message Integer64Proto { + required int64 value = 1; +} + +message BoolProto { + required bool value = 1; +} + +message DoubleProto { + required double value = 1; +} + +message BytesProto { + required bytes value = 1 [ctype=CORD]; +} + +message VoidProto { +} diff --git a/vendor/google.golang.org/appengine/internal/datastore/datastore_v3.pb.go b/vendor/google.golang.org/appengine/internal/datastore/datastore_v3.pb.go new file mode 100644 index 0000000000..8613cb7311 --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/datastore/datastore_v3.pb.go @@ -0,0 +1,2778 @@ +// Code generated by protoc-gen-go. +// source: google.golang.org/appengine/internal/datastore/datastore_v3.proto +// DO NOT EDIT! + +/* +Package datastore is a generated protocol buffer package. + +It is generated from these files: + google.golang.org/appengine/internal/datastore/datastore_v3.proto + +It has these top-level messages: + Action + PropertyValue + Property + Path + Reference + User + EntityProto + CompositeProperty + Index + CompositeIndex + IndexPostfix + IndexPosition + Snapshot + InternalHeader + Transaction + Query + CompiledQuery + CompiledCursor + Cursor + Error + Cost + GetRequest + GetResponse + PutRequest + PutResponse + TouchRequest + TouchResponse + DeleteRequest + DeleteResponse + NextRequest + QueryResult + AllocateIdsRequest + AllocateIdsResponse + CompositeIndices + AddActionsRequest + AddActionsResponse + BeginTransactionRequest + CommitResponse +*/ +package datastore + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +type Property_Meaning int32 + +const ( + Property_NO_MEANING Property_Meaning = 0 + Property_BLOB Property_Meaning = 14 + Property_TEXT Property_Meaning = 15 + Property_BYTESTRING Property_Meaning = 16 + Property_ATOM_CATEGORY Property_Meaning = 1 + Property_ATOM_LINK Property_Meaning = 2 + Property_ATOM_TITLE Property_Meaning = 3 + Property_ATOM_CONTENT Property_Meaning = 4 + Property_ATOM_SUMMARY Property_Meaning = 5 + Property_ATOM_AUTHOR Property_Meaning = 6 + Property_GD_WHEN Property_Meaning = 7 + Property_GD_EMAIL Property_Meaning = 8 + Property_GEORSS_POINT Property_Meaning = 9 + Property_GD_IM Property_Meaning = 10 + Property_GD_PHONENUMBER Property_Meaning = 11 + Property_GD_POSTALADDRESS Property_Meaning = 12 + Property_GD_RATING Property_Meaning = 13 + Property_BLOBKEY Property_Meaning = 17 + Property_ENTITY_PROTO Property_Meaning = 19 + Property_INDEX_VALUE Property_Meaning = 18 +) + +var Property_Meaning_name = map[int32]string{ + 0: "NO_MEANING", + 14: "BLOB", + 15: "TEXT", + 16: "BYTESTRING", + 1: "ATOM_CATEGORY", + 2: "ATOM_LINK", + 3: "ATOM_TITLE", + 4: "ATOM_CONTENT", + 5: "ATOM_SUMMARY", + 6: "ATOM_AUTHOR", + 7: "GD_WHEN", + 8: "GD_EMAIL", + 9: "GEORSS_POINT", + 10: "GD_IM", + 11: "GD_PHONENUMBER", + 12: "GD_POSTALADDRESS", + 13: "GD_RATING", + 17: "BLOBKEY", + 19: "ENTITY_PROTO", + 18: "INDEX_VALUE", +} +var Property_Meaning_value = map[string]int32{ + "NO_MEANING": 0, + "BLOB": 14, + "TEXT": 15, + "BYTESTRING": 16, + "ATOM_CATEGORY": 1, + "ATOM_LINK": 2, + "ATOM_TITLE": 3, + "ATOM_CONTENT": 4, + "ATOM_SUMMARY": 5, + "ATOM_AUTHOR": 6, + "GD_WHEN": 7, + "GD_EMAIL": 8, + "GEORSS_POINT": 9, + "GD_IM": 10, + "GD_PHONENUMBER": 11, + "GD_POSTALADDRESS": 12, + "GD_RATING": 13, + "BLOBKEY": 17, + "ENTITY_PROTO": 19, + "INDEX_VALUE": 18, +} + +func (x Property_Meaning) Enum() *Property_Meaning { + p := new(Property_Meaning) + *p = x + return p +} +func (x Property_Meaning) String() string { + return proto.EnumName(Property_Meaning_name, int32(x)) +} +func (x *Property_Meaning) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(Property_Meaning_value, data, "Property_Meaning") + if err != nil { + return err + } + *x = Property_Meaning(value) + return nil +} + +type Property_FtsTokenizationOption int32 + +const ( + Property_HTML Property_FtsTokenizationOption = 1 + Property_ATOM Property_FtsTokenizationOption = 2 +) + +var Property_FtsTokenizationOption_name = map[int32]string{ + 1: "HTML", + 2: "ATOM", +} +var Property_FtsTokenizationOption_value = map[string]int32{ + "HTML": 1, + "ATOM": 2, +} + +func (x Property_FtsTokenizationOption) Enum() *Property_FtsTokenizationOption { + p := new(Property_FtsTokenizationOption) + *p = x + return p +} +func (x Property_FtsTokenizationOption) String() string { + return proto.EnumName(Property_FtsTokenizationOption_name, int32(x)) +} +func (x *Property_FtsTokenizationOption) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(Property_FtsTokenizationOption_value, data, "Property_FtsTokenizationOption") + if err != nil { + return err + } + *x = Property_FtsTokenizationOption(value) + return nil +} + +type EntityProto_Kind int32 + +const ( + EntityProto_GD_CONTACT EntityProto_Kind = 1 + EntityProto_GD_EVENT EntityProto_Kind = 2 + EntityProto_GD_MESSAGE EntityProto_Kind = 3 +) + +var EntityProto_Kind_name = map[int32]string{ + 1: "GD_CONTACT", + 2: "GD_EVENT", + 3: "GD_MESSAGE", +} +var EntityProto_Kind_value = map[string]int32{ + "GD_CONTACT": 1, + "GD_EVENT": 2, + "GD_MESSAGE": 3, +} + +func (x EntityProto_Kind) Enum() *EntityProto_Kind { + p := new(EntityProto_Kind) + *p = x + return p +} +func (x EntityProto_Kind) String() string { + return proto.EnumName(EntityProto_Kind_name, int32(x)) +} +func (x *EntityProto_Kind) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(EntityProto_Kind_value, data, "EntityProto_Kind") + if err != nil { + return err + } + *x = EntityProto_Kind(value) + return nil +} + +type Index_Property_Direction int32 + +const ( + Index_Property_ASCENDING Index_Property_Direction = 1 + Index_Property_DESCENDING Index_Property_Direction = 2 +) + +var Index_Property_Direction_name = map[int32]string{ + 1: "ASCENDING", + 2: "DESCENDING", +} +var Index_Property_Direction_value = map[string]int32{ + "ASCENDING": 1, + "DESCENDING": 2, +} + +func (x Index_Property_Direction) Enum() *Index_Property_Direction { + p := new(Index_Property_Direction) + *p = x + return p +} +func (x Index_Property_Direction) String() string { + return proto.EnumName(Index_Property_Direction_name, int32(x)) +} +func (x *Index_Property_Direction) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(Index_Property_Direction_value, data, "Index_Property_Direction") + if err != nil { + return err + } + *x = Index_Property_Direction(value) + return nil +} + +type CompositeIndex_State int32 + +const ( + CompositeIndex_WRITE_ONLY CompositeIndex_State = 1 + CompositeIndex_READ_WRITE CompositeIndex_State = 2 + CompositeIndex_DELETED CompositeIndex_State = 3 + CompositeIndex_ERROR CompositeIndex_State = 4 +) + +var CompositeIndex_State_name = map[int32]string{ + 1: "WRITE_ONLY", + 2: "READ_WRITE", + 3: "DELETED", + 4: "ERROR", +} +var CompositeIndex_State_value = map[string]int32{ + "WRITE_ONLY": 1, + "READ_WRITE": 2, + "DELETED": 3, + "ERROR": 4, +} + +func (x CompositeIndex_State) Enum() *CompositeIndex_State { + p := new(CompositeIndex_State) + *p = x + return p +} +func (x CompositeIndex_State) String() string { + return proto.EnumName(CompositeIndex_State_name, int32(x)) +} +func (x *CompositeIndex_State) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(CompositeIndex_State_value, data, "CompositeIndex_State") + if err != nil { + return err + } + *x = CompositeIndex_State(value) + return nil +} + +type Snapshot_Status int32 + +const ( + Snapshot_INACTIVE Snapshot_Status = 0 + Snapshot_ACTIVE Snapshot_Status = 1 +) + +var Snapshot_Status_name = map[int32]string{ + 0: "INACTIVE", + 1: "ACTIVE", +} +var Snapshot_Status_value = map[string]int32{ + "INACTIVE": 0, + "ACTIVE": 1, +} + +func (x Snapshot_Status) Enum() *Snapshot_Status { + p := new(Snapshot_Status) + *p = x + return p +} +func (x Snapshot_Status) String() string { + return proto.EnumName(Snapshot_Status_name, int32(x)) +} +func (x *Snapshot_Status) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(Snapshot_Status_value, data, "Snapshot_Status") + if err != nil { + return err + } + *x = Snapshot_Status(value) + return nil +} + +type Query_Hint int32 + +const ( + Query_ORDER_FIRST Query_Hint = 1 + Query_ANCESTOR_FIRST Query_Hint = 2 + Query_FILTER_FIRST Query_Hint = 3 +) + +var Query_Hint_name = map[int32]string{ + 1: "ORDER_FIRST", + 2: "ANCESTOR_FIRST", + 3: "FILTER_FIRST", +} +var Query_Hint_value = map[string]int32{ + "ORDER_FIRST": 1, + "ANCESTOR_FIRST": 2, + "FILTER_FIRST": 3, +} + +func (x Query_Hint) Enum() *Query_Hint { + p := new(Query_Hint) + *p = x + return p +} +func (x Query_Hint) String() string { + return proto.EnumName(Query_Hint_name, int32(x)) +} +func (x *Query_Hint) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(Query_Hint_value, data, "Query_Hint") + if err != nil { + return err + } + *x = Query_Hint(value) + return nil +} + +type Query_Filter_Operator int32 + +const ( + Query_Filter_LESS_THAN Query_Filter_Operator = 1 + Query_Filter_LESS_THAN_OR_EQUAL Query_Filter_Operator = 2 + Query_Filter_GREATER_THAN Query_Filter_Operator = 3 + Query_Filter_GREATER_THAN_OR_EQUAL Query_Filter_Operator = 4 + Query_Filter_EQUAL Query_Filter_Operator = 5 + Query_Filter_IN Query_Filter_Operator = 6 + Query_Filter_EXISTS Query_Filter_Operator = 7 +) + +var Query_Filter_Operator_name = map[int32]string{ + 1: "LESS_THAN", + 2: "LESS_THAN_OR_EQUAL", + 3: "GREATER_THAN", + 4: "GREATER_THAN_OR_EQUAL", + 5: "EQUAL", + 6: "IN", + 7: "EXISTS", +} +var Query_Filter_Operator_value = map[string]int32{ + "LESS_THAN": 1, + "LESS_THAN_OR_EQUAL": 2, + "GREATER_THAN": 3, + "GREATER_THAN_OR_EQUAL": 4, + "EQUAL": 5, + "IN": 6, + "EXISTS": 7, +} + +func (x Query_Filter_Operator) Enum() *Query_Filter_Operator { + p := new(Query_Filter_Operator) + *p = x + return p +} +func (x Query_Filter_Operator) String() string { + return proto.EnumName(Query_Filter_Operator_name, int32(x)) +} +func (x *Query_Filter_Operator) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(Query_Filter_Operator_value, data, "Query_Filter_Operator") + if err != nil { + return err + } + *x = Query_Filter_Operator(value) + return nil +} + +type Query_Order_Direction int32 + +const ( + Query_Order_ASCENDING Query_Order_Direction = 1 + Query_Order_DESCENDING Query_Order_Direction = 2 +) + +var Query_Order_Direction_name = map[int32]string{ + 1: "ASCENDING", + 2: "DESCENDING", +} +var Query_Order_Direction_value = map[string]int32{ + "ASCENDING": 1, + "DESCENDING": 2, +} + +func (x Query_Order_Direction) Enum() *Query_Order_Direction { + p := new(Query_Order_Direction) + *p = x + return p +} +func (x Query_Order_Direction) String() string { + return proto.EnumName(Query_Order_Direction_name, int32(x)) +} +func (x *Query_Order_Direction) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(Query_Order_Direction_value, data, "Query_Order_Direction") + if err != nil { + return err + } + *x = Query_Order_Direction(value) + return nil +} + +type Error_ErrorCode int32 + +const ( + Error_BAD_REQUEST Error_ErrorCode = 1 + Error_CONCURRENT_TRANSACTION Error_ErrorCode = 2 + Error_INTERNAL_ERROR Error_ErrorCode = 3 + Error_NEED_INDEX Error_ErrorCode = 4 + Error_TIMEOUT Error_ErrorCode = 5 + Error_PERMISSION_DENIED Error_ErrorCode = 6 + Error_BIGTABLE_ERROR Error_ErrorCode = 7 + Error_COMMITTED_BUT_STILL_APPLYING Error_ErrorCode = 8 + Error_CAPABILITY_DISABLED Error_ErrorCode = 9 + Error_TRY_ALTERNATE_BACKEND Error_ErrorCode = 10 + Error_SAFE_TIME_TOO_OLD Error_ErrorCode = 11 +) + +var Error_ErrorCode_name = map[int32]string{ + 1: "BAD_REQUEST", + 2: "CONCURRENT_TRANSACTION", + 3: "INTERNAL_ERROR", + 4: "NEED_INDEX", + 5: "TIMEOUT", + 6: "PERMISSION_DENIED", + 7: "BIGTABLE_ERROR", + 8: "COMMITTED_BUT_STILL_APPLYING", + 9: "CAPABILITY_DISABLED", + 10: "TRY_ALTERNATE_BACKEND", + 11: "SAFE_TIME_TOO_OLD", +} +var Error_ErrorCode_value = map[string]int32{ + "BAD_REQUEST": 1, + "CONCURRENT_TRANSACTION": 2, + "INTERNAL_ERROR": 3, + "NEED_INDEX": 4, + "TIMEOUT": 5, + "PERMISSION_DENIED": 6, + "BIGTABLE_ERROR": 7, + "COMMITTED_BUT_STILL_APPLYING": 8, + "CAPABILITY_DISABLED": 9, + "TRY_ALTERNATE_BACKEND": 10, + "SAFE_TIME_TOO_OLD": 11, +} + +func (x Error_ErrorCode) Enum() *Error_ErrorCode { + p := new(Error_ErrorCode) + *p = x + return p +} +func (x Error_ErrorCode) String() string { + return proto.EnumName(Error_ErrorCode_name, int32(x)) +} +func (x *Error_ErrorCode) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(Error_ErrorCode_value, data, "Error_ErrorCode") + if err != nil { + return err + } + *x = Error_ErrorCode(value) + return nil +} + +type PutRequest_AutoIdPolicy int32 + +const ( + PutRequest_CURRENT PutRequest_AutoIdPolicy = 0 + PutRequest_SEQUENTIAL PutRequest_AutoIdPolicy = 1 +) + +var PutRequest_AutoIdPolicy_name = map[int32]string{ + 0: "CURRENT", + 1: "SEQUENTIAL", +} +var PutRequest_AutoIdPolicy_value = map[string]int32{ + "CURRENT": 0, + "SEQUENTIAL": 1, +} + +func (x PutRequest_AutoIdPolicy) Enum() *PutRequest_AutoIdPolicy { + p := new(PutRequest_AutoIdPolicy) + *p = x + return p +} +func (x PutRequest_AutoIdPolicy) String() string { + return proto.EnumName(PutRequest_AutoIdPolicy_name, int32(x)) +} +func (x *PutRequest_AutoIdPolicy) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(PutRequest_AutoIdPolicy_value, data, "PutRequest_AutoIdPolicy") + if err != nil { + return err + } + *x = PutRequest_AutoIdPolicy(value) + return nil +} + +type Action struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *Action) Reset() { *m = Action{} } +func (m *Action) String() string { return proto.CompactTextString(m) } +func (*Action) ProtoMessage() {} + +type PropertyValue struct { + Int64Value *int64 `protobuf:"varint,1,opt,name=int64Value" json:"int64Value,omitempty"` + BooleanValue *bool `protobuf:"varint,2,opt,name=booleanValue" json:"booleanValue,omitempty"` + StringValue *string `protobuf:"bytes,3,opt,name=stringValue" json:"stringValue,omitempty"` + DoubleValue *float64 `protobuf:"fixed64,4,opt,name=doubleValue" json:"doubleValue,omitempty"` + Pointvalue *PropertyValue_PointValue `protobuf:"group,5,opt,name=PointValue" json:"pointvalue,omitempty"` + Uservalue *PropertyValue_UserValue `protobuf:"group,8,opt,name=UserValue" json:"uservalue,omitempty"` + Referencevalue *PropertyValue_ReferenceValue `protobuf:"group,12,opt,name=ReferenceValue" json:"referencevalue,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *PropertyValue) Reset() { *m = PropertyValue{} } +func (m *PropertyValue) String() string { return proto.CompactTextString(m) } +func (*PropertyValue) ProtoMessage() {} + +func (m *PropertyValue) GetInt64Value() int64 { + if m != nil && m.Int64Value != nil { + return *m.Int64Value + } + return 0 +} + +func (m *PropertyValue) GetBooleanValue() bool { + if m != nil && m.BooleanValue != nil { + return *m.BooleanValue + } + return false +} + +func (m *PropertyValue) GetStringValue() string { + if m != nil && m.StringValue != nil { + return *m.StringValue + } + return "" +} + +func (m *PropertyValue) GetDoubleValue() float64 { + if m != nil && m.DoubleValue != nil { + return *m.DoubleValue + } + return 0 +} + +func (m *PropertyValue) GetPointvalue() *PropertyValue_PointValue { + if m != nil { + return m.Pointvalue + } + return nil +} + +func (m *PropertyValue) GetUservalue() *PropertyValue_UserValue { + if m != nil { + return m.Uservalue + } + return nil +} + +func (m *PropertyValue) GetReferencevalue() *PropertyValue_ReferenceValue { + if m != nil { + return m.Referencevalue + } + return nil +} + +type PropertyValue_PointValue struct { + X *float64 `protobuf:"fixed64,6,req,name=x" json:"x,omitempty"` + Y *float64 `protobuf:"fixed64,7,req,name=y" json:"y,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *PropertyValue_PointValue) Reset() { *m = PropertyValue_PointValue{} } +func (m *PropertyValue_PointValue) String() string { return proto.CompactTextString(m) } +func (*PropertyValue_PointValue) ProtoMessage() {} + +func (m *PropertyValue_PointValue) GetX() float64 { + if m != nil && m.X != nil { + return *m.X + } + return 0 +} + +func (m *PropertyValue_PointValue) GetY() float64 { + if m != nil && m.Y != nil { + return *m.Y + } + return 0 +} + +type PropertyValue_UserValue struct { + Email *string `protobuf:"bytes,9,req,name=email" json:"email,omitempty"` + AuthDomain *string `protobuf:"bytes,10,req,name=auth_domain" json:"auth_domain,omitempty"` + Nickname *string `protobuf:"bytes,11,opt,name=nickname" json:"nickname,omitempty"` + FederatedIdentity *string `protobuf:"bytes,21,opt,name=federated_identity" json:"federated_identity,omitempty"` + FederatedProvider *string `protobuf:"bytes,22,opt,name=federated_provider" json:"federated_provider,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *PropertyValue_UserValue) Reset() { *m = PropertyValue_UserValue{} } +func (m *PropertyValue_UserValue) String() string { return proto.CompactTextString(m) } +func (*PropertyValue_UserValue) ProtoMessage() {} + +func (m *PropertyValue_UserValue) GetEmail() string { + if m != nil && m.Email != nil { + return *m.Email + } + return "" +} + +func (m *PropertyValue_UserValue) GetAuthDomain() string { + if m != nil && m.AuthDomain != nil { + return *m.AuthDomain + } + return "" +} + +func (m *PropertyValue_UserValue) GetNickname() string { + if m != nil && m.Nickname != nil { + return *m.Nickname + } + return "" +} + +func (m *PropertyValue_UserValue) GetFederatedIdentity() string { + if m != nil && m.FederatedIdentity != nil { + return *m.FederatedIdentity + } + return "" +} + +func (m *PropertyValue_UserValue) GetFederatedProvider() string { + if m != nil && m.FederatedProvider != nil { + return *m.FederatedProvider + } + return "" +} + +type PropertyValue_ReferenceValue struct { + App *string `protobuf:"bytes,13,req,name=app" json:"app,omitempty"` + NameSpace *string `protobuf:"bytes,20,opt,name=name_space" json:"name_space,omitempty"` + Pathelement []*PropertyValue_ReferenceValue_PathElement `protobuf:"group,14,rep,name=PathElement" json:"pathelement,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *PropertyValue_ReferenceValue) Reset() { *m = PropertyValue_ReferenceValue{} } +func (m *PropertyValue_ReferenceValue) String() string { return proto.CompactTextString(m) } +func (*PropertyValue_ReferenceValue) ProtoMessage() {} + +func (m *PropertyValue_ReferenceValue) GetApp() string { + if m != nil && m.App != nil { + return *m.App + } + return "" +} + +func (m *PropertyValue_ReferenceValue) GetNameSpace() string { + if m != nil && m.NameSpace != nil { + return *m.NameSpace + } + return "" +} + +func (m *PropertyValue_ReferenceValue) GetPathelement() []*PropertyValue_ReferenceValue_PathElement { + if m != nil { + return m.Pathelement + } + return nil +} + +type PropertyValue_ReferenceValue_PathElement struct { + Type *string `protobuf:"bytes,15,req,name=type" json:"type,omitempty"` + Id *int64 `protobuf:"varint,16,opt,name=id" json:"id,omitempty"` + Name *string `protobuf:"bytes,17,opt,name=name" json:"name,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *PropertyValue_ReferenceValue_PathElement) Reset() { + *m = PropertyValue_ReferenceValue_PathElement{} +} +func (m *PropertyValue_ReferenceValue_PathElement) String() string { return proto.CompactTextString(m) } +func (*PropertyValue_ReferenceValue_PathElement) ProtoMessage() {} + +func (m *PropertyValue_ReferenceValue_PathElement) GetType() string { + if m != nil && m.Type != nil { + return *m.Type + } + return "" +} + +func (m *PropertyValue_ReferenceValue_PathElement) GetId() int64 { + if m != nil && m.Id != nil { + return *m.Id + } + return 0 +} + +func (m *PropertyValue_ReferenceValue_PathElement) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +type Property struct { + Meaning *Property_Meaning `protobuf:"varint,1,opt,name=meaning,enum=appengine.Property_Meaning,def=0" json:"meaning,omitempty"` + MeaningUri *string `protobuf:"bytes,2,opt,name=meaning_uri" json:"meaning_uri,omitempty"` + Name *string `protobuf:"bytes,3,req,name=name" json:"name,omitempty"` + Value *PropertyValue `protobuf:"bytes,5,req,name=value" json:"value,omitempty"` + Multiple *bool `protobuf:"varint,4,req,name=multiple" json:"multiple,omitempty"` + Searchable *bool `protobuf:"varint,6,opt,name=searchable,def=0" json:"searchable,omitempty"` + FtsTokenizationOption *Property_FtsTokenizationOption `protobuf:"varint,8,opt,name=fts_tokenization_option,enum=appengine.Property_FtsTokenizationOption" json:"fts_tokenization_option,omitempty"` + Locale *string `protobuf:"bytes,9,opt,name=locale,def=en" json:"locale,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Property) Reset() { *m = Property{} } +func (m *Property) String() string { return proto.CompactTextString(m) } +func (*Property) ProtoMessage() {} + +const Default_Property_Meaning Property_Meaning = Property_NO_MEANING +const Default_Property_Searchable bool = false +const Default_Property_Locale string = "en" + +func (m *Property) GetMeaning() Property_Meaning { + if m != nil && m.Meaning != nil { + return *m.Meaning + } + return Default_Property_Meaning +} + +func (m *Property) GetMeaningUri() string { + if m != nil && m.MeaningUri != nil { + return *m.MeaningUri + } + return "" +} + +func (m *Property) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *Property) GetValue() *PropertyValue { + if m != nil { + return m.Value + } + return nil +} + +func (m *Property) GetMultiple() bool { + if m != nil && m.Multiple != nil { + return *m.Multiple + } + return false +} + +func (m *Property) GetSearchable() bool { + if m != nil && m.Searchable != nil { + return *m.Searchable + } + return Default_Property_Searchable +} + +func (m *Property) GetFtsTokenizationOption() Property_FtsTokenizationOption { + if m != nil && m.FtsTokenizationOption != nil { + return *m.FtsTokenizationOption + } + return Property_HTML +} + +func (m *Property) GetLocale() string { + if m != nil && m.Locale != nil { + return *m.Locale + } + return Default_Property_Locale +} + +type Path struct { + Element []*Path_Element `protobuf:"group,1,rep,name=Element" json:"element,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Path) Reset() { *m = Path{} } +func (m *Path) String() string { return proto.CompactTextString(m) } +func (*Path) ProtoMessage() {} + +func (m *Path) GetElement() []*Path_Element { + if m != nil { + return m.Element + } + return nil +} + +type Path_Element struct { + Type *string `protobuf:"bytes,2,req,name=type" json:"type,omitempty"` + Id *int64 `protobuf:"varint,3,opt,name=id" json:"id,omitempty"` + Name *string `protobuf:"bytes,4,opt,name=name" json:"name,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Path_Element) Reset() { *m = Path_Element{} } +func (m *Path_Element) String() string { return proto.CompactTextString(m) } +func (*Path_Element) ProtoMessage() {} + +func (m *Path_Element) GetType() string { + if m != nil && m.Type != nil { + return *m.Type + } + return "" +} + +func (m *Path_Element) GetId() int64 { + if m != nil && m.Id != nil { + return *m.Id + } + return 0 +} + +func (m *Path_Element) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +type Reference struct { + App *string `protobuf:"bytes,13,req,name=app" json:"app,omitempty"` + NameSpace *string `protobuf:"bytes,20,opt,name=name_space" json:"name_space,omitempty"` + Path *Path `protobuf:"bytes,14,req,name=path" json:"path,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Reference) Reset() { *m = Reference{} } +func (m *Reference) String() string { return proto.CompactTextString(m) } +func (*Reference) ProtoMessage() {} + +func (m *Reference) GetApp() string { + if m != nil && m.App != nil { + return *m.App + } + return "" +} + +func (m *Reference) GetNameSpace() string { + if m != nil && m.NameSpace != nil { + return *m.NameSpace + } + return "" +} + +func (m *Reference) GetPath() *Path { + if m != nil { + return m.Path + } + return nil +} + +type User struct { + Email *string `protobuf:"bytes,1,req,name=email" json:"email,omitempty"` + AuthDomain *string `protobuf:"bytes,2,req,name=auth_domain" json:"auth_domain,omitempty"` + Nickname *string `protobuf:"bytes,3,opt,name=nickname" json:"nickname,omitempty"` + FederatedIdentity *string `protobuf:"bytes,6,opt,name=federated_identity" json:"federated_identity,omitempty"` + FederatedProvider *string `protobuf:"bytes,7,opt,name=federated_provider" json:"federated_provider,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *User) Reset() { *m = User{} } +func (m *User) String() string { return proto.CompactTextString(m) } +func (*User) ProtoMessage() {} + +func (m *User) GetEmail() string { + if m != nil && m.Email != nil { + return *m.Email + } + return "" +} + +func (m *User) GetAuthDomain() string { + if m != nil && m.AuthDomain != nil { + return *m.AuthDomain + } + return "" +} + +func (m *User) GetNickname() string { + if m != nil && m.Nickname != nil { + return *m.Nickname + } + return "" +} + +func (m *User) GetFederatedIdentity() string { + if m != nil && m.FederatedIdentity != nil { + return *m.FederatedIdentity + } + return "" +} + +func (m *User) GetFederatedProvider() string { + if m != nil && m.FederatedProvider != nil { + return *m.FederatedProvider + } + return "" +} + +type EntityProto struct { + Key *Reference `protobuf:"bytes,13,req,name=key" json:"key,omitempty"` + EntityGroup *Path `protobuf:"bytes,16,req,name=entity_group" json:"entity_group,omitempty"` + Owner *User `protobuf:"bytes,17,opt,name=owner" json:"owner,omitempty"` + Kind *EntityProto_Kind `protobuf:"varint,4,opt,name=kind,enum=appengine.EntityProto_Kind" json:"kind,omitempty"` + KindUri *string `protobuf:"bytes,5,opt,name=kind_uri" json:"kind_uri,omitempty"` + Property []*Property `protobuf:"bytes,14,rep,name=property" json:"property,omitempty"` + RawProperty []*Property `protobuf:"bytes,15,rep,name=raw_property" json:"raw_property,omitempty"` + Rank *int32 `protobuf:"varint,18,opt,name=rank" json:"rank,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *EntityProto) Reset() { *m = EntityProto{} } +func (m *EntityProto) String() string { return proto.CompactTextString(m) } +func (*EntityProto) ProtoMessage() {} + +func (m *EntityProto) GetKey() *Reference { + if m != nil { + return m.Key + } + return nil +} + +func (m *EntityProto) GetEntityGroup() *Path { + if m != nil { + return m.EntityGroup + } + return nil +} + +func (m *EntityProto) GetOwner() *User { + if m != nil { + return m.Owner + } + return nil +} + +func (m *EntityProto) GetKind() EntityProto_Kind { + if m != nil && m.Kind != nil { + return *m.Kind + } + return EntityProto_GD_CONTACT +} + +func (m *EntityProto) GetKindUri() string { + if m != nil && m.KindUri != nil { + return *m.KindUri + } + return "" +} + +func (m *EntityProto) GetProperty() []*Property { + if m != nil { + return m.Property + } + return nil +} + +func (m *EntityProto) GetRawProperty() []*Property { + if m != nil { + return m.RawProperty + } + return nil +} + +func (m *EntityProto) GetRank() int32 { + if m != nil && m.Rank != nil { + return *m.Rank + } + return 0 +} + +type CompositeProperty struct { + IndexId *int64 `protobuf:"varint,1,req,name=index_id" json:"index_id,omitempty"` + Value []string `protobuf:"bytes,2,rep,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CompositeProperty) Reset() { *m = CompositeProperty{} } +func (m *CompositeProperty) String() string { return proto.CompactTextString(m) } +func (*CompositeProperty) ProtoMessage() {} + +func (m *CompositeProperty) GetIndexId() int64 { + if m != nil && m.IndexId != nil { + return *m.IndexId + } + return 0 +} + +func (m *CompositeProperty) GetValue() []string { + if m != nil { + return m.Value + } + return nil +} + +type Index struct { + EntityType *string `protobuf:"bytes,1,req,name=entity_type" json:"entity_type,omitempty"` + Ancestor *bool `protobuf:"varint,5,req,name=ancestor" json:"ancestor,omitempty"` + Property []*Index_Property `protobuf:"group,2,rep,name=Property" json:"property,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Index) Reset() { *m = Index{} } +func (m *Index) String() string { return proto.CompactTextString(m) } +func (*Index) ProtoMessage() {} + +func (m *Index) GetEntityType() string { + if m != nil && m.EntityType != nil { + return *m.EntityType + } + return "" +} + +func (m *Index) GetAncestor() bool { + if m != nil && m.Ancestor != nil { + return *m.Ancestor + } + return false +} + +func (m *Index) GetProperty() []*Index_Property { + if m != nil { + return m.Property + } + return nil +} + +type Index_Property struct { + Name *string `protobuf:"bytes,3,req,name=name" json:"name,omitempty"` + Direction *Index_Property_Direction `protobuf:"varint,4,opt,name=direction,enum=appengine.Index_Property_Direction,def=1" json:"direction,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Index_Property) Reset() { *m = Index_Property{} } +func (m *Index_Property) String() string { return proto.CompactTextString(m) } +func (*Index_Property) ProtoMessage() {} + +const Default_Index_Property_Direction Index_Property_Direction = Index_Property_ASCENDING + +func (m *Index_Property) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *Index_Property) GetDirection() Index_Property_Direction { + if m != nil && m.Direction != nil { + return *m.Direction + } + return Default_Index_Property_Direction +} + +type CompositeIndex struct { + AppId *string `protobuf:"bytes,1,req,name=app_id" json:"app_id,omitempty"` + Id *int64 `protobuf:"varint,2,req,name=id" json:"id,omitempty"` + Definition *Index `protobuf:"bytes,3,req,name=definition" json:"definition,omitempty"` + State *CompositeIndex_State `protobuf:"varint,4,req,name=state,enum=appengine.CompositeIndex_State" json:"state,omitempty"` + OnlyUseIfRequired *bool `protobuf:"varint,6,opt,name=only_use_if_required,def=0" json:"only_use_if_required,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CompositeIndex) Reset() { *m = CompositeIndex{} } +func (m *CompositeIndex) String() string { return proto.CompactTextString(m) } +func (*CompositeIndex) ProtoMessage() {} + +const Default_CompositeIndex_OnlyUseIfRequired bool = false + +func (m *CompositeIndex) GetAppId() string { + if m != nil && m.AppId != nil { + return *m.AppId + } + return "" +} + +func (m *CompositeIndex) GetId() int64 { + if m != nil && m.Id != nil { + return *m.Id + } + return 0 +} + +func (m *CompositeIndex) GetDefinition() *Index { + if m != nil { + return m.Definition + } + return nil +} + +func (m *CompositeIndex) GetState() CompositeIndex_State { + if m != nil && m.State != nil { + return *m.State + } + return CompositeIndex_WRITE_ONLY +} + +func (m *CompositeIndex) GetOnlyUseIfRequired() bool { + if m != nil && m.OnlyUseIfRequired != nil { + return *m.OnlyUseIfRequired + } + return Default_CompositeIndex_OnlyUseIfRequired +} + +type IndexPostfix struct { + IndexValue []*IndexPostfix_IndexValue `protobuf:"bytes,1,rep,name=index_value" json:"index_value,omitempty"` + Key *Reference `protobuf:"bytes,2,opt,name=key" json:"key,omitempty"` + Before *bool `protobuf:"varint,3,opt,name=before,def=1" json:"before,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *IndexPostfix) Reset() { *m = IndexPostfix{} } +func (m *IndexPostfix) String() string { return proto.CompactTextString(m) } +func (*IndexPostfix) ProtoMessage() {} + +const Default_IndexPostfix_Before bool = true + +func (m *IndexPostfix) GetIndexValue() []*IndexPostfix_IndexValue { + if m != nil { + return m.IndexValue + } + return nil +} + +func (m *IndexPostfix) GetKey() *Reference { + if m != nil { + return m.Key + } + return nil +} + +func (m *IndexPostfix) GetBefore() bool { + if m != nil && m.Before != nil { + return *m.Before + } + return Default_IndexPostfix_Before +} + +type IndexPostfix_IndexValue struct { + PropertyName *string `protobuf:"bytes,1,req,name=property_name" json:"property_name,omitempty"` + Value *PropertyValue `protobuf:"bytes,2,req,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *IndexPostfix_IndexValue) Reset() { *m = IndexPostfix_IndexValue{} } +func (m *IndexPostfix_IndexValue) String() string { return proto.CompactTextString(m) } +func (*IndexPostfix_IndexValue) ProtoMessage() {} + +func (m *IndexPostfix_IndexValue) GetPropertyName() string { + if m != nil && m.PropertyName != nil { + return *m.PropertyName + } + return "" +} + +func (m *IndexPostfix_IndexValue) GetValue() *PropertyValue { + if m != nil { + return m.Value + } + return nil +} + +type IndexPosition struct { + Key *string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` + Before *bool `protobuf:"varint,2,opt,name=before,def=1" json:"before,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *IndexPosition) Reset() { *m = IndexPosition{} } +func (m *IndexPosition) String() string { return proto.CompactTextString(m) } +func (*IndexPosition) ProtoMessage() {} + +const Default_IndexPosition_Before bool = true + +func (m *IndexPosition) GetKey() string { + if m != nil && m.Key != nil { + return *m.Key + } + return "" +} + +func (m *IndexPosition) GetBefore() bool { + if m != nil && m.Before != nil { + return *m.Before + } + return Default_IndexPosition_Before +} + +type Snapshot struct { + Ts *int64 `protobuf:"varint,1,req,name=ts" json:"ts,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Snapshot) Reset() { *m = Snapshot{} } +func (m *Snapshot) String() string { return proto.CompactTextString(m) } +func (*Snapshot) ProtoMessage() {} + +func (m *Snapshot) GetTs() int64 { + if m != nil && m.Ts != nil { + return *m.Ts + } + return 0 +} + +type InternalHeader struct { + Qos *string `protobuf:"bytes,1,opt,name=qos" json:"qos,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *InternalHeader) Reset() { *m = InternalHeader{} } +func (m *InternalHeader) String() string { return proto.CompactTextString(m) } +func (*InternalHeader) ProtoMessage() {} + +func (m *InternalHeader) GetQos() string { + if m != nil && m.Qos != nil { + return *m.Qos + } + return "" +} + +type Transaction struct { + Header *InternalHeader `protobuf:"bytes,4,opt,name=header" json:"header,omitempty"` + Handle *uint64 `protobuf:"fixed64,1,req,name=handle" json:"handle,omitempty"` + App *string `protobuf:"bytes,2,req,name=app" json:"app,omitempty"` + MarkChanges *bool `protobuf:"varint,3,opt,name=mark_changes,def=0" json:"mark_changes,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Transaction) Reset() { *m = Transaction{} } +func (m *Transaction) String() string { return proto.CompactTextString(m) } +func (*Transaction) ProtoMessage() {} + +const Default_Transaction_MarkChanges bool = false + +func (m *Transaction) GetHeader() *InternalHeader { + if m != nil { + return m.Header + } + return nil +} + +func (m *Transaction) GetHandle() uint64 { + if m != nil && m.Handle != nil { + return *m.Handle + } + return 0 +} + +func (m *Transaction) GetApp() string { + if m != nil && m.App != nil { + return *m.App + } + return "" +} + +func (m *Transaction) GetMarkChanges() bool { + if m != nil && m.MarkChanges != nil { + return *m.MarkChanges + } + return Default_Transaction_MarkChanges +} + +type Query struct { + Header *InternalHeader `protobuf:"bytes,39,opt,name=header" json:"header,omitempty"` + App *string `protobuf:"bytes,1,req,name=app" json:"app,omitempty"` + NameSpace *string `protobuf:"bytes,29,opt,name=name_space" json:"name_space,omitempty"` + Kind *string `protobuf:"bytes,3,opt,name=kind" json:"kind,omitempty"` + Ancestor *Reference `protobuf:"bytes,17,opt,name=ancestor" json:"ancestor,omitempty"` + Filter []*Query_Filter `protobuf:"group,4,rep,name=Filter" json:"filter,omitempty"` + SearchQuery *string `protobuf:"bytes,8,opt,name=search_query" json:"search_query,omitempty"` + Order []*Query_Order `protobuf:"group,9,rep,name=Order" json:"order,omitempty"` + Hint *Query_Hint `protobuf:"varint,18,opt,name=hint,enum=appengine.Query_Hint" json:"hint,omitempty"` + Count *int32 `protobuf:"varint,23,opt,name=count" json:"count,omitempty"` + Offset *int32 `protobuf:"varint,12,opt,name=offset,def=0" json:"offset,omitempty"` + Limit *int32 `protobuf:"varint,16,opt,name=limit" json:"limit,omitempty"` + CompiledCursor *CompiledCursor `protobuf:"bytes,30,opt,name=compiled_cursor" json:"compiled_cursor,omitempty"` + EndCompiledCursor *CompiledCursor `protobuf:"bytes,31,opt,name=end_compiled_cursor" json:"end_compiled_cursor,omitempty"` + CompositeIndex []*CompositeIndex `protobuf:"bytes,19,rep,name=composite_index" json:"composite_index,omitempty"` + RequirePerfectPlan *bool `protobuf:"varint,20,opt,name=require_perfect_plan,def=0" json:"require_perfect_plan,omitempty"` + KeysOnly *bool `protobuf:"varint,21,opt,name=keys_only,def=0" json:"keys_only,omitempty"` + Transaction *Transaction `protobuf:"bytes,22,opt,name=transaction" json:"transaction,omitempty"` + Compile *bool `protobuf:"varint,25,opt,name=compile,def=0" json:"compile,omitempty"` + FailoverMs *int64 `protobuf:"varint,26,opt,name=failover_ms" json:"failover_ms,omitempty"` + Strong *bool `protobuf:"varint,32,opt,name=strong" json:"strong,omitempty"` + PropertyName []string `protobuf:"bytes,33,rep,name=property_name" json:"property_name,omitempty"` + GroupByPropertyName []string `protobuf:"bytes,34,rep,name=group_by_property_name" json:"group_by_property_name,omitempty"` + Distinct *bool `protobuf:"varint,24,opt,name=distinct" json:"distinct,omitempty"` + MinSafeTimeSeconds *int64 `protobuf:"varint,35,opt,name=min_safe_time_seconds" json:"min_safe_time_seconds,omitempty"` + SafeReplicaName []string `protobuf:"bytes,36,rep,name=safe_replica_name" json:"safe_replica_name,omitempty"` + PersistOffset *bool `protobuf:"varint,37,opt,name=persist_offset,def=0" json:"persist_offset,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Query) Reset() { *m = Query{} } +func (m *Query) String() string { return proto.CompactTextString(m) } +func (*Query) ProtoMessage() {} + +const Default_Query_Offset int32 = 0 +const Default_Query_RequirePerfectPlan bool = false +const Default_Query_KeysOnly bool = false +const Default_Query_Compile bool = false +const Default_Query_PersistOffset bool = false + +func (m *Query) GetHeader() *InternalHeader { + if m != nil { + return m.Header + } + return nil +} + +func (m *Query) GetApp() string { + if m != nil && m.App != nil { + return *m.App + } + return "" +} + +func (m *Query) GetNameSpace() string { + if m != nil && m.NameSpace != nil { + return *m.NameSpace + } + return "" +} + +func (m *Query) GetKind() string { + if m != nil && m.Kind != nil { + return *m.Kind + } + return "" +} + +func (m *Query) GetAncestor() *Reference { + if m != nil { + return m.Ancestor + } + return nil +} + +func (m *Query) GetFilter() []*Query_Filter { + if m != nil { + return m.Filter + } + return nil +} + +func (m *Query) GetSearchQuery() string { + if m != nil && m.SearchQuery != nil { + return *m.SearchQuery + } + return "" +} + +func (m *Query) GetOrder() []*Query_Order { + if m != nil { + return m.Order + } + return nil +} + +func (m *Query) GetHint() Query_Hint { + if m != nil && m.Hint != nil { + return *m.Hint + } + return Query_ORDER_FIRST +} + +func (m *Query) GetCount() int32 { + if m != nil && m.Count != nil { + return *m.Count + } + return 0 +} + +func (m *Query) GetOffset() int32 { + if m != nil && m.Offset != nil { + return *m.Offset + } + return Default_Query_Offset +} + +func (m *Query) GetLimit() int32 { + if m != nil && m.Limit != nil { + return *m.Limit + } + return 0 +} + +func (m *Query) GetCompiledCursor() *CompiledCursor { + if m != nil { + return m.CompiledCursor + } + return nil +} + +func (m *Query) GetEndCompiledCursor() *CompiledCursor { + if m != nil { + return m.EndCompiledCursor + } + return nil +} + +func (m *Query) GetCompositeIndex() []*CompositeIndex { + if m != nil { + return m.CompositeIndex + } + return nil +} + +func (m *Query) GetRequirePerfectPlan() bool { + if m != nil && m.RequirePerfectPlan != nil { + return *m.RequirePerfectPlan + } + return Default_Query_RequirePerfectPlan +} + +func (m *Query) GetKeysOnly() bool { + if m != nil && m.KeysOnly != nil { + return *m.KeysOnly + } + return Default_Query_KeysOnly +} + +func (m *Query) GetTransaction() *Transaction { + if m != nil { + return m.Transaction + } + return nil +} + +func (m *Query) GetCompile() bool { + if m != nil && m.Compile != nil { + return *m.Compile + } + return Default_Query_Compile +} + +func (m *Query) GetFailoverMs() int64 { + if m != nil && m.FailoverMs != nil { + return *m.FailoverMs + } + return 0 +} + +func (m *Query) GetStrong() bool { + if m != nil && m.Strong != nil { + return *m.Strong + } + return false +} + +func (m *Query) GetPropertyName() []string { + if m != nil { + return m.PropertyName + } + return nil +} + +func (m *Query) GetGroupByPropertyName() []string { + if m != nil { + return m.GroupByPropertyName + } + return nil +} + +func (m *Query) GetDistinct() bool { + if m != nil && m.Distinct != nil { + return *m.Distinct + } + return false +} + +func (m *Query) GetMinSafeTimeSeconds() int64 { + if m != nil && m.MinSafeTimeSeconds != nil { + return *m.MinSafeTimeSeconds + } + return 0 +} + +func (m *Query) GetSafeReplicaName() []string { + if m != nil { + return m.SafeReplicaName + } + return nil +} + +func (m *Query) GetPersistOffset() bool { + if m != nil && m.PersistOffset != nil { + return *m.PersistOffset + } + return Default_Query_PersistOffset +} + +type Query_Filter struct { + Op *Query_Filter_Operator `protobuf:"varint,6,req,name=op,enum=appengine.Query_Filter_Operator" json:"op,omitempty"` + Property []*Property `protobuf:"bytes,14,rep,name=property" json:"property,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Query_Filter) Reset() { *m = Query_Filter{} } +func (m *Query_Filter) String() string { return proto.CompactTextString(m) } +func (*Query_Filter) ProtoMessage() {} + +func (m *Query_Filter) GetOp() Query_Filter_Operator { + if m != nil && m.Op != nil { + return *m.Op + } + return Query_Filter_LESS_THAN +} + +func (m *Query_Filter) GetProperty() []*Property { + if m != nil { + return m.Property + } + return nil +} + +type Query_Order struct { + Property *string `protobuf:"bytes,10,req,name=property" json:"property,omitempty"` + Direction *Query_Order_Direction `protobuf:"varint,11,opt,name=direction,enum=appengine.Query_Order_Direction,def=1" json:"direction,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Query_Order) Reset() { *m = Query_Order{} } +func (m *Query_Order) String() string { return proto.CompactTextString(m) } +func (*Query_Order) ProtoMessage() {} + +const Default_Query_Order_Direction Query_Order_Direction = Query_Order_ASCENDING + +func (m *Query_Order) GetProperty() string { + if m != nil && m.Property != nil { + return *m.Property + } + return "" +} + +func (m *Query_Order) GetDirection() Query_Order_Direction { + if m != nil && m.Direction != nil { + return *m.Direction + } + return Default_Query_Order_Direction +} + +type CompiledQuery struct { + Primaryscan *CompiledQuery_PrimaryScan `protobuf:"group,1,req,name=PrimaryScan" json:"primaryscan,omitempty"` + Mergejoinscan []*CompiledQuery_MergeJoinScan `protobuf:"group,7,rep,name=MergeJoinScan" json:"mergejoinscan,omitempty"` + IndexDef *Index `protobuf:"bytes,21,opt,name=index_def" json:"index_def,omitempty"` + Offset *int32 `protobuf:"varint,10,opt,name=offset,def=0" json:"offset,omitempty"` + Limit *int32 `protobuf:"varint,11,opt,name=limit" json:"limit,omitempty"` + KeysOnly *bool `protobuf:"varint,12,req,name=keys_only" json:"keys_only,omitempty"` + PropertyName []string `protobuf:"bytes,24,rep,name=property_name" json:"property_name,omitempty"` + DistinctInfixSize *int32 `protobuf:"varint,25,opt,name=distinct_infix_size" json:"distinct_infix_size,omitempty"` + Entityfilter *CompiledQuery_EntityFilter `protobuf:"group,13,opt,name=EntityFilter" json:"entityfilter,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CompiledQuery) Reset() { *m = CompiledQuery{} } +func (m *CompiledQuery) String() string { return proto.CompactTextString(m) } +func (*CompiledQuery) ProtoMessage() {} + +const Default_CompiledQuery_Offset int32 = 0 + +func (m *CompiledQuery) GetPrimaryscan() *CompiledQuery_PrimaryScan { + if m != nil { + return m.Primaryscan + } + return nil +} + +func (m *CompiledQuery) GetMergejoinscan() []*CompiledQuery_MergeJoinScan { + if m != nil { + return m.Mergejoinscan + } + return nil +} + +func (m *CompiledQuery) GetIndexDef() *Index { + if m != nil { + return m.IndexDef + } + return nil +} + +func (m *CompiledQuery) GetOffset() int32 { + if m != nil && m.Offset != nil { + return *m.Offset + } + return Default_CompiledQuery_Offset +} + +func (m *CompiledQuery) GetLimit() int32 { + if m != nil && m.Limit != nil { + return *m.Limit + } + return 0 +} + +func (m *CompiledQuery) GetKeysOnly() bool { + if m != nil && m.KeysOnly != nil { + return *m.KeysOnly + } + return false +} + +func (m *CompiledQuery) GetPropertyName() []string { + if m != nil { + return m.PropertyName + } + return nil +} + +func (m *CompiledQuery) GetDistinctInfixSize() int32 { + if m != nil && m.DistinctInfixSize != nil { + return *m.DistinctInfixSize + } + return 0 +} + +func (m *CompiledQuery) GetEntityfilter() *CompiledQuery_EntityFilter { + if m != nil { + return m.Entityfilter + } + return nil +} + +type CompiledQuery_PrimaryScan struct { + IndexName *string `protobuf:"bytes,2,opt,name=index_name" json:"index_name,omitempty"` + StartKey *string `protobuf:"bytes,3,opt,name=start_key" json:"start_key,omitempty"` + StartInclusive *bool `protobuf:"varint,4,opt,name=start_inclusive" json:"start_inclusive,omitempty"` + EndKey *string `protobuf:"bytes,5,opt,name=end_key" json:"end_key,omitempty"` + EndInclusive *bool `protobuf:"varint,6,opt,name=end_inclusive" json:"end_inclusive,omitempty"` + StartPostfixValue []string `protobuf:"bytes,22,rep,name=start_postfix_value" json:"start_postfix_value,omitempty"` + EndPostfixValue []string `protobuf:"bytes,23,rep,name=end_postfix_value" json:"end_postfix_value,omitempty"` + EndUnappliedLogTimestampUs *int64 `protobuf:"varint,19,opt,name=end_unapplied_log_timestamp_us" json:"end_unapplied_log_timestamp_us,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CompiledQuery_PrimaryScan) Reset() { *m = CompiledQuery_PrimaryScan{} } +func (m *CompiledQuery_PrimaryScan) String() string { return proto.CompactTextString(m) } +func (*CompiledQuery_PrimaryScan) ProtoMessage() {} + +func (m *CompiledQuery_PrimaryScan) GetIndexName() string { + if m != nil && m.IndexName != nil { + return *m.IndexName + } + return "" +} + +func (m *CompiledQuery_PrimaryScan) GetStartKey() string { + if m != nil && m.StartKey != nil { + return *m.StartKey + } + return "" +} + +func (m *CompiledQuery_PrimaryScan) GetStartInclusive() bool { + if m != nil && m.StartInclusive != nil { + return *m.StartInclusive + } + return false +} + +func (m *CompiledQuery_PrimaryScan) GetEndKey() string { + if m != nil && m.EndKey != nil { + return *m.EndKey + } + return "" +} + +func (m *CompiledQuery_PrimaryScan) GetEndInclusive() bool { + if m != nil && m.EndInclusive != nil { + return *m.EndInclusive + } + return false +} + +func (m *CompiledQuery_PrimaryScan) GetStartPostfixValue() []string { + if m != nil { + return m.StartPostfixValue + } + return nil +} + +func (m *CompiledQuery_PrimaryScan) GetEndPostfixValue() []string { + if m != nil { + return m.EndPostfixValue + } + return nil +} + +func (m *CompiledQuery_PrimaryScan) GetEndUnappliedLogTimestampUs() int64 { + if m != nil && m.EndUnappliedLogTimestampUs != nil { + return *m.EndUnappliedLogTimestampUs + } + return 0 +} + +type CompiledQuery_MergeJoinScan struct { + IndexName *string `protobuf:"bytes,8,req,name=index_name" json:"index_name,omitempty"` + PrefixValue []string `protobuf:"bytes,9,rep,name=prefix_value" json:"prefix_value,omitempty"` + ValuePrefix *bool `protobuf:"varint,20,opt,name=value_prefix,def=0" json:"value_prefix,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CompiledQuery_MergeJoinScan) Reset() { *m = CompiledQuery_MergeJoinScan{} } +func (m *CompiledQuery_MergeJoinScan) String() string { return proto.CompactTextString(m) } +func (*CompiledQuery_MergeJoinScan) ProtoMessage() {} + +const Default_CompiledQuery_MergeJoinScan_ValuePrefix bool = false + +func (m *CompiledQuery_MergeJoinScan) GetIndexName() string { + if m != nil && m.IndexName != nil { + return *m.IndexName + } + return "" +} + +func (m *CompiledQuery_MergeJoinScan) GetPrefixValue() []string { + if m != nil { + return m.PrefixValue + } + return nil +} + +func (m *CompiledQuery_MergeJoinScan) GetValuePrefix() bool { + if m != nil && m.ValuePrefix != nil { + return *m.ValuePrefix + } + return Default_CompiledQuery_MergeJoinScan_ValuePrefix +} + +type CompiledQuery_EntityFilter struct { + Distinct *bool `protobuf:"varint,14,opt,name=distinct,def=0" json:"distinct,omitempty"` + Kind *string `protobuf:"bytes,17,opt,name=kind" json:"kind,omitempty"` + Ancestor *Reference `protobuf:"bytes,18,opt,name=ancestor" json:"ancestor,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CompiledQuery_EntityFilter) Reset() { *m = CompiledQuery_EntityFilter{} } +func (m *CompiledQuery_EntityFilter) String() string { return proto.CompactTextString(m) } +func (*CompiledQuery_EntityFilter) ProtoMessage() {} + +const Default_CompiledQuery_EntityFilter_Distinct bool = false + +func (m *CompiledQuery_EntityFilter) GetDistinct() bool { + if m != nil && m.Distinct != nil { + return *m.Distinct + } + return Default_CompiledQuery_EntityFilter_Distinct +} + +func (m *CompiledQuery_EntityFilter) GetKind() string { + if m != nil && m.Kind != nil { + return *m.Kind + } + return "" +} + +func (m *CompiledQuery_EntityFilter) GetAncestor() *Reference { + if m != nil { + return m.Ancestor + } + return nil +} + +type CompiledCursor struct { + Position *CompiledCursor_Position `protobuf:"group,2,opt,name=Position" json:"position,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CompiledCursor) Reset() { *m = CompiledCursor{} } +func (m *CompiledCursor) String() string { return proto.CompactTextString(m) } +func (*CompiledCursor) ProtoMessage() {} + +func (m *CompiledCursor) GetPosition() *CompiledCursor_Position { + if m != nil { + return m.Position + } + return nil +} + +type CompiledCursor_Position struct { + StartKey *string `protobuf:"bytes,27,opt,name=start_key" json:"start_key,omitempty"` + Indexvalue []*CompiledCursor_Position_IndexValue `protobuf:"group,29,rep,name=IndexValue" json:"indexvalue,omitempty"` + Key *Reference `protobuf:"bytes,32,opt,name=key" json:"key,omitempty"` + StartInclusive *bool `protobuf:"varint,28,opt,name=start_inclusive,def=1" json:"start_inclusive,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CompiledCursor_Position) Reset() { *m = CompiledCursor_Position{} } +func (m *CompiledCursor_Position) String() string { return proto.CompactTextString(m) } +func (*CompiledCursor_Position) ProtoMessage() {} + +const Default_CompiledCursor_Position_StartInclusive bool = true + +func (m *CompiledCursor_Position) GetStartKey() string { + if m != nil && m.StartKey != nil { + return *m.StartKey + } + return "" +} + +func (m *CompiledCursor_Position) GetIndexvalue() []*CompiledCursor_Position_IndexValue { + if m != nil { + return m.Indexvalue + } + return nil +} + +func (m *CompiledCursor_Position) GetKey() *Reference { + if m != nil { + return m.Key + } + return nil +} + +func (m *CompiledCursor_Position) GetStartInclusive() bool { + if m != nil && m.StartInclusive != nil { + return *m.StartInclusive + } + return Default_CompiledCursor_Position_StartInclusive +} + +type CompiledCursor_Position_IndexValue struct { + Property *string `protobuf:"bytes,30,opt,name=property" json:"property,omitempty"` + Value *PropertyValue `protobuf:"bytes,31,req,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CompiledCursor_Position_IndexValue) Reset() { *m = CompiledCursor_Position_IndexValue{} } +func (m *CompiledCursor_Position_IndexValue) String() string { return proto.CompactTextString(m) } +func (*CompiledCursor_Position_IndexValue) ProtoMessage() {} + +func (m *CompiledCursor_Position_IndexValue) GetProperty() string { + if m != nil && m.Property != nil { + return *m.Property + } + return "" +} + +func (m *CompiledCursor_Position_IndexValue) GetValue() *PropertyValue { + if m != nil { + return m.Value + } + return nil +} + +type Cursor struct { + Cursor *uint64 `protobuf:"fixed64,1,req,name=cursor" json:"cursor,omitempty"` + App *string `protobuf:"bytes,2,opt,name=app" json:"app,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Cursor) Reset() { *m = Cursor{} } +func (m *Cursor) String() string { return proto.CompactTextString(m) } +func (*Cursor) ProtoMessage() {} + +func (m *Cursor) GetCursor() uint64 { + if m != nil && m.Cursor != nil { + return *m.Cursor + } + return 0 +} + +func (m *Cursor) GetApp() string { + if m != nil && m.App != nil { + return *m.App + } + return "" +} + +type Error struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *Error) Reset() { *m = Error{} } +func (m *Error) String() string { return proto.CompactTextString(m) } +func (*Error) ProtoMessage() {} + +type Cost struct { + IndexWrites *int32 `protobuf:"varint,1,opt,name=index_writes" json:"index_writes,omitempty"` + IndexWriteBytes *int32 `protobuf:"varint,2,opt,name=index_write_bytes" json:"index_write_bytes,omitempty"` + EntityWrites *int32 `protobuf:"varint,3,opt,name=entity_writes" json:"entity_writes,omitempty"` + EntityWriteBytes *int32 `protobuf:"varint,4,opt,name=entity_write_bytes" json:"entity_write_bytes,omitempty"` + Commitcost *Cost_CommitCost `protobuf:"group,5,opt,name=CommitCost" json:"commitcost,omitempty"` + ApproximateStorageDelta *int32 `protobuf:"varint,8,opt,name=approximate_storage_delta" json:"approximate_storage_delta,omitempty"` + IdSequenceUpdates *int32 `protobuf:"varint,9,opt,name=id_sequence_updates" json:"id_sequence_updates,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Cost) Reset() { *m = Cost{} } +func (m *Cost) String() string { return proto.CompactTextString(m) } +func (*Cost) ProtoMessage() {} + +func (m *Cost) GetIndexWrites() int32 { + if m != nil && m.IndexWrites != nil { + return *m.IndexWrites + } + return 0 +} + +func (m *Cost) GetIndexWriteBytes() int32 { + if m != nil && m.IndexWriteBytes != nil { + return *m.IndexWriteBytes + } + return 0 +} + +func (m *Cost) GetEntityWrites() int32 { + if m != nil && m.EntityWrites != nil { + return *m.EntityWrites + } + return 0 +} + +func (m *Cost) GetEntityWriteBytes() int32 { + if m != nil && m.EntityWriteBytes != nil { + return *m.EntityWriteBytes + } + return 0 +} + +func (m *Cost) GetCommitcost() *Cost_CommitCost { + if m != nil { + return m.Commitcost + } + return nil +} + +func (m *Cost) GetApproximateStorageDelta() int32 { + if m != nil && m.ApproximateStorageDelta != nil { + return *m.ApproximateStorageDelta + } + return 0 +} + +func (m *Cost) GetIdSequenceUpdates() int32 { + if m != nil && m.IdSequenceUpdates != nil { + return *m.IdSequenceUpdates + } + return 0 +} + +type Cost_CommitCost struct { + RequestedEntityPuts *int32 `protobuf:"varint,6,opt,name=requested_entity_puts" json:"requested_entity_puts,omitempty"` + RequestedEntityDeletes *int32 `protobuf:"varint,7,opt,name=requested_entity_deletes" json:"requested_entity_deletes,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Cost_CommitCost) Reset() { *m = Cost_CommitCost{} } +func (m *Cost_CommitCost) String() string { return proto.CompactTextString(m) } +func (*Cost_CommitCost) ProtoMessage() {} + +func (m *Cost_CommitCost) GetRequestedEntityPuts() int32 { + if m != nil && m.RequestedEntityPuts != nil { + return *m.RequestedEntityPuts + } + return 0 +} + +func (m *Cost_CommitCost) GetRequestedEntityDeletes() int32 { + if m != nil && m.RequestedEntityDeletes != nil { + return *m.RequestedEntityDeletes + } + return 0 +} + +type GetRequest struct { + Header *InternalHeader `protobuf:"bytes,6,opt,name=header" json:"header,omitempty"` + Key []*Reference `protobuf:"bytes,1,rep,name=key" json:"key,omitempty"` + Transaction *Transaction `protobuf:"bytes,2,opt,name=transaction" json:"transaction,omitempty"` + FailoverMs *int64 `protobuf:"varint,3,opt,name=failover_ms" json:"failover_ms,omitempty"` + Strong *bool `protobuf:"varint,4,opt,name=strong" json:"strong,omitempty"` + AllowDeferred *bool `protobuf:"varint,5,opt,name=allow_deferred,def=0" json:"allow_deferred,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetRequest) Reset() { *m = GetRequest{} } +func (m *GetRequest) String() string { return proto.CompactTextString(m) } +func (*GetRequest) ProtoMessage() {} + +const Default_GetRequest_AllowDeferred bool = false + +func (m *GetRequest) GetHeader() *InternalHeader { + if m != nil { + return m.Header + } + return nil +} + +func (m *GetRequest) GetKey() []*Reference { + if m != nil { + return m.Key + } + return nil +} + +func (m *GetRequest) GetTransaction() *Transaction { + if m != nil { + return m.Transaction + } + return nil +} + +func (m *GetRequest) GetFailoverMs() int64 { + if m != nil && m.FailoverMs != nil { + return *m.FailoverMs + } + return 0 +} + +func (m *GetRequest) GetStrong() bool { + if m != nil && m.Strong != nil { + return *m.Strong + } + return false +} + +func (m *GetRequest) GetAllowDeferred() bool { + if m != nil && m.AllowDeferred != nil { + return *m.AllowDeferred + } + return Default_GetRequest_AllowDeferred +} + +type GetResponse struct { + Entity []*GetResponse_Entity `protobuf:"group,1,rep,name=Entity" json:"entity,omitempty"` + Deferred []*Reference `protobuf:"bytes,5,rep,name=deferred" json:"deferred,omitempty"` + InOrder *bool `protobuf:"varint,6,opt,name=in_order,def=1" json:"in_order,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetResponse) Reset() { *m = GetResponse{} } +func (m *GetResponse) String() string { return proto.CompactTextString(m) } +func (*GetResponse) ProtoMessage() {} + +const Default_GetResponse_InOrder bool = true + +func (m *GetResponse) GetEntity() []*GetResponse_Entity { + if m != nil { + return m.Entity + } + return nil +} + +func (m *GetResponse) GetDeferred() []*Reference { + if m != nil { + return m.Deferred + } + return nil +} + +func (m *GetResponse) GetInOrder() bool { + if m != nil && m.InOrder != nil { + return *m.InOrder + } + return Default_GetResponse_InOrder +} + +type GetResponse_Entity struct { + Entity *EntityProto `protobuf:"bytes,2,opt,name=entity" json:"entity,omitempty"` + Key *Reference `protobuf:"bytes,4,opt,name=key" json:"key,omitempty"` + Version *int64 `protobuf:"varint,3,opt,name=version" json:"version,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetResponse_Entity) Reset() { *m = GetResponse_Entity{} } +func (m *GetResponse_Entity) String() string { return proto.CompactTextString(m) } +func (*GetResponse_Entity) ProtoMessage() {} + +func (m *GetResponse_Entity) GetEntity() *EntityProto { + if m != nil { + return m.Entity + } + return nil +} + +func (m *GetResponse_Entity) GetKey() *Reference { + if m != nil { + return m.Key + } + return nil +} + +func (m *GetResponse_Entity) GetVersion() int64 { + if m != nil && m.Version != nil { + return *m.Version + } + return 0 +} + +type PutRequest struct { + Header *InternalHeader `protobuf:"bytes,11,opt,name=header" json:"header,omitempty"` + Entity []*EntityProto `protobuf:"bytes,1,rep,name=entity" json:"entity,omitempty"` + Transaction *Transaction `protobuf:"bytes,2,opt,name=transaction" json:"transaction,omitempty"` + CompositeIndex []*CompositeIndex `protobuf:"bytes,3,rep,name=composite_index" json:"composite_index,omitempty"` + Trusted *bool `protobuf:"varint,4,opt,name=trusted,def=0" json:"trusted,omitempty"` + Force *bool `protobuf:"varint,7,opt,name=force,def=0" json:"force,omitempty"` + MarkChanges *bool `protobuf:"varint,8,opt,name=mark_changes,def=0" json:"mark_changes,omitempty"` + Snapshot []*Snapshot `protobuf:"bytes,9,rep,name=snapshot" json:"snapshot,omitempty"` + AutoIdPolicy *PutRequest_AutoIdPolicy `protobuf:"varint,10,opt,name=auto_id_policy,enum=appengine.PutRequest_AutoIdPolicy,def=0" json:"auto_id_policy,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *PutRequest) Reset() { *m = PutRequest{} } +func (m *PutRequest) String() string { return proto.CompactTextString(m) } +func (*PutRequest) ProtoMessage() {} + +const Default_PutRequest_Trusted bool = false +const Default_PutRequest_Force bool = false +const Default_PutRequest_MarkChanges bool = false +const Default_PutRequest_AutoIdPolicy PutRequest_AutoIdPolicy = PutRequest_CURRENT + +func (m *PutRequest) GetHeader() *InternalHeader { + if m != nil { + return m.Header + } + return nil +} + +func (m *PutRequest) GetEntity() []*EntityProto { + if m != nil { + return m.Entity + } + return nil +} + +func (m *PutRequest) GetTransaction() *Transaction { + if m != nil { + return m.Transaction + } + return nil +} + +func (m *PutRequest) GetCompositeIndex() []*CompositeIndex { + if m != nil { + return m.CompositeIndex + } + return nil +} + +func (m *PutRequest) GetTrusted() bool { + if m != nil && m.Trusted != nil { + return *m.Trusted + } + return Default_PutRequest_Trusted +} + +func (m *PutRequest) GetForce() bool { + if m != nil && m.Force != nil { + return *m.Force + } + return Default_PutRequest_Force +} + +func (m *PutRequest) GetMarkChanges() bool { + if m != nil && m.MarkChanges != nil { + return *m.MarkChanges + } + return Default_PutRequest_MarkChanges +} + +func (m *PutRequest) GetSnapshot() []*Snapshot { + if m != nil { + return m.Snapshot + } + return nil +} + +func (m *PutRequest) GetAutoIdPolicy() PutRequest_AutoIdPolicy { + if m != nil && m.AutoIdPolicy != nil { + return *m.AutoIdPolicy + } + return Default_PutRequest_AutoIdPolicy +} + +type PutResponse struct { + Key []*Reference `protobuf:"bytes,1,rep,name=key" json:"key,omitempty"` + Cost *Cost `protobuf:"bytes,2,opt,name=cost" json:"cost,omitempty"` + Version []int64 `protobuf:"varint,3,rep,name=version" json:"version,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *PutResponse) Reset() { *m = PutResponse{} } +func (m *PutResponse) String() string { return proto.CompactTextString(m) } +func (*PutResponse) ProtoMessage() {} + +func (m *PutResponse) GetKey() []*Reference { + if m != nil { + return m.Key + } + return nil +} + +func (m *PutResponse) GetCost() *Cost { + if m != nil { + return m.Cost + } + return nil +} + +func (m *PutResponse) GetVersion() []int64 { + if m != nil { + return m.Version + } + return nil +} + +type TouchRequest struct { + Header *InternalHeader `protobuf:"bytes,10,opt,name=header" json:"header,omitempty"` + Key []*Reference `protobuf:"bytes,1,rep,name=key" json:"key,omitempty"` + CompositeIndex []*CompositeIndex `protobuf:"bytes,2,rep,name=composite_index" json:"composite_index,omitempty"` + Force *bool `protobuf:"varint,3,opt,name=force,def=0" json:"force,omitempty"` + Snapshot []*Snapshot `protobuf:"bytes,9,rep,name=snapshot" json:"snapshot,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *TouchRequest) Reset() { *m = TouchRequest{} } +func (m *TouchRequest) String() string { return proto.CompactTextString(m) } +func (*TouchRequest) ProtoMessage() {} + +const Default_TouchRequest_Force bool = false + +func (m *TouchRequest) GetHeader() *InternalHeader { + if m != nil { + return m.Header + } + return nil +} + +func (m *TouchRequest) GetKey() []*Reference { + if m != nil { + return m.Key + } + return nil +} + +func (m *TouchRequest) GetCompositeIndex() []*CompositeIndex { + if m != nil { + return m.CompositeIndex + } + return nil +} + +func (m *TouchRequest) GetForce() bool { + if m != nil && m.Force != nil { + return *m.Force + } + return Default_TouchRequest_Force +} + +func (m *TouchRequest) GetSnapshot() []*Snapshot { + if m != nil { + return m.Snapshot + } + return nil +} + +type TouchResponse struct { + Cost *Cost `protobuf:"bytes,1,opt,name=cost" json:"cost,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *TouchResponse) Reset() { *m = TouchResponse{} } +func (m *TouchResponse) String() string { return proto.CompactTextString(m) } +func (*TouchResponse) ProtoMessage() {} + +func (m *TouchResponse) GetCost() *Cost { + if m != nil { + return m.Cost + } + return nil +} + +type DeleteRequest struct { + Header *InternalHeader `protobuf:"bytes,10,opt,name=header" json:"header,omitempty"` + Key []*Reference `protobuf:"bytes,6,rep,name=key" json:"key,omitempty"` + Transaction *Transaction `protobuf:"bytes,5,opt,name=transaction" json:"transaction,omitempty"` + Trusted *bool `protobuf:"varint,4,opt,name=trusted,def=0" json:"trusted,omitempty"` + Force *bool `protobuf:"varint,7,opt,name=force,def=0" json:"force,omitempty"` + MarkChanges *bool `protobuf:"varint,8,opt,name=mark_changes,def=0" json:"mark_changes,omitempty"` + Snapshot []*Snapshot `protobuf:"bytes,9,rep,name=snapshot" json:"snapshot,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *DeleteRequest) Reset() { *m = DeleteRequest{} } +func (m *DeleteRequest) String() string { return proto.CompactTextString(m) } +func (*DeleteRequest) ProtoMessage() {} + +const Default_DeleteRequest_Trusted bool = false +const Default_DeleteRequest_Force bool = false +const Default_DeleteRequest_MarkChanges bool = false + +func (m *DeleteRequest) GetHeader() *InternalHeader { + if m != nil { + return m.Header + } + return nil +} + +func (m *DeleteRequest) GetKey() []*Reference { + if m != nil { + return m.Key + } + return nil +} + +func (m *DeleteRequest) GetTransaction() *Transaction { + if m != nil { + return m.Transaction + } + return nil +} + +func (m *DeleteRequest) GetTrusted() bool { + if m != nil && m.Trusted != nil { + return *m.Trusted + } + return Default_DeleteRequest_Trusted +} + +func (m *DeleteRequest) GetForce() bool { + if m != nil && m.Force != nil { + return *m.Force + } + return Default_DeleteRequest_Force +} + +func (m *DeleteRequest) GetMarkChanges() bool { + if m != nil && m.MarkChanges != nil { + return *m.MarkChanges + } + return Default_DeleteRequest_MarkChanges +} + +func (m *DeleteRequest) GetSnapshot() []*Snapshot { + if m != nil { + return m.Snapshot + } + return nil +} + +type DeleteResponse struct { + Cost *Cost `protobuf:"bytes,1,opt,name=cost" json:"cost,omitempty"` + Version []int64 `protobuf:"varint,3,rep,name=version" json:"version,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *DeleteResponse) Reset() { *m = DeleteResponse{} } +func (m *DeleteResponse) String() string { return proto.CompactTextString(m) } +func (*DeleteResponse) ProtoMessage() {} + +func (m *DeleteResponse) GetCost() *Cost { + if m != nil { + return m.Cost + } + return nil +} + +func (m *DeleteResponse) GetVersion() []int64 { + if m != nil { + return m.Version + } + return nil +} + +type NextRequest struct { + Header *InternalHeader `protobuf:"bytes,5,opt,name=header" json:"header,omitempty"` + Cursor *Cursor `protobuf:"bytes,1,req,name=cursor" json:"cursor,omitempty"` + Count *int32 `protobuf:"varint,2,opt,name=count" json:"count,omitempty"` + Offset *int32 `protobuf:"varint,4,opt,name=offset,def=0" json:"offset,omitempty"` + Compile *bool `protobuf:"varint,3,opt,name=compile,def=0" json:"compile,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *NextRequest) Reset() { *m = NextRequest{} } +func (m *NextRequest) String() string { return proto.CompactTextString(m) } +func (*NextRequest) ProtoMessage() {} + +const Default_NextRequest_Offset int32 = 0 +const Default_NextRequest_Compile bool = false + +func (m *NextRequest) GetHeader() *InternalHeader { + if m != nil { + return m.Header + } + return nil +} + +func (m *NextRequest) GetCursor() *Cursor { + if m != nil { + return m.Cursor + } + return nil +} + +func (m *NextRequest) GetCount() int32 { + if m != nil && m.Count != nil { + return *m.Count + } + return 0 +} + +func (m *NextRequest) GetOffset() int32 { + if m != nil && m.Offset != nil { + return *m.Offset + } + return Default_NextRequest_Offset +} + +func (m *NextRequest) GetCompile() bool { + if m != nil && m.Compile != nil { + return *m.Compile + } + return Default_NextRequest_Compile +} + +type QueryResult struct { + Cursor *Cursor `protobuf:"bytes,1,opt,name=cursor" json:"cursor,omitempty"` + Result []*EntityProto `protobuf:"bytes,2,rep,name=result" json:"result,omitempty"` + SkippedResults *int32 `protobuf:"varint,7,opt,name=skipped_results" json:"skipped_results,omitempty"` + MoreResults *bool `protobuf:"varint,3,req,name=more_results" json:"more_results,omitempty"` + KeysOnly *bool `protobuf:"varint,4,opt,name=keys_only" json:"keys_only,omitempty"` + IndexOnly *bool `protobuf:"varint,9,opt,name=index_only" json:"index_only,omitempty"` + SmallOps *bool `protobuf:"varint,10,opt,name=small_ops" json:"small_ops,omitempty"` + CompiledQuery *CompiledQuery `protobuf:"bytes,5,opt,name=compiled_query" json:"compiled_query,omitempty"` + CompiledCursor *CompiledCursor `protobuf:"bytes,6,opt,name=compiled_cursor" json:"compiled_cursor,omitempty"` + Index []*CompositeIndex `protobuf:"bytes,8,rep,name=index" json:"index,omitempty"` + Version []int64 `protobuf:"varint,11,rep,name=version" json:"version,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *QueryResult) Reset() { *m = QueryResult{} } +func (m *QueryResult) String() string { return proto.CompactTextString(m) } +func (*QueryResult) ProtoMessage() {} + +func (m *QueryResult) GetCursor() *Cursor { + if m != nil { + return m.Cursor + } + return nil +} + +func (m *QueryResult) GetResult() []*EntityProto { + if m != nil { + return m.Result + } + return nil +} + +func (m *QueryResult) GetSkippedResults() int32 { + if m != nil && m.SkippedResults != nil { + return *m.SkippedResults + } + return 0 +} + +func (m *QueryResult) GetMoreResults() bool { + if m != nil && m.MoreResults != nil { + return *m.MoreResults + } + return false +} + +func (m *QueryResult) GetKeysOnly() bool { + if m != nil && m.KeysOnly != nil { + return *m.KeysOnly + } + return false +} + +func (m *QueryResult) GetIndexOnly() bool { + if m != nil && m.IndexOnly != nil { + return *m.IndexOnly + } + return false +} + +func (m *QueryResult) GetSmallOps() bool { + if m != nil && m.SmallOps != nil { + return *m.SmallOps + } + return false +} + +func (m *QueryResult) GetCompiledQuery() *CompiledQuery { + if m != nil { + return m.CompiledQuery + } + return nil +} + +func (m *QueryResult) GetCompiledCursor() *CompiledCursor { + if m != nil { + return m.CompiledCursor + } + return nil +} + +func (m *QueryResult) GetIndex() []*CompositeIndex { + if m != nil { + return m.Index + } + return nil +} + +func (m *QueryResult) GetVersion() []int64 { + if m != nil { + return m.Version + } + return nil +} + +type AllocateIdsRequest struct { + Header *InternalHeader `protobuf:"bytes,4,opt,name=header" json:"header,omitempty"` + ModelKey *Reference `protobuf:"bytes,1,opt,name=model_key" json:"model_key,omitempty"` + Size *int64 `protobuf:"varint,2,opt,name=size" json:"size,omitempty"` + Max *int64 `protobuf:"varint,3,opt,name=max" json:"max,omitempty"` + Reserve []*Reference `protobuf:"bytes,5,rep,name=reserve" json:"reserve,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *AllocateIdsRequest) Reset() { *m = AllocateIdsRequest{} } +func (m *AllocateIdsRequest) String() string { return proto.CompactTextString(m) } +func (*AllocateIdsRequest) ProtoMessage() {} + +func (m *AllocateIdsRequest) GetHeader() *InternalHeader { + if m != nil { + return m.Header + } + return nil +} + +func (m *AllocateIdsRequest) GetModelKey() *Reference { + if m != nil { + return m.ModelKey + } + return nil +} + +func (m *AllocateIdsRequest) GetSize() int64 { + if m != nil && m.Size != nil { + return *m.Size + } + return 0 +} + +func (m *AllocateIdsRequest) GetMax() int64 { + if m != nil && m.Max != nil { + return *m.Max + } + return 0 +} + +func (m *AllocateIdsRequest) GetReserve() []*Reference { + if m != nil { + return m.Reserve + } + return nil +} + +type AllocateIdsResponse struct { + Start *int64 `protobuf:"varint,1,req,name=start" json:"start,omitempty"` + End *int64 `protobuf:"varint,2,req,name=end" json:"end,omitempty"` + Cost *Cost `protobuf:"bytes,3,opt,name=cost" json:"cost,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *AllocateIdsResponse) Reset() { *m = AllocateIdsResponse{} } +func (m *AllocateIdsResponse) String() string { return proto.CompactTextString(m) } +func (*AllocateIdsResponse) ProtoMessage() {} + +func (m *AllocateIdsResponse) GetStart() int64 { + if m != nil && m.Start != nil { + return *m.Start + } + return 0 +} + +func (m *AllocateIdsResponse) GetEnd() int64 { + if m != nil && m.End != nil { + return *m.End + } + return 0 +} + +func (m *AllocateIdsResponse) GetCost() *Cost { + if m != nil { + return m.Cost + } + return nil +} + +type CompositeIndices struct { + Index []*CompositeIndex `protobuf:"bytes,1,rep,name=index" json:"index,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CompositeIndices) Reset() { *m = CompositeIndices{} } +func (m *CompositeIndices) String() string { return proto.CompactTextString(m) } +func (*CompositeIndices) ProtoMessage() {} + +func (m *CompositeIndices) GetIndex() []*CompositeIndex { + if m != nil { + return m.Index + } + return nil +} + +type AddActionsRequest struct { + Header *InternalHeader `protobuf:"bytes,3,opt,name=header" json:"header,omitempty"` + Transaction *Transaction `protobuf:"bytes,1,req,name=transaction" json:"transaction,omitempty"` + Action []*Action `protobuf:"bytes,2,rep,name=action" json:"action,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *AddActionsRequest) Reset() { *m = AddActionsRequest{} } +func (m *AddActionsRequest) String() string { return proto.CompactTextString(m) } +func (*AddActionsRequest) ProtoMessage() {} + +func (m *AddActionsRequest) GetHeader() *InternalHeader { + if m != nil { + return m.Header + } + return nil +} + +func (m *AddActionsRequest) GetTransaction() *Transaction { + if m != nil { + return m.Transaction + } + return nil +} + +func (m *AddActionsRequest) GetAction() []*Action { + if m != nil { + return m.Action + } + return nil +} + +type AddActionsResponse struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *AddActionsResponse) Reset() { *m = AddActionsResponse{} } +func (m *AddActionsResponse) String() string { return proto.CompactTextString(m) } +func (*AddActionsResponse) ProtoMessage() {} + +type BeginTransactionRequest struct { + Header *InternalHeader `protobuf:"bytes,3,opt,name=header" json:"header,omitempty"` + App *string `protobuf:"bytes,1,req,name=app" json:"app,omitempty"` + AllowMultipleEg *bool `protobuf:"varint,2,opt,name=allow_multiple_eg,def=0" json:"allow_multiple_eg,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *BeginTransactionRequest) Reset() { *m = BeginTransactionRequest{} } +func (m *BeginTransactionRequest) String() string { return proto.CompactTextString(m) } +func (*BeginTransactionRequest) ProtoMessage() {} + +const Default_BeginTransactionRequest_AllowMultipleEg bool = false + +func (m *BeginTransactionRequest) GetHeader() *InternalHeader { + if m != nil { + return m.Header + } + return nil +} + +func (m *BeginTransactionRequest) GetApp() string { + if m != nil && m.App != nil { + return *m.App + } + return "" +} + +func (m *BeginTransactionRequest) GetAllowMultipleEg() bool { + if m != nil && m.AllowMultipleEg != nil { + return *m.AllowMultipleEg + } + return Default_BeginTransactionRequest_AllowMultipleEg +} + +type CommitResponse struct { + Cost *Cost `protobuf:"bytes,1,opt,name=cost" json:"cost,omitempty"` + Version []*CommitResponse_Version `protobuf:"group,3,rep,name=Version" json:"version,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CommitResponse) Reset() { *m = CommitResponse{} } +func (m *CommitResponse) String() string { return proto.CompactTextString(m) } +func (*CommitResponse) ProtoMessage() {} + +func (m *CommitResponse) GetCost() *Cost { + if m != nil { + return m.Cost + } + return nil +} + +func (m *CommitResponse) GetVersion() []*CommitResponse_Version { + if m != nil { + return m.Version + } + return nil +} + +type CommitResponse_Version struct { + RootEntityKey *Reference `protobuf:"bytes,4,req,name=root_entity_key" json:"root_entity_key,omitempty"` + Version *int64 `protobuf:"varint,5,req,name=version" json:"version,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CommitResponse_Version) Reset() { *m = CommitResponse_Version{} } +func (m *CommitResponse_Version) String() string { return proto.CompactTextString(m) } +func (*CommitResponse_Version) ProtoMessage() {} + +func (m *CommitResponse_Version) GetRootEntityKey() *Reference { + if m != nil { + return m.RootEntityKey + } + return nil +} + +func (m *CommitResponse_Version) GetVersion() int64 { + if m != nil && m.Version != nil { + return *m.Version + } + return 0 +} + +func init() { +} diff --git a/vendor/google.golang.org/appengine/internal/datastore/datastore_v3.proto b/vendor/google.golang.org/appengine/internal/datastore/datastore_v3.proto new file mode 100644 index 0000000000..e76f126ff7 --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/datastore/datastore_v3.proto @@ -0,0 +1,541 @@ +syntax = "proto2"; +option go_package = "datastore"; + +package appengine; + +message Action{} + +message PropertyValue { + optional int64 int64Value = 1; + optional bool booleanValue = 2; + optional string stringValue = 3; + optional double doubleValue = 4; + + optional group PointValue = 5 { + required double x = 6; + required double y = 7; + } + + optional group UserValue = 8 { + required string email = 9; + required string auth_domain = 10; + optional string nickname = 11; + optional string federated_identity = 21; + optional string federated_provider = 22; + } + + optional group ReferenceValue = 12 { + required string app = 13; + optional string name_space = 20; + repeated group PathElement = 14 { + required string type = 15; + optional int64 id = 16; + optional string name = 17; + } + } +} + +message Property { + enum Meaning { + NO_MEANING = 0; + BLOB = 14; + TEXT = 15; + BYTESTRING = 16; + + ATOM_CATEGORY = 1; + ATOM_LINK = 2; + ATOM_TITLE = 3; + ATOM_CONTENT = 4; + ATOM_SUMMARY = 5; + ATOM_AUTHOR = 6; + + GD_WHEN = 7; + GD_EMAIL = 8; + GEORSS_POINT = 9; + GD_IM = 10; + + GD_PHONENUMBER = 11; + GD_POSTALADDRESS = 12; + + GD_RATING = 13; + + BLOBKEY = 17; + ENTITY_PROTO = 19; + + INDEX_VALUE = 18; + }; + + optional Meaning meaning = 1 [default = NO_MEANING]; + optional string meaning_uri = 2; + + required string name = 3; + + required PropertyValue value = 5; + + required bool multiple = 4; + + optional bool searchable = 6 [default=false]; + + enum FtsTokenizationOption { + HTML = 1; + ATOM = 2; + } + + optional FtsTokenizationOption fts_tokenization_option = 8; + + optional string locale = 9 [default = "en"]; +} + +message Path { + repeated group Element = 1 { + required string type = 2; + optional int64 id = 3; + optional string name = 4; + } +} + +message Reference { + required string app = 13; + optional string name_space = 20; + required Path path = 14; +} + +message User { + required string email = 1; + required string auth_domain = 2; + optional string nickname = 3; + optional string federated_identity = 6; + optional string federated_provider = 7; +} + +message EntityProto { + required Reference key = 13; + required Path entity_group = 16; + optional User owner = 17; + + enum Kind { + GD_CONTACT = 1; + GD_EVENT = 2; + GD_MESSAGE = 3; + } + optional Kind kind = 4; + optional string kind_uri = 5; + + repeated Property property = 14; + repeated Property raw_property = 15; + + optional int32 rank = 18; +} + +message CompositeProperty { + required int64 index_id = 1; + repeated string value = 2; +} + +message Index { + required string entity_type = 1; + required bool ancestor = 5; + repeated group Property = 2 { + required string name = 3; + enum Direction { + ASCENDING = 1; + DESCENDING = 2; + } + optional Direction direction = 4 [default = ASCENDING]; + } +} + +message CompositeIndex { + required string app_id = 1; + required int64 id = 2; + required Index definition = 3; + + enum State { + WRITE_ONLY = 1; + READ_WRITE = 2; + DELETED = 3; + ERROR = 4; + } + required State state = 4; + + optional bool only_use_if_required = 6 [default = false]; +} + +message IndexPostfix { + message IndexValue { + required string property_name = 1; + required PropertyValue value = 2; + } + + repeated IndexValue index_value = 1; + + optional Reference key = 2; + + optional bool before = 3 [default=true]; +} + +message IndexPosition { + optional string key = 1; + + optional bool before = 2 [default=true]; +} + +message Snapshot { + enum Status { + INACTIVE = 0; + ACTIVE = 1; + } + + required int64 ts = 1; +} + +message InternalHeader { + optional string qos = 1; +} + +message Transaction { + optional InternalHeader header = 4; + required fixed64 handle = 1; + required string app = 2; + optional bool mark_changes = 3 [default = false]; +} + +message Query { + optional InternalHeader header = 39; + + required string app = 1; + optional string name_space = 29; + + optional string kind = 3; + optional Reference ancestor = 17; + + repeated group Filter = 4 { + enum Operator { + LESS_THAN = 1; + LESS_THAN_OR_EQUAL = 2; + GREATER_THAN = 3; + GREATER_THAN_OR_EQUAL = 4; + EQUAL = 5; + IN = 6; + EXISTS = 7; + } + + required Operator op = 6; + repeated Property property = 14; + } + + optional string search_query = 8; + + repeated group Order = 9 { + enum Direction { + ASCENDING = 1; + DESCENDING = 2; + } + + required string property = 10; + optional Direction direction = 11 [default = ASCENDING]; + } + + enum Hint { + ORDER_FIRST = 1; + ANCESTOR_FIRST = 2; + FILTER_FIRST = 3; + } + optional Hint hint = 18; + + optional int32 count = 23; + + optional int32 offset = 12 [default = 0]; + + optional int32 limit = 16; + + optional CompiledCursor compiled_cursor = 30; + optional CompiledCursor end_compiled_cursor = 31; + + repeated CompositeIndex composite_index = 19; + + optional bool require_perfect_plan = 20 [default = false]; + + optional bool keys_only = 21 [default = false]; + + optional Transaction transaction = 22; + + optional bool compile = 25 [default = false]; + + optional int64 failover_ms = 26; + + optional bool strong = 32; + + repeated string property_name = 33; + + repeated string group_by_property_name = 34; + + optional bool distinct = 24; + + optional int64 min_safe_time_seconds = 35; + + repeated string safe_replica_name = 36; + + optional bool persist_offset = 37 [default=false]; +} + +message CompiledQuery { + required group PrimaryScan = 1 { + optional string index_name = 2; + + optional string start_key = 3; + optional bool start_inclusive = 4; + optional string end_key = 5; + optional bool end_inclusive = 6; + + repeated string start_postfix_value = 22; + repeated string end_postfix_value = 23; + + optional int64 end_unapplied_log_timestamp_us = 19; + } + + repeated group MergeJoinScan = 7 { + required string index_name = 8; + + repeated string prefix_value = 9; + + optional bool value_prefix = 20 [default=false]; + } + + optional Index index_def = 21; + + optional int32 offset = 10 [default = 0]; + + optional int32 limit = 11; + + required bool keys_only = 12; + + repeated string property_name = 24; + + optional int32 distinct_infix_size = 25; + + optional group EntityFilter = 13 { + optional bool distinct = 14 [default=false]; + + optional string kind = 17; + optional Reference ancestor = 18; + } +} + +message CompiledCursor { + optional group Position = 2 { + optional string start_key = 27; + + repeated group IndexValue = 29 { + optional string property = 30; + required PropertyValue value = 31; + } + + optional Reference key = 32; + + optional bool start_inclusive = 28 [default=true]; + } +} + +message Cursor { + required fixed64 cursor = 1; + + optional string app = 2; +} + +message Error { + enum ErrorCode { + BAD_REQUEST = 1; + CONCURRENT_TRANSACTION = 2; + INTERNAL_ERROR = 3; + NEED_INDEX = 4; + TIMEOUT = 5; + PERMISSION_DENIED = 6; + BIGTABLE_ERROR = 7; + COMMITTED_BUT_STILL_APPLYING = 8; + CAPABILITY_DISABLED = 9; + TRY_ALTERNATE_BACKEND = 10; + SAFE_TIME_TOO_OLD = 11; + } +} + +message Cost { + optional int32 index_writes = 1; + optional int32 index_write_bytes = 2; + optional int32 entity_writes = 3; + optional int32 entity_write_bytes = 4; + optional group CommitCost = 5 { + optional int32 requested_entity_puts = 6; + optional int32 requested_entity_deletes = 7; + }; + optional int32 approximate_storage_delta = 8; + optional int32 id_sequence_updates = 9; +} + +message GetRequest { + optional InternalHeader header = 6; + + repeated Reference key = 1; + optional Transaction transaction = 2; + + optional int64 failover_ms = 3; + + optional bool strong = 4; + + optional bool allow_deferred = 5 [default=false]; +} + +message GetResponse { + repeated group Entity = 1 { + optional EntityProto entity = 2; + optional Reference key = 4; + + optional int64 version = 3; + } + + repeated Reference deferred = 5; + + optional bool in_order = 6 [default=true]; +} + +message PutRequest { + optional InternalHeader header = 11; + + repeated EntityProto entity = 1; + optional Transaction transaction = 2; + repeated CompositeIndex composite_index = 3; + + optional bool trusted = 4 [default = false]; + + optional bool force = 7 [default = false]; + + optional bool mark_changes = 8 [default = false]; + repeated Snapshot snapshot = 9; + + enum AutoIdPolicy { + CURRENT = 0; + SEQUENTIAL = 1; + } + optional AutoIdPolicy auto_id_policy = 10 [default = CURRENT]; +} + +message PutResponse { + repeated Reference key = 1; + optional Cost cost = 2; + repeated int64 version = 3; +} + +message TouchRequest { + optional InternalHeader header = 10; + + repeated Reference key = 1; + repeated CompositeIndex composite_index = 2; + optional bool force = 3 [default = false]; + repeated Snapshot snapshot = 9; +} + +message TouchResponse { + optional Cost cost = 1; +} + +message DeleteRequest { + optional InternalHeader header = 10; + + repeated Reference key = 6; + optional Transaction transaction = 5; + + optional bool trusted = 4 [default = false]; + + optional bool force = 7 [default = false]; + + optional bool mark_changes = 8 [default = false]; + repeated Snapshot snapshot = 9; +} + +message DeleteResponse { + optional Cost cost = 1; + repeated int64 version = 3; +} + +message NextRequest { + optional InternalHeader header = 5; + + required Cursor cursor = 1; + optional int32 count = 2; + + optional int32 offset = 4 [default = 0]; + + optional bool compile = 3 [default = false]; +} + +message QueryResult { + optional Cursor cursor = 1; + + repeated EntityProto result = 2; + + optional int32 skipped_results = 7; + + required bool more_results = 3; + + optional bool keys_only = 4; + + optional bool index_only = 9; + + optional bool small_ops = 10; + + optional CompiledQuery compiled_query = 5; + + optional CompiledCursor compiled_cursor = 6; + + repeated CompositeIndex index = 8; + + repeated int64 version = 11; +} + +message AllocateIdsRequest { + optional InternalHeader header = 4; + + optional Reference model_key = 1; + + optional int64 size = 2; + + optional int64 max = 3; + + repeated Reference reserve = 5; +} + +message AllocateIdsResponse { + required int64 start = 1; + required int64 end = 2; + optional Cost cost = 3; +} + +message CompositeIndices { + repeated CompositeIndex index = 1; +} + +message AddActionsRequest { + optional InternalHeader header = 3; + + required Transaction transaction = 1; + repeated Action action = 2; +} + +message AddActionsResponse { +} + +message BeginTransactionRequest { + optional InternalHeader header = 3; + + required string app = 1; + optional bool allow_multiple_eg = 2 [default = false]; +} + +message CommitResponse { + optional Cost cost = 1; + + repeated group Version = 3 { + required Reference root_entity_key = 4; + required int64 version = 5; + } +} diff --git a/vendor/google.golang.org/appengine/internal/identity.go b/vendor/google.golang.org/appengine/internal/identity.go new file mode 100644 index 0000000000..d538701ab3 --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/identity.go @@ -0,0 +1,14 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package internal + +import netcontext "golang.org/x/net/context" + +// These functions are implementations of the wrapper functions +// in ../appengine/identity.go. See that file for commentary. + +func AppID(c netcontext.Context) string { + return appID(FullyQualifiedAppID(c)) +} diff --git a/vendor/google.golang.org/appengine/internal/identity_classic.go b/vendor/google.golang.org/appengine/internal/identity_classic.go new file mode 100644 index 0000000000..e6b9227c56 --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/identity_classic.go @@ -0,0 +1,27 @@ +// Copyright 2015 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +// +build appengine + +package internal + +import ( + "appengine" + + netcontext "golang.org/x/net/context" +) + +func DefaultVersionHostname(ctx netcontext.Context) string { + return appengine.DefaultVersionHostname(fromContext(ctx)) +} + +func RequestID(ctx netcontext.Context) string { return appengine.RequestID(fromContext(ctx)) } +func Datacenter(_ netcontext.Context) string { return appengine.Datacenter() } +func ServerSoftware() string { return appengine.ServerSoftware() } +func ModuleName(ctx netcontext.Context) string { return appengine.ModuleName(fromContext(ctx)) } +func VersionID(ctx netcontext.Context) string { return appengine.VersionID(fromContext(ctx)) } +func InstanceID() string { return appengine.InstanceID() } +func IsDevAppServer() bool { return appengine.IsDevAppServer() } + +func fullyQualifiedAppID(ctx netcontext.Context) string { return fromContext(ctx).FullyQualifiedAppID() } diff --git a/vendor/google.golang.org/appengine/internal/identity_vm.go b/vendor/google.golang.org/appengine/internal/identity_vm.go new file mode 100644 index 0000000000..ebe68b785b --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/identity_vm.go @@ -0,0 +1,97 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +// +build !appengine + +package internal + +import ( + "net/http" + "os" + + netcontext "golang.org/x/net/context" +) + +// These functions are implementations of the wrapper functions +// in ../appengine/identity.go. See that file for commentary. + +const ( + hDefaultVersionHostname = "X-AppEngine-Default-Version-Hostname" + hRequestLogId = "X-AppEngine-Request-Log-Id" + hDatacenter = "X-AppEngine-Datacenter" +) + +func ctxHeaders(ctx netcontext.Context) http.Header { + return fromContext(ctx).Request().Header +} + +func DefaultVersionHostname(ctx netcontext.Context) string { + return ctxHeaders(ctx).Get(hDefaultVersionHostname) +} + +func RequestID(ctx netcontext.Context) string { + return ctxHeaders(ctx).Get(hRequestLogId) +} + +func Datacenter(ctx netcontext.Context) string { + return ctxHeaders(ctx).Get(hDatacenter) +} + +func ServerSoftware() string { + // TODO(dsymonds): Remove fallback when we've verified this. + if s := os.Getenv("SERVER_SOFTWARE"); s != "" { + return s + } + return "Google App Engine/1.x.x" +} + +// TODO(dsymonds): Remove the metadata fetches. + +func ModuleName(_ netcontext.Context) string { + if s := os.Getenv("GAE_MODULE_NAME"); s != "" { + return s + } + return string(mustGetMetadata("instance/attributes/gae_backend_name")) +} + +func VersionID(_ netcontext.Context) string { + if s1, s2 := os.Getenv("GAE_MODULE_VERSION"), os.Getenv("GAE_MINOR_VERSION"); s1 != "" && s2 != "" { + return s1 + "." + s2 + } + return string(mustGetMetadata("instance/attributes/gae_backend_version")) + "." + string(mustGetMetadata("instance/attributes/gae_backend_minor_version")) +} + +func InstanceID() string { + if s := os.Getenv("GAE_MODULE_INSTANCE"); s != "" { + return s + } + return string(mustGetMetadata("instance/attributes/gae_backend_instance")) +} + +func partitionlessAppID() string { + // gae_project has everything except the partition prefix. + appID := os.Getenv("GAE_LONG_APP_ID") + if appID == "" { + appID = string(mustGetMetadata("instance/attributes/gae_project")) + } + return appID +} + +func fullyQualifiedAppID(_ netcontext.Context) string { + appID := partitionlessAppID() + + part := os.Getenv("GAE_PARTITION") + if part == "" { + part = string(mustGetMetadata("instance/attributes/gae_partition")) + } + + if part != "" { + appID = part + "~" + appID + } + return appID +} + +func IsDevAppServer() bool { + return os.Getenv("RUN_WITH_DEVAPPSERVER") != "" +} diff --git a/vendor/google.golang.org/appengine/internal/internal.go b/vendor/google.golang.org/appengine/internal/internal.go new file mode 100644 index 0000000000..66e8d76866 --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/internal.go @@ -0,0 +1,144 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +// Package internal provides support for package appengine. +// +// Programs should not use this package directly. Its API is not stable. +// Use packages appengine and appengine/* instead. +package internal + +import ( + "fmt" + "io" + "log" + "net/http" + "net/url" + "os" + + "github.com/golang/protobuf/proto" + + remotepb "google.golang.org/appengine/internal/remote_api" +) + +// errorCodeMaps is a map of service name to the error code map for the service. +var errorCodeMaps = make(map[string]map[int32]string) + +// RegisterErrorCodeMap is called from API implementations to register their +// error code map. This should only be called from init functions. +func RegisterErrorCodeMap(service string, m map[int32]string) { + errorCodeMaps[service] = m +} + +type timeoutCodeKey struct { + service string + code int32 +} + +// timeoutCodes is the set of service+code pairs that represent timeouts. +var timeoutCodes = make(map[timeoutCodeKey]bool) + +func RegisterTimeoutErrorCode(service string, code int32) { + timeoutCodes[timeoutCodeKey{service, code}] = true +} + +// APIError is the type returned by appengine.Context's Call method +// when an API call fails in an API-specific way. This may be, for instance, +// a taskqueue API call failing with TaskQueueServiceError::UNKNOWN_QUEUE. +type APIError struct { + Service string + Detail string + Code int32 // API-specific error code +} + +func (e *APIError) Error() string { + if e.Code == 0 { + if e.Detail == "" { + return "APIError " + } + return e.Detail + } + s := fmt.Sprintf("API error %d", e.Code) + if m, ok := errorCodeMaps[e.Service]; ok { + s += " (" + e.Service + ": " + m[e.Code] + ")" + } else { + // Shouldn't happen, but provide a bit more detail if it does. + s = e.Service + " " + s + } + if e.Detail != "" { + s += ": " + e.Detail + } + return s +} + +func (e *APIError) IsTimeout() bool { + return timeoutCodes[timeoutCodeKey{e.Service, e.Code}] +} + +// CallError is the type returned by appengine.Context's Call method when an +// API call fails in a generic way, such as RpcError::CAPABILITY_DISABLED. +type CallError struct { + Detail string + Code int32 + // TODO: Remove this if we get a distinguishable error code. + Timeout bool +} + +func (e *CallError) Error() string { + var msg string + switch remotepb.RpcError_ErrorCode(e.Code) { + case remotepb.RpcError_UNKNOWN: + return e.Detail + case remotepb.RpcError_OVER_QUOTA: + msg = "Over quota" + case remotepb.RpcError_CAPABILITY_DISABLED: + msg = "Capability disabled" + case remotepb.RpcError_CANCELLED: + msg = "Canceled" + default: + msg = fmt.Sprintf("Call error %d", e.Code) + } + s := msg + ": " + e.Detail + if e.Timeout { + s += " (timeout)" + } + return s +} + +func (e *CallError) IsTimeout() bool { + return e.Timeout +} + +func Main() { + installHealthChecker(http.DefaultServeMux) + + port := "8080" + if s := os.Getenv("PORT"); s != "" { + port = s + } + + if err := http.ListenAndServe(":"+port, http.HandlerFunc(handleHTTP)); err != nil { + log.Fatalf("http.ListenAndServe: %v", err) + } +} + +func installHealthChecker(mux *http.ServeMux) { + // If no health check handler has been installed by this point, add a trivial one. + const healthPath = "/_ah/health" + hreq := &http.Request{ + Method: "GET", + URL: &url.URL{ + Path: healthPath, + }, + } + if _, pat := mux.Handler(hreq); pat != healthPath { + mux.HandleFunc(healthPath, func(w http.ResponseWriter, r *http.Request) { + io.WriteString(w, "ok") + }) + } +} + +// NamespaceMods is a map from API service to a function that will mutate an RPC request to attach a namespace. +// The function should be prepared to be called on the same message more than once; it should only modify the +// RPC request the first time. +var NamespaceMods = make(map[string]func(m proto.Message, namespace string)) diff --git a/vendor/google.golang.org/appengine/internal/log/log_service.pb.go b/vendor/google.golang.org/appengine/internal/log/log_service.pb.go new file mode 100644 index 0000000000..20c595be30 --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/log/log_service.pb.go @@ -0,0 +1,899 @@ +// Code generated by protoc-gen-go. +// source: google.golang.org/appengine/internal/log/log_service.proto +// DO NOT EDIT! + +/* +Package log is a generated protocol buffer package. + +It is generated from these files: + google.golang.org/appengine/internal/log/log_service.proto + +It has these top-level messages: + LogServiceError + UserAppLogLine + UserAppLogGroup + FlushRequest + SetStatusRequest + LogOffset + LogLine + RequestLog + LogModuleVersion + LogReadRequest + LogReadResponse + LogUsageRecord + LogUsageRequest + LogUsageResponse +*/ +package log + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +type LogServiceError_ErrorCode int32 + +const ( + LogServiceError_OK LogServiceError_ErrorCode = 0 + LogServiceError_INVALID_REQUEST LogServiceError_ErrorCode = 1 + LogServiceError_STORAGE_ERROR LogServiceError_ErrorCode = 2 +) + +var LogServiceError_ErrorCode_name = map[int32]string{ + 0: "OK", + 1: "INVALID_REQUEST", + 2: "STORAGE_ERROR", +} +var LogServiceError_ErrorCode_value = map[string]int32{ + "OK": 0, + "INVALID_REQUEST": 1, + "STORAGE_ERROR": 2, +} + +func (x LogServiceError_ErrorCode) Enum() *LogServiceError_ErrorCode { + p := new(LogServiceError_ErrorCode) + *p = x + return p +} +func (x LogServiceError_ErrorCode) String() string { + return proto.EnumName(LogServiceError_ErrorCode_name, int32(x)) +} +func (x *LogServiceError_ErrorCode) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(LogServiceError_ErrorCode_value, data, "LogServiceError_ErrorCode") + if err != nil { + return err + } + *x = LogServiceError_ErrorCode(value) + return nil +} + +type LogServiceError struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *LogServiceError) Reset() { *m = LogServiceError{} } +func (m *LogServiceError) String() string { return proto.CompactTextString(m) } +func (*LogServiceError) ProtoMessage() {} + +type UserAppLogLine struct { + TimestampUsec *int64 `protobuf:"varint,1,req,name=timestamp_usec" json:"timestamp_usec,omitempty"` + Level *int64 `protobuf:"varint,2,req,name=level" json:"level,omitempty"` + Message *string `protobuf:"bytes,3,req,name=message" json:"message,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *UserAppLogLine) Reset() { *m = UserAppLogLine{} } +func (m *UserAppLogLine) String() string { return proto.CompactTextString(m) } +func (*UserAppLogLine) ProtoMessage() {} + +func (m *UserAppLogLine) GetTimestampUsec() int64 { + if m != nil && m.TimestampUsec != nil { + return *m.TimestampUsec + } + return 0 +} + +func (m *UserAppLogLine) GetLevel() int64 { + if m != nil && m.Level != nil { + return *m.Level + } + return 0 +} + +func (m *UserAppLogLine) GetMessage() string { + if m != nil && m.Message != nil { + return *m.Message + } + return "" +} + +type UserAppLogGroup struct { + LogLine []*UserAppLogLine `protobuf:"bytes,2,rep,name=log_line" json:"log_line,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *UserAppLogGroup) Reset() { *m = UserAppLogGroup{} } +func (m *UserAppLogGroup) String() string { return proto.CompactTextString(m) } +func (*UserAppLogGroup) ProtoMessage() {} + +func (m *UserAppLogGroup) GetLogLine() []*UserAppLogLine { + if m != nil { + return m.LogLine + } + return nil +} + +type FlushRequest struct { + Logs []byte `protobuf:"bytes,1,opt,name=logs" json:"logs,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *FlushRequest) Reset() { *m = FlushRequest{} } +func (m *FlushRequest) String() string { return proto.CompactTextString(m) } +func (*FlushRequest) ProtoMessage() {} + +func (m *FlushRequest) GetLogs() []byte { + if m != nil { + return m.Logs + } + return nil +} + +type SetStatusRequest struct { + Status *string `protobuf:"bytes,1,req,name=status" json:"status,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *SetStatusRequest) Reset() { *m = SetStatusRequest{} } +func (m *SetStatusRequest) String() string { return proto.CompactTextString(m) } +func (*SetStatusRequest) ProtoMessage() {} + +func (m *SetStatusRequest) GetStatus() string { + if m != nil && m.Status != nil { + return *m.Status + } + return "" +} + +type LogOffset struct { + RequestId []byte `protobuf:"bytes,1,opt,name=request_id" json:"request_id,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *LogOffset) Reset() { *m = LogOffset{} } +func (m *LogOffset) String() string { return proto.CompactTextString(m) } +func (*LogOffset) ProtoMessage() {} + +func (m *LogOffset) GetRequestId() []byte { + if m != nil { + return m.RequestId + } + return nil +} + +type LogLine struct { + Time *int64 `protobuf:"varint,1,req,name=time" json:"time,omitempty"` + Level *int32 `protobuf:"varint,2,req,name=level" json:"level,omitempty"` + LogMessage *string `protobuf:"bytes,3,req,name=log_message" json:"log_message,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *LogLine) Reset() { *m = LogLine{} } +func (m *LogLine) String() string { return proto.CompactTextString(m) } +func (*LogLine) ProtoMessage() {} + +func (m *LogLine) GetTime() int64 { + if m != nil && m.Time != nil { + return *m.Time + } + return 0 +} + +func (m *LogLine) GetLevel() int32 { + if m != nil && m.Level != nil { + return *m.Level + } + return 0 +} + +func (m *LogLine) GetLogMessage() string { + if m != nil && m.LogMessage != nil { + return *m.LogMessage + } + return "" +} + +type RequestLog struct { + AppId *string `protobuf:"bytes,1,req,name=app_id" json:"app_id,omitempty"` + ModuleId *string `protobuf:"bytes,37,opt,name=module_id,def=default" json:"module_id,omitempty"` + VersionId *string `protobuf:"bytes,2,req,name=version_id" json:"version_id,omitempty"` + RequestId []byte `protobuf:"bytes,3,req,name=request_id" json:"request_id,omitempty"` + Offset *LogOffset `protobuf:"bytes,35,opt,name=offset" json:"offset,omitempty"` + Ip *string `protobuf:"bytes,4,req,name=ip" json:"ip,omitempty"` + Nickname *string `protobuf:"bytes,5,opt,name=nickname" json:"nickname,omitempty"` + StartTime *int64 `protobuf:"varint,6,req,name=start_time" json:"start_time,omitempty"` + EndTime *int64 `protobuf:"varint,7,req,name=end_time" json:"end_time,omitempty"` + Latency *int64 `protobuf:"varint,8,req,name=latency" json:"latency,omitempty"` + Mcycles *int64 `protobuf:"varint,9,req,name=mcycles" json:"mcycles,omitempty"` + Method *string `protobuf:"bytes,10,req,name=method" json:"method,omitempty"` + Resource *string `protobuf:"bytes,11,req,name=resource" json:"resource,omitempty"` + HttpVersion *string `protobuf:"bytes,12,req,name=http_version" json:"http_version,omitempty"` + Status *int32 `protobuf:"varint,13,req,name=status" json:"status,omitempty"` + ResponseSize *int64 `protobuf:"varint,14,req,name=response_size" json:"response_size,omitempty"` + Referrer *string `protobuf:"bytes,15,opt,name=referrer" json:"referrer,omitempty"` + UserAgent *string `protobuf:"bytes,16,opt,name=user_agent" json:"user_agent,omitempty"` + UrlMapEntry *string `protobuf:"bytes,17,req,name=url_map_entry" json:"url_map_entry,omitempty"` + Combined *string `protobuf:"bytes,18,req,name=combined" json:"combined,omitempty"` + ApiMcycles *int64 `protobuf:"varint,19,opt,name=api_mcycles" json:"api_mcycles,omitempty"` + Host *string `protobuf:"bytes,20,opt,name=host" json:"host,omitempty"` + Cost *float64 `protobuf:"fixed64,21,opt,name=cost" json:"cost,omitempty"` + TaskQueueName *string `protobuf:"bytes,22,opt,name=task_queue_name" json:"task_queue_name,omitempty"` + TaskName *string `protobuf:"bytes,23,opt,name=task_name" json:"task_name,omitempty"` + WasLoadingRequest *bool `protobuf:"varint,24,opt,name=was_loading_request" json:"was_loading_request,omitempty"` + PendingTime *int64 `protobuf:"varint,25,opt,name=pending_time" json:"pending_time,omitempty"` + ReplicaIndex *int32 `protobuf:"varint,26,opt,name=replica_index,def=-1" json:"replica_index,omitempty"` + Finished *bool `protobuf:"varint,27,opt,name=finished,def=1" json:"finished,omitempty"` + CloneKey []byte `protobuf:"bytes,28,opt,name=clone_key" json:"clone_key,omitempty"` + Line []*LogLine `protobuf:"bytes,29,rep,name=line" json:"line,omitempty"` + LinesIncomplete *bool `protobuf:"varint,36,opt,name=lines_incomplete" json:"lines_incomplete,omitempty"` + AppEngineRelease []byte `protobuf:"bytes,38,opt,name=app_engine_release" json:"app_engine_release,omitempty"` + ExitReason *int32 `protobuf:"varint,30,opt,name=exit_reason" json:"exit_reason,omitempty"` + WasThrottledForTime *bool `protobuf:"varint,31,opt,name=was_throttled_for_time" json:"was_throttled_for_time,omitempty"` + WasThrottledForRequests *bool `protobuf:"varint,32,opt,name=was_throttled_for_requests" json:"was_throttled_for_requests,omitempty"` + ThrottledTime *int64 `protobuf:"varint,33,opt,name=throttled_time" json:"throttled_time,omitempty"` + ServerName []byte `protobuf:"bytes,34,opt,name=server_name" json:"server_name,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *RequestLog) Reset() { *m = RequestLog{} } +func (m *RequestLog) String() string { return proto.CompactTextString(m) } +func (*RequestLog) ProtoMessage() {} + +const Default_RequestLog_ModuleId string = "default" +const Default_RequestLog_ReplicaIndex int32 = -1 +const Default_RequestLog_Finished bool = true + +func (m *RequestLog) GetAppId() string { + if m != nil && m.AppId != nil { + return *m.AppId + } + return "" +} + +func (m *RequestLog) GetModuleId() string { + if m != nil && m.ModuleId != nil { + return *m.ModuleId + } + return Default_RequestLog_ModuleId +} + +func (m *RequestLog) GetVersionId() string { + if m != nil && m.VersionId != nil { + return *m.VersionId + } + return "" +} + +func (m *RequestLog) GetRequestId() []byte { + if m != nil { + return m.RequestId + } + return nil +} + +func (m *RequestLog) GetOffset() *LogOffset { + if m != nil { + return m.Offset + } + return nil +} + +func (m *RequestLog) GetIp() string { + if m != nil && m.Ip != nil { + return *m.Ip + } + return "" +} + +func (m *RequestLog) GetNickname() string { + if m != nil && m.Nickname != nil { + return *m.Nickname + } + return "" +} + +func (m *RequestLog) GetStartTime() int64 { + if m != nil && m.StartTime != nil { + return *m.StartTime + } + return 0 +} + +func (m *RequestLog) GetEndTime() int64 { + if m != nil && m.EndTime != nil { + return *m.EndTime + } + return 0 +} + +func (m *RequestLog) GetLatency() int64 { + if m != nil && m.Latency != nil { + return *m.Latency + } + return 0 +} + +func (m *RequestLog) GetMcycles() int64 { + if m != nil && m.Mcycles != nil { + return *m.Mcycles + } + return 0 +} + +func (m *RequestLog) GetMethod() string { + if m != nil && m.Method != nil { + return *m.Method + } + return "" +} + +func (m *RequestLog) GetResource() string { + if m != nil && m.Resource != nil { + return *m.Resource + } + return "" +} + +func (m *RequestLog) GetHttpVersion() string { + if m != nil && m.HttpVersion != nil { + return *m.HttpVersion + } + return "" +} + +func (m *RequestLog) GetStatus() int32 { + if m != nil && m.Status != nil { + return *m.Status + } + return 0 +} + +func (m *RequestLog) GetResponseSize() int64 { + if m != nil && m.ResponseSize != nil { + return *m.ResponseSize + } + return 0 +} + +func (m *RequestLog) GetReferrer() string { + if m != nil && m.Referrer != nil { + return *m.Referrer + } + return "" +} + +func (m *RequestLog) GetUserAgent() string { + if m != nil && m.UserAgent != nil { + return *m.UserAgent + } + return "" +} + +func (m *RequestLog) GetUrlMapEntry() string { + if m != nil && m.UrlMapEntry != nil { + return *m.UrlMapEntry + } + return "" +} + +func (m *RequestLog) GetCombined() string { + if m != nil && m.Combined != nil { + return *m.Combined + } + return "" +} + +func (m *RequestLog) GetApiMcycles() int64 { + if m != nil && m.ApiMcycles != nil { + return *m.ApiMcycles + } + return 0 +} + +func (m *RequestLog) GetHost() string { + if m != nil && m.Host != nil { + return *m.Host + } + return "" +} + +func (m *RequestLog) GetCost() float64 { + if m != nil && m.Cost != nil { + return *m.Cost + } + return 0 +} + +func (m *RequestLog) GetTaskQueueName() string { + if m != nil && m.TaskQueueName != nil { + return *m.TaskQueueName + } + return "" +} + +func (m *RequestLog) GetTaskName() string { + if m != nil && m.TaskName != nil { + return *m.TaskName + } + return "" +} + +func (m *RequestLog) GetWasLoadingRequest() bool { + if m != nil && m.WasLoadingRequest != nil { + return *m.WasLoadingRequest + } + return false +} + +func (m *RequestLog) GetPendingTime() int64 { + if m != nil && m.PendingTime != nil { + return *m.PendingTime + } + return 0 +} + +func (m *RequestLog) GetReplicaIndex() int32 { + if m != nil && m.ReplicaIndex != nil { + return *m.ReplicaIndex + } + return Default_RequestLog_ReplicaIndex +} + +func (m *RequestLog) GetFinished() bool { + if m != nil && m.Finished != nil { + return *m.Finished + } + return Default_RequestLog_Finished +} + +func (m *RequestLog) GetCloneKey() []byte { + if m != nil { + return m.CloneKey + } + return nil +} + +func (m *RequestLog) GetLine() []*LogLine { + if m != nil { + return m.Line + } + return nil +} + +func (m *RequestLog) GetLinesIncomplete() bool { + if m != nil && m.LinesIncomplete != nil { + return *m.LinesIncomplete + } + return false +} + +func (m *RequestLog) GetAppEngineRelease() []byte { + if m != nil { + return m.AppEngineRelease + } + return nil +} + +func (m *RequestLog) GetExitReason() int32 { + if m != nil && m.ExitReason != nil { + return *m.ExitReason + } + return 0 +} + +func (m *RequestLog) GetWasThrottledForTime() bool { + if m != nil && m.WasThrottledForTime != nil { + return *m.WasThrottledForTime + } + return false +} + +func (m *RequestLog) GetWasThrottledForRequests() bool { + if m != nil && m.WasThrottledForRequests != nil { + return *m.WasThrottledForRequests + } + return false +} + +func (m *RequestLog) GetThrottledTime() int64 { + if m != nil && m.ThrottledTime != nil { + return *m.ThrottledTime + } + return 0 +} + +func (m *RequestLog) GetServerName() []byte { + if m != nil { + return m.ServerName + } + return nil +} + +type LogModuleVersion struct { + ModuleId *string `protobuf:"bytes,1,opt,name=module_id,def=default" json:"module_id,omitempty"` + VersionId *string `protobuf:"bytes,2,opt,name=version_id" json:"version_id,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *LogModuleVersion) Reset() { *m = LogModuleVersion{} } +func (m *LogModuleVersion) String() string { return proto.CompactTextString(m) } +func (*LogModuleVersion) ProtoMessage() {} + +const Default_LogModuleVersion_ModuleId string = "default" + +func (m *LogModuleVersion) GetModuleId() string { + if m != nil && m.ModuleId != nil { + return *m.ModuleId + } + return Default_LogModuleVersion_ModuleId +} + +func (m *LogModuleVersion) GetVersionId() string { + if m != nil && m.VersionId != nil { + return *m.VersionId + } + return "" +} + +type LogReadRequest struct { + AppId *string `protobuf:"bytes,1,req,name=app_id" json:"app_id,omitempty"` + VersionId []string `protobuf:"bytes,2,rep,name=version_id" json:"version_id,omitempty"` + ModuleVersion []*LogModuleVersion `protobuf:"bytes,19,rep,name=module_version" json:"module_version,omitempty"` + StartTime *int64 `protobuf:"varint,3,opt,name=start_time" json:"start_time,omitempty"` + EndTime *int64 `protobuf:"varint,4,opt,name=end_time" json:"end_time,omitempty"` + Offset *LogOffset `protobuf:"bytes,5,opt,name=offset" json:"offset,omitempty"` + RequestId [][]byte `protobuf:"bytes,6,rep,name=request_id" json:"request_id,omitempty"` + MinimumLogLevel *int32 `protobuf:"varint,7,opt,name=minimum_log_level" json:"minimum_log_level,omitempty"` + IncludeIncomplete *bool `protobuf:"varint,8,opt,name=include_incomplete" json:"include_incomplete,omitempty"` + Count *int64 `protobuf:"varint,9,opt,name=count" json:"count,omitempty"` + CombinedLogRegex *string `protobuf:"bytes,14,opt,name=combined_log_regex" json:"combined_log_regex,omitempty"` + HostRegex *string `protobuf:"bytes,15,opt,name=host_regex" json:"host_regex,omitempty"` + ReplicaIndex *int32 `protobuf:"varint,16,opt,name=replica_index" json:"replica_index,omitempty"` + IncludeAppLogs *bool `protobuf:"varint,10,opt,name=include_app_logs" json:"include_app_logs,omitempty"` + AppLogsPerRequest *int32 `protobuf:"varint,17,opt,name=app_logs_per_request" json:"app_logs_per_request,omitempty"` + IncludeHost *bool `protobuf:"varint,11,opt,name=include_host" json:"include_host,omitempty"` + IncludeAll *bool `protobuf:"varint,12,opt,name=include_all" json:"include_all,omitempty"` + CacheIterator *bool `protobuf:"varint,13,opt,name=cache_iterator" json:"cache_iterator,omitempty"` + NumShards *int32 `protobuf:"varint,18,opt,name=num_shards" json:"num_shards,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *LogReadRequest) Reset() { *m = LogReadRequest{} } +func (m *LogReadRequest) String() string { return proto.CompactTextString(m) } +func (*LogReadRequest) ProtoMessage() {} + +func (m *LogReadRequest) GetAppId() string { + if m != nil && m.AppId != nil { + return *m.AppId + } + return "" +} + +func (m *LogReadRequest) GetVersionId() []string { + if m != nil { + return m.VersionId + } + return nil +} + +func (m *LogReadRequest) GetModuleVersion() []*LogModuleVersion { + if m != nil { + return m.ModuleVersion + } + return nil +} + +func (m *LogReadRequest) GetStartTime() int64 { + if m != nil && m.StartTime != nil { + return *m.StartTime + } + return 0 +} + +func (m *LogReadRequest) GetEndTime() int64 { + if m != nil && m.EndTime != nil { + return *m.EndTime + } + return 0 +} + +func (m *LogReadRequest) GetOffset() *LogOffset { + if m != nil { + return m.Offset + } + return nil +} + +func (m *LogReadRequest) GetRequestId() [][]byte { + if m != nil { + return m.RequestId + } + return nil +} + +func (m *LogReadRequest) GetMinimumLogLevel() int32 { + if m != nil && m.MinimumLogLevel != nil { + return *m.MinimumLogLevel + } + return 0 +} + +func (m *LogReadRequest) GetIncludeIncomplete() bool { + if m != nil && m.IncludeIncomplete != nil { + return *m.IncludeIncomplete + } + return false +} + +func (m *LogReadRequest) GetCount() int64 { + if m != nil && m.Count != nil { + return *m.Count + } + return 0 +} + +func (m *LogReadRequest) GetCombinedLogRegex() string { + if m != nil && m.CombinedLogRegex != nil { + return *m.CombinedLogRegex + } + return "" +} + +func (m *LogReadRequest) GetHostRegex() string { + if m != nil && m.HostRegex != nil { + return *m.HostRegex + } + return "" +} + +func (m *LogReadRequest) GetReplicaIndex() int32 { + if m != nil && m.ReplicaIndex != nil { + return *m.ReplicaIndex + } + return 0 +} + +func (m *LogReadRequest) GetIncludeAppLogs() bool { + if m != nil && m.IncludeAppLogs != nil { + return *m.IncludeAppLogs + } + return false +} + +func (m *LogReadRequest) GetAppLogsPerRequest() int32 { + if m != nil && m.AppLogsPerRequest != nil { + return *m.AppLogsPerRequest + } + return 0 +} + +func (m *LogReadRequest) GetIncludeHost() bool { + if m != nil && m.IncludeHost != nil { + return *m.IncludeHost + } + return false +} + +func (m *LogReadRequest) GetIncludeAll() bool { + if m != nil && m.IncludeAll != nil { + return *m.IncludeAll + } + return false +} + +func (m *LogReadRequest) GetCacheIterator() bool { + if m != nil && m.CacheIterator != nil { + return *m.CacheIterator + } + return false +} + +func (m *LogReadRequest) GetNumShards() int32 { + if m != nil && m.NumShards != nil { + return *m.NumShards + } + return 0 +} + +type LogReadResponse struct { + Log []*RequestLog `protobuf:"bytes,1,rep,name=log" json:"log,omitempty"` + Offset *LogOffset `protobuf:"bytes,2,opt,name=offset" json:"offset,omitempty"` + LastEndTime *int64 `protobuf:"varint,3,opt,name=last_end_time" json:"last_end_time,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *LogReadResponse) Reset() { *m = LogReadResponse{} } +func (m *LogReadResponse) String() string { return proto.CompactTextString(m) } +func (*LogReadResponse) ProtoMessage() {} + +func (m *LogReadResponse) GetLog() []*RequestLog { + if m != nil { + return m.Log + } + return nil +} + +func (m *LogReadResponse) GetOffset() *LogOffset { + if m != nil { + return m.Offset + } + return nil +} + +func (m *LogReadResponse) GetLastEndTime() int64 { + if m != nil && m.LastEndTime != nil { + return *m.LastEndTime + } + return 0 +} + +type LogUsageRecord struct { + VersionId *string `protobuf:"bytes,1,opt,name=version_id" json:"version_id,omitempty"` + StartTime *int32 `protobuf:"varint,2,opt,name=start_time" json:"start_time,omitempty"` + EndTime *int32 `protobuf:"varint,3,opt,name=end_time" json:"end_time,omitempty"` + Count *int64 `protobuf:"varint,4,opt,name=count" json:"count,omitempty"` + TotalSize *int64 `protobuf:"varint,5,opt,name=total_size" json:"total_size,omitempty"` + Records *int32 `protobuf:"varint,6,opt,name=records" json:"records,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *LogUsageRecord) Reset() { *m = LogUsageRecord{} } +func (m *LogUsageRecord) String() string { return proto.CompactTextString(m) } +func (*LogUsageRecord) ProtoMessage() {} + +func (m *LogUsageRecord) GetVersionId() string { + if m != nil && m.VersionId != nil { + return *m.VersionId + } + return "" +} + +func (m *LogUsageRecord) GetStartTime() int32 { + if m != nil && m.StartTime != nil { + return *m.StartTime + } + return 0 +} + +func (m *LogUsageRecord) GetEndTime() int32 { + if m != nil && m.EndTime != nil { + return *m.EndTime + } + return 0 +} + +func (m *LogUsageRecord) GetCount() int64 { + if m != nil && m.Count != nil { + return *m.Count + } + return 0 +} + +func (m *LogUsageRecord) GetTotalSize() int64 { + if m != nil && m.TotalSize != nil { + return *m.TotalSize + } + return 0 +} + +func (m *LogUsageRecord) GetRecords() int32 { + if m != nil && m.Records != nil { + return *m.Records + } + return 0 +} + +type LogUsageRequest struct { + AppId *string `protobuf:"bytes,1,req,name=app_id" json:"app_id,omitempty"` + VersionId []string `protobuf:"bytes,2,rep,name=version_id" json:"version_id,omitempty"` + StartTime *int32 `protobuf:"varint,3,opt,name=start_time" json:"start_time,omitempty"` + EndTime *int32 `protobuf:"varint,4,opt,name=end_time" json:"end_time,omitempty"` + ResolutionHours *uint32 `protobuf:"varint,5,opt,name=resolution_hours,def=1" json:"resolution_hours,omitempty"` + CombineVersions *bool `protobuf:"varint,6,opt,name=combine_versions" json:"combine_versions,omitempty"` + UsageVersion *int32 `protobuf:"varint,7,opt,name=usage_version" json:"usage_version,omitempty"` + VersionsOnly *bool `protobuf:"varint,8,opt,name=versions_only" json:"versions_only,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *LogUsageRequest) Reset() { *m = LogUsageRequest{} } +func (m *LogUsageRequest) String() string { return proto.CompactTextString(m) } +func (*LogUsageRequest) ProtoMessage() {} + +const Default_LogUsageRequest_ResolutionHours uint32 = 1 + +func (m *LogUsageRequest) GetAppId() string { + if m != nil && m.AppId != nil { + return *m.AppId + } + return "" +} + +func (m *LogUsageRequest) GetVersionId() []string { + if m != nil { + return m.VersionId + } + return nil +} + +func (m *LogUsageRequest) GetStartTime() int32 { + if m != nil && m.StartTime != nil { + return *m.StartTime + } + return 0 +} + +func (m *LogUsageRequest) GetEndTime() int32 { + if m != nil && m.EndTime != nil { + return *m.EndTime + } + return 0 +} + +func (m *LogUsageRequest) GetResolutionHours() uint32 { + if m != nil && m.ResolutionHours != nil { + return *m.ResolutionHours + } + return Default_LogUsageRequest_ResolutionHours +} + +func (m *LogUsageRequest) GetCombineVersions() bool { + if m != nil && m.CombineVersions != nil { + return *m.CombineVersions + } + return false +} + +func (m *LogUsageRequest) GetUsageVersion() int32 { + if m != nil && m.UsageVersion != nil { + return *m.UsageVersion + } + return 0 +} + +func (m *LogUsageRequest) GetVersionsOnly() bool { + if m != nil && m.VersionsOnly != nil { + return *m.VersionsOnly + } + return false +} + +type LogUsageResponse struct { + Usage []*LogUsageRecord `protobuf:"bytes,1,rep,name=usage" json:"usage,omitempty"` + Summary *LogUsageRecord `protobuf:"bytes,2,opt,name=summary" json:"summary,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *LogUsageResponse) Reset() { *m = LogUsageResponse{} } +func (m *LogUsageResponse) String() string { return proto.CompactTextString(m) } +func (*LogUsageResponse) ProtoMessage() {} + +func (m *LogUsageResponse) GetUsage() []*LogUsageRecord { + if m != nil { + return m.Usage + } + return nil +} + +func (m *LogUsageResponse) GetSummary() *LogUsageRecord { + if m != nil { + return m.Summary + } + return nil +} + +func init() { +} diff --git a/vendor/google.golang.org/appengine/internal/log/log_service.proto b/vendor/google.golang.org/appengine/internal/log/log_service.proto new file mode 100644 index 0000000000..8981dc4757 --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/log/log_service.proto @@ -0,0 +1,150 @@ +syntax = "proto2"; +option go_package = "log"; + +package appengine; + +message LogServiceError { + enum ErrorCode { + OK = 0; + INVALID_REQUEST = 1; + STORAGE_ERROR = 2; + } +} + +message UserAppLogLine { + required int64 timestamp_usec = 1; + required int64 level = 2; + required string message = 3; +} + +message UserAppLogGroup { + repeated UserAppLogLine log_line = 2; +} + +message FlushRequest { + optional bytes logs = 1; +} + +message SetStatusRequest { + required string status = 1; +} + + +message LogOffset { + optional bytes request_id = 1; +} + +message LogLine { + required int64 time = 1; + required int32 level = 2; + required string log_message = 3; +} + +message RequestLog { + required string app_id = 1; + optional string module_id = 37 [default="default"]; + required string version_id = 2; + required bytes request_id = 3; + optional LogOffset offset = 35; + required string ip = 4; + optional string nickname = 5; + required int64 start_time = 6; + required int64 end_time = 7; + required int64 latency = 8; + required int64 mcycles = 9; + required string method = 10; + required string resource = 11; + required string http_version = 12; + required int32 status = 13; + required int64 response_size = 14; + optional string referrer = 15; + optional string user_agent = 16; + required string url_map_entry = 17; + required string combined = 18; + optional int64 api_mcycles = 19; + optional string host = 20; + optional double cost = 21; + + optional string task_queue_name = 22; + optional string task_name = 23; + + optional bool was_loading_request = 24; + optional int64 pending_time = 25; + optional int32 replica_index = 26 [default = -1]; + optional bool finished = 27 [default = true]; + optional bytes clone_key = 28; + + repeated LogLine line = 29; + + optional bool lines_incomplete = 36; + optional bytes app_engine_release = 38; + + optional int32 exit_reason = 30; + optional bool was_throttled_for_time = 31; + optional bool was_throttled_for_requests = 32; + optional int64 throttled_time = 33; + + optional bytes server_name = 34; +} + +message LogModuleVersion { + optional string module_id = 1 [default="default"]; + optional string version_id = 2; +} + +message LogReadRequest { + required string app_id = 1; + repeated string version_id = 2; + repeated LogModuleVersion module_version = 19; + + optional int64 start_time = 3; + optional int64 end_time = 4; + optional LogOffset offset = 5; + repeated bytes request_id = 6; + + optional int32 minimum_log_level = 7; + optional bool include_incomplete = 8; + optional int64 count = 9; + + optional string combined_log_regex = 14; + optional string host_regex = 15; + optional int32 replica_index = 16; + + optional bool include_app_logs = 10; + optional int32 app_logs_per_request = 17; + optional bool include_host = 11; + optional bool include_all = 12; + optional bool cache_iterator = 13; + optional int32 num_shards = 18; +} + +message LogReadResponse { + repeated RequestLog log = 1; + optional LogOffset offset = 2; + optional int64 last_end_time = 3; +} + +message LogUsageRecord { + optional string version_id = 1; + optional int32 start_time = 2; + optional int32 end_time = 3; + optional int64 count = 4; + optional int64 total_size = 5; + optional int32 records = 6; +} + +message LogUsageRequest { + required string app_id = 1; + repeated string version_id = 2; + optional int32 start_time = 3; + optional int32 end_time = 4; + optional uint32 resolution_hours = 5 [default = 1]; + optional bool combine_versions = 6; + optional int32 usage_version = 7; + optional bool versions_only = 8; +} + +message LogUsageResponse { + repeated LogUsageRecord usage = 1; + optional LogUsageRecord summary = 2; +} diff --git a/vendor/google.golang.org/appengine/internal/metadata.go b/vendor/google.golang.org/appengine/internal/metadata.go new file mode 100644 index 0000000000..9cc1f71d10 --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/metadata.go @@ -0,0 +1,61 @@ +// Copyright 2014 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package internal + +// This file has code for accessing metadata. +// +// References: +// https://cloud.google.com/compute/docs/metadata + +import ( + "fmt" + "io/ioutil" + "log" + "net/http" + "net/url" +) + +const ( + metadataHost = "metadata" + metadataPath = "/computeMetadata/v1/" +) + +var ( + metadataRequestHeaders = http.Header{ + "Metadata-Flavor": []string{"Google"}, + } +) + +// TODO(dsymonds): Do we need to support default values, like Python? +func mustGetMetadata(key string) []byte { + b, err := getMetadata(key) + if err != nil { + log.Fatalf("Metadata fetch failed: %v", err) + } + return b +} + +func getMetadata(key string) ([]byte, error) { + // TODO(dsymonds): May need to use url.Parse to support keys with query args. + req := &http.Request{ + Method: "GET", + URL: &url.URL{ + Scheme: "http", + Host: metadataHost, + Path: metadataPath + key, + }, + Header: metadataRequestHeaders, + Host: metadataHost, + } + resp, err := http.DefaultClient.Do(req) + if err != nil { + return nil, err + } + defer resp.Body.Close() + if resp.StatusCode != 200 { + return nil, fmt.Errorf("metadata server returned HTTP %d", resp.StatusCode) + } + return ioutil.ReadAll(resp.Body) +} diff --git a/vendor/google.golang.org/appengine/internal/modules/modules_service.pb.go b/vendor/google.golang.org/appengine/internal/modules/modules_service.pb.go new file mode 100644 index 0000000000..a0145ed317 --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/modules/modules_service.pb.go @@ -0,0 +1,375 @@ +// Code generated by protoc-gen-go. +// source: google.golang.org/appengine/internal/modules/modules_service.proto +// DO NOT EDIT! + +/* +Package modules is a generated protocol buffer package. + +It is generated from these files: + google.golang.org/appengine/internal/modules/modules_service.proto + +It has these top-level messages: + ModulesServiceError + GetModulesRequest + GetModulesResponse + GetVersionsRequest + GetVersionsResponse + GetDefaultVersionRequest + GetDefaultVersionResponse + GetNumInstancesRequest + GetNumInstancesResponse + SetNumInstancesRequest + SetNumInstancesResponse + StartModuleRequest + StartModuleResponse + StopModuleRequest + StopModuleResponse + GetHostnameRequest + GetHostnameResponse +*/ +package modules + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +type ModulesServiceError_ErrorCode int32 + +const ( + ModulesServiceError_OK ModulesServiceError_ErrorCode = 0 + ModulesServiceError_INVALID_MODULE ModulesServiceError_ErrorCode = 1 + ModulesServiceError_INVALID_VERSION ModulesServiceError_ErrorCode = 2 + ModulesServiceError_INVALID_INSTANCES ModulesServiceError_ErrorCode = 3 + ModulesServiceError_TRANSIENT_ERROR ModulesServiceError_ErrorCode = 4 + ModulesServiceError_UNEXPECTED_STATE ModulesServiceError_ErrorCode = 5 +) + +var ModulesServiceError_ErrorCode_name = map[int32]string{ + 0: "OK", + 1: "INVALID_MODULE", + 2: "INVALID_VERSION", + 3: "INVALID_INSTANCES", + 4: "TRANSIENT_ERROR", + 5: "UNEXPECTED_STATE", +} +var ModulesServiceError_ErrorCode_value = map[string]int32{ + "OK": 0, + "INVALID_MODULE": 1, + "INVALID_VERSION": 2, + "INVALID_INSTANCES": 3, + "TRANSIENT_ERROR": 4, + "UNEXPECTED_STATE": 5, +} + +func (x ModulesServiceError_ErrorCode) Enum() *ModulesServiceError_ErrorCode { + p := new(ModulesServiceError_ErrorCode) + *p = x + return p +} +func (x ModulesServiceError_ErrorCode) String() string { + return proto.EnumName(ModulesServiceError_ErrorCode_name, int32(x)) +} +func (x *ModulesServiceError_ErrorCode) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(ModulesServiceError_ErrorCode_value, data, "ModulesServiceError_ErrorCode") + if err != nil { + return err + } + *x = ModulesServiceError_ErrorCode(value) + return nil +} + +type ModulesServiceError struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *ModulesServiceError) Reset() { *m = ModulesServiceError{} } +func (m *ModulesServiceError) String() string { return proto.CompactTextString(m) } +func (*ModulesServiceError) ProtoMessage() {} + +type GetModulesRequest struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetModulesRequest) Reset() { *m = GetModulesRequest{} } +func (m *GetModulesRequest) String() string { return proto.CompactTextString(m) } +func (*GetModulesRequest) ProtoMessage() {} + +type GetModulesResponse struct { + Module []string `protobuf:"bytes,1,rep,name=module" json:"module,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetModulesResponse) Reset() { *m = GetModulesResponse{} } +func (m *GetModulesResponse) String() string { return proto.CompactTextString(m) } +func (*GetModulesResponse) ProtoMessage() {} + +func (m *GetModulesResponse) GetModule() []string { + if m != nil { + return m.Module + } + return nil +} + +type GetVersionsRequest struct { + Module *string `protobuf:"bytes,1,opt,name=module" json:"module,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetVersionsRequest) Reset() { *m = GetVersionsRequest{} } +func (m *GetVersionsRequest) String() string { return proto.CompactTextString(m) } +func (*GetVersionsRequest) ProtoMessage() {} + +func (m *GetVersionsRequest) GetModule() string { + if m != nil && m.Module != nil { + return *m.Module + } + return "" +} + +type GetVersionsResponse struct { + Version []string `protobuf:"bytes,1,rep,name=version" json:"version,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetVersionsResponse) Reset() { *m = GetVersionsResponse{} } +func (m *GetVersionsResponse) String() string { return proto.CompactTextString(m) } +func (*GetVersionsResponse) ProtoMessage() {} + +func (m *GetVersionsResponse) GetVersion() []string { + if m != nil { + return m.Version + } + return nil +} + +type GetDefaultVersionRequest struct { + Module *string `protobuf:"bytes,1,opt,name=module" json:"module,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetDefaultVersionRequest) Reset() { *m = GetDefaultVersionRequest{} } +func (m *GetDefaultVersionRequest) String() string { return proto.CompactTextString(m) } +func (*GetDefaultVersionRequest) ProtoMessage() {} + +func (m *GetDefaultVersionRequest) GetModule() string { + if m != nil && m.Module != nil { + return *m.Module + } + return "" +} + +type GetDefaultVersionResponse struct { + Version *string `protobuf:"bytes,1,req,name=version" json:"version,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetDefaultVersionResponse) Reset() { *m = GetDefaultVersionResponse{} } +func (m *GetDefaultVersionResponse) String() string { return proto.CompactTextString(m) } +func (*GetDefaultVersionResponse) ProtoMessage() {} + +func (m *GetDefaultVersionResponse) GetVersion() string { + if m != nil && m.Version != nil { + return *m.Version + } + return "" +} + +type GetNumInstancesRequest struct { + Module *string `protobuf:"bytes,1,opt,name=module" json:"module,omitempty"` + Version *string `protobuf:"bytes,2,opt,name=version" json:"version,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetNumInstancesRequest) Reset() { *m = GetNumInstancesRequest{} } +func (m *GetNumInstancesRequest) String() string { return proto.CompactTextString(m) } +func (*GetNumInstancesRequest) ProtoMessage() {} + +func (m *GetNumInstancesRequest) GetModule() string { + if m != nil && m.Module != nil { + return *m.Module + } + return "" +} + +func (m *GetNumInstancesRequest) GetVersion() string { + if m != nil && m.Version != nil { + return *m.Version + } + return "" +} + +type GetNumInstancesResponse struct { + Instances *int64 `protobuf:"varint,1,req,name=instances" json:"instances,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetNumInstancesResponse) Reset() { *m = GetNumInstancesResponse{} } +func (m *GetNumInstancesResponse) String() string { return proto.CompactTextString(m) } +func (*GetNumInstancesResponse) ProtoMessage() {} + +func (m *GetNumInstancesResponse) GetInstances() int64 { + if m != nil && m.Instances != nil { + return *m.Instances + } + return 0 +} + +type SetNumInstancesRequest struct { + Module *string `protobuf:"bytes,1,opt,name=module" json:"module,omitempty"` + Version *string `protobuf:"bytes,2,opt,name=version" json:"version,omitempty"` + Instances *int64 `protobuf:"varint,3,req,name=instances" json:"instances,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *SetNumInstancesRequest) Reset() { *m = SetNumInstancesRequest{} } +func (m *SetNumInstancesRequest) String() string { return proto.CompactTextString(m) } +func (*SetNumInstancesRequest) ProtoMessage() {} + +func (m *SetNumInstancesRequest) GetModule() string { + if m != nil && m.Module != nil { + return *m.Module + } + return "" +} + +func (m *SetNumInstancesRequest) GetVersion() string { + if m != nil && m.Version != nil { + return *m.Version + } + return "" +} + +func (m *SetNumInstancesRequest) GetInstances() int64 { + if m != nil && m.Instances != nil { + return *m.Instances + } + return 0 +} + +type SetNumInstancesResponse struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *SetNumInstancesResponse) Reset() { *m = SetNumInstancesResponse{} } +func (m *SetNumInstancesResponse) String() string { return proto.CompactTextString(m) } +func (*SetNumInstancesResponse) ProtoMessage() {} + +type StartModuleRequest struct { + Module *string `protobuf:"bytes,1,req,name=module" json:"module,omitempty"` + Version *string `protobuf:"bytes,2,req,name=version" json:"version,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *StartModuleRequest) Reset() { *m = StartModuleRequest{} } +func (m *StartModuleRequest) String() string { return proto.CompactTextString(m) } +func (*StartModuleRequest) ProtoMessage() {} + +func (m *StartModuleRequest) GetModule() string { + if m != nil && m.Module != nil { + return *m.Module + } + return "" +} + +func (m *StartModuleRequest) GetVersion() string { + if m != nil && m.Version != nil { + return *m.Version + } + return "" +} + +type StartModuleResponse struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *StartModuleResponse) Reset() { *m = StartModuleResponse{} } +func (m *StartModuleResponse) String() string { return proto.CompactTextString(m) } +func (*StartModuleResponse) ProtoMessage() {} + +type StopModuleRequest struct { + Module *string `protobuf:"bytes,1,opt,name=module" json:"module,omitempty"` + Version *string `protobuf:"bytes,2,opt,name=version" json:"version,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *StopModuleRequest) Reset() { *m = StopModuleRequest{} } +func (m *StopModuleRequest) String() string { return proto.CompactTextString(m) } +func (*StopModuleRequest) ProtoMessage() {} + +func (m *StopModuleRequest) GetModule() string { + if m != nil && m.Module != nil { + return *m.Module + } + return "" +} + +func (m *StopModuleRequest) GetVersion() string { + if m != nil && m.Version != nil { + return *m.Version + } + return "" +} + +type StopModuleResponse struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *StopModuleResponse) Reset() { *m = StopModuleResponse{} } +func (m *StopModuleResponse) String() string { return proto.CompactTextString(m) } +func (*StopModuleResponse) ProtoMessage() {} + +type GetHostnameRequest struct { + Module *string `protobuf:"bytes,1,opt,name=module" json:"module,omitempty"` + Version *string `protobuf:"bytes,2,opt,name=version" json:"version,omitempty"` + Instance *string `protobuf:"bytes,3,opt,name=instance" json:"instance,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetHostnameRequest) Reset() { *m = GetHostnameRequest{} } +func (m *GetHostnameRequest) String() string { return proto.CompactTextString(m) } +func (*GetHostnameRequest) ProtoMessage() {} + +func (m *GetHostnameRequest) GetModule() string { + if m != nil && m.Module != nil { + return *m.Module + } + return "" +} + +func (m *GetHostnameRequest) GetVersion() string { + if m != nil && m.Version != nil { + return *m.Version + } + return "" +} + +func (m *GetHostnameRequest) GetInstance() string { + if m != nil && m.Instance != nil { + return *m.Instance + } + return "" +} + +type GetHostnameResponse struct { + Hostname *string `protobuf:"bytes,1,req,name=hostname" json:"hostname,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetHostnameResponse) Reset() { *m = GetHostnameResponse{} } +func (m *GetHostnameResponse) String() string { return proto.CompactTextString(m) } +func (*GetHostnameResponse) ProtoMessage() {} + +func (m *GetHostnameResponse) GetHostname() string { + if m != nil && m.Hostname != nil { + return *m.Hostname + } + return "" +} + +func init() { +} diff --git a/vendor/google.golang.org/appengine/internal/modules/modules_service.proto b/vendor/google.golang.org/appengine/internal/modules/modules_service.proto new file mode 100644 index 0000000000..d29f0065a2 --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/modules/modules_service.proto @@ -0,0 +1,80 @@ +syntax = "proto2"; +option go_package = "modules"; + +package appengine; + +message ModulesServiceError { + enum ErrorCode { + OK = 0; + INVALID_MODULE = 1; + INVALID_VERSION = 2; + INVALID_INSTANCES = 3; + TRANSIENT_ERROR = 4; + UNEXPECTED_STATE = 5; + } +} + +message GetModulesRequest { +} + +message GetModulesResponse { + repeated string module = 1; +} + +message GetVersionsRequest { + optional string module = 1; +} + +message GetVersionsResponse { + repeated string version = 1; +} + +message GetDefaultVersionRequest { + optional string module = 1; +} + +message GetDefaultVersionResponse { + required string version = 1; +} + +message GetNumInstancesRequest { + optional string module = 1; + optional string version = 2; +} + +message GetNumInstancesResponse { + required int64 instances = 1; +} + +message SetNumInstancesRequest { + optional string module = 1; + optional string version = 2; + required int64 instances = 3; +} + +message SetNumInstancesResponse {} + +message StartModuleRequest { + required string module = 1; + required string version = 2; +} + +message StartModuleResponse {} + +message StopModuleRequest { + optional string module = 1; + optional string version = 2; +} + +message StopModuleResponse {} + +message GetHostnameRequest { + optional string module = 1; + optional string version = 2; + optional string instance = 3; +} + +message GetHostnameResponse { + required string hostname = 1; +} + diff --git a/vendor/google.golang.org/appengine/internal/net.go b/vendor/google.golang.org/appengine/internal/net.go new file mode 100644 index 0000000000..3b94cf0c6a --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/net.go @@ -0,0 +1,56 @@ +// Copyright 2014 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package internal + +// This file implements a network dialer that limits the number of concurrent connections. +// It is only used for API calls. + +import ( + "log" + "net" + "runtime" + "sync" + "time" +) + +var limitSem = make(chan int, 100) // TODO(dsymonds): Use environment variable. + +func limitRelease() { + // non-blocking + select { + case <-limitSem: + default: + // This should not normally happen. + log.Print("appengine: unbalanced limitSem release!") + } +} + +func limitDial(network, addr string) (net.Conn, error) { + limitSem <- 1 + + // Dial with a timeout in case the API host is MIA. + // The connection should normally be very fast. + conn, err := net.DialTimeout(network, addr, 500*time.Millisecond) + if err != nil { + limitRelease() + return nil, err + } + lc := &limitConn{Conn: conn} + runtime.SetFinalizer(lc, (*limitConn).Close) // shouldn't usually be required + return lc, nil +} + +type limitConn struct { + close sync.Once + net.Conn +} + +func (lc *limitConn) Close() error { + defer lc.close.Do(func() { + limitRelease() + runtime.SetFinalizer(lc, nil) + }) + return lc.Conn.Close() +} diff --git a/vendor/google.golang.org/appengine/internal/regen.sh b/vendor/google.golang.org/appengine/internal/regen.sh new file mode 100644 index 0000000000..2fdb546a63 --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/regen.sh @@ -0,0 +1,40 @@ +#!/bin/bash -e +# +# This script rebuilds the generated code for the protocol buffers. +# To run this you will need protoc and goprotobuf installed; +# see https://github.com/golang/protobuf for instructions. + +PKG=google.golang.org/appengine + +function die() { + echo 1>&2 $* + exit 1 +} + +# Sanity check that the right tools are accessible. +for tool in go protoc protoc-gen-go; do + q=$(which $tool) || die "didn't find $tool" + echo 1>&2 "$tool: $q" +done + +echo -n 1>&2 "finding package dir... " +pkgdir=$(go list -f '{{.Dir}}' $PKG) +echo 1>&2 $pkgdir +base=$(echo $pkgdir | sed "s,/$PKG\$,,") +echo 1>&2 "base: $base" +cd $base + +# Run protoc once per package. +for dir in $(find $PKG/internal -name '*.proto' | xargs dirname | sort | uniq); do + echo 1>&2 "* $dir" + protoc --go_out=. $dir/*.proto +done + +for f in $(find $PKG/internal -name '*.pb.go'); do + # Remove proto.RegisterEnum calls. + # These cause duplicate registration panics when these packages + # are used on classic App Engine. proto.RegisterEnum only affects + # parsing the text format; we don't care about that. + # https://code.google.com/p/googleappengine/issues/detail?id=11670#c17 + sed -i '/proto.RegisterEnum/d' $f +done diff --git a/vendor/google.golang.org/appengine/internal/remote_api/remote_api.pb.go b/vendor/google.golang.org/appengine/internal/remote_api/remote_api.pb.go new file mode 100644 index 0000000000..526bd39e6d --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/remote_api/remote_api.pb.go @@ -0,0 +1,231 @@ +// Code generated by protoc-gen-go. +// source: google.golang.org/appengine/internal/remote_api/remote_api.proto +// DO NOT EDIT! + +/* +Package remote_api is a generated protocol buffer package. + +It is generated from these files: + google.golang.org/appengine/internal/remote_api/remote_api.proto + +It has these top-level messages: + Request + ApplicationError + RpcError + Response +*/ +package remote_api + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +type RpcError_ErrorCode int32 + +const ( + RpcError_UNKNOWN RpcError_ErrorCode = 0 + RpcError_CALL_NOT_FOUND RpcError_ErrorCode = 1 + RpcError_PARSE_ERROR RpcError_ErrorCode = 2 + RpcError_SECURITY_VIOLATION RpcError_ErrorCode = 3 + RpcError_OVER_QUOTA RpcError_ErrorCode = 4 + RpcError_REQUEST_TOO_LARGE RpcError_ErrorCode = 5 + RpcError_CAPABILITY_DISABLED RpcError_ErrorCode = 6 + RpcError_FEATURE_DISABLED RpcError_ErrorCode = 7 + RpcError_BAD_REQUEST RpcError_ErrorCode = 8 + RpcError_RESPONSE_TOO_LARGE RpcError_ErrorCode = 9 + RpcError_CANCELLED RpcError_ErrorCode = 10 + RpcError_REPLAY_ERROR RpcError_ErrorCode = 11 + RpcError_DEADLINE_EXCEEDED RpcError_ErrorCode = 12 +) + +var RpcError_ErrorCode_name = map[int32]string{ + 0: "UNKNOWN", + 1: "CALL_NOT_FOUND", + 2: "PARSE_ERROR", + 3: "SECURITY_VIOLATION", + 4: "OVER_QUOTA", + 5: "REQUEST_TOO_LARGE", + 6: "CAPABILITY_DISABLED", + 7: "FEATURE_DISABLED", + 8: "BAD_REQUEST", + 9: "RESPONSE_TOO_LARGE", + 10: "CANCELLED", + 11: "REPLAY_ERROR", + 12: "DEADLINE_EXCEEDED", +} +var RpcError_ErrorCode_value = map[string]int32{ + "UNKNOWN": 0, + "CALL_NOT_FOUND": 1, + "PARSE_ERROR": 2, + "SECURITY_VIOLATION": 3, + "OVER_QUOTA": 4, + "REQUEST_TOO_LARGE": 5, + "CAPABILITY_DISABLED": 6, + "FEATURE_DISABLED": 7, + "BAD_REQUEST": 8, + "RESPONSE_TOO_LARGE": 9, + "CANCELLED": 10, + "REPLAY_ERROR": 11, + "DEADLINE_EXCEEDED": 12, +} + +func (x RpcError_ErrorCode) Enum() *RpcError_ErrorCode { + p := new(RpcError_ErrorCode) + *p = x + return p +} +func (x RpcError_ErrorCode) String() string { + return proto.EnumName(RpcError_ErrorCode_name, int32(x)) +} +func (x *RpcError_ErrorCode) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(RpcError_ErrorCode_value, data, "RpcError_ErrorCode") + if err != nil { + return err + } + *x = RpcError_ErrorCode(value) + return nil +} + +type Request struct { + ServiceName *string `protobuf:"bytes,2,req,name=service_name" json:"service_name,omitempty"` + Method *string `protobuf:"bytes,3,req,name=method" json:"method,omitempty"` + Request []byte `protobuf:"bytes,4,req,name=request" json:"request,omitempty"` + RequestId *string `protobuf:"bytes,5,opt,name=request_id" json:"request_id,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Request) Reset() { *m = Request{} } +func (m *Request) String() string { return proto.CompactTextString(m) } +func (*Request) ProtoMessage() {} + +func (m *Request) GetServiceName() string { + if m != nil && m.ServiceName != nil { + return *m.ServiceName + } + return "" +} + +func (m *Request) GetMethod() string { + if m != nil && m.Method != nil { + return *m.Method + } + return "" +} + +func (m *Request) GetRequest() []byte { + if m != nil { + return m.Request + } + return nil +} + +func (m *Request) GetRequestId() string { + if m != nil && m.RequestId != nil { + return *m.RequestId + } + return "" +} + +type ApplicationError struct { + Code *int32 `protobuf:"varint,1,req,name=code" json:"code,omitempty"` + Detail *string `protobuf:"bytes,2,req,name=detail" json:"detail,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *ApplicationError) Reset() { *m = ApplicationError{} } +func (m *ApplicationError) String() string { return proto.CompactTextString(m) } +func (*ApplicationError) ProtoMessage() {} + +func (m *ApplicationError) GetCode() int32 { + if m != nil && m.Code != nil { + return *m.Code + } + return 0 +} + +func (m *ApplicationError) GetDetail() string { + if m != nil && m.Detail != nil { + return *m.Detail + } + return "" +} + +type RpcError struct { + Code *int32 `protobuf:"varint,1,req,name=code" json:"code,omitempty"` + Detail *string `protobuf:"bytes,2,opt,name=detail" json:"detail,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *RpcError) Reset() { *m = RpcError{} } +func (m *RpcError) String() string { return proto.CompactTextString(m) } +func (*RpcError) ProtoMessage() {} + +func (m *RpcError) GetCode() int32 { + if m != nil && m.Code != nil { + return *m.Code + } + return 0 +} + +func (m *RpcError) GetDetail() string { + if m != nil && m.Detail != nil { + return *m.Detail + } + return "" +} + +type Response struct { + Response []byte `protobuf:"bytes,1,opt,name=response" json:"response,omitempty"` + Exception []byte `protobuf:"bytes,2,opt,name=exception" json:"exception,omitempty"` + ApplicationError *ApplicationError `protobuf:"bytes,3,opt,name=application_error" json:"application_error,omitempty"` + JavaException []byte `protobuf:"bytes,4,opt,name=java_exception" json:"java_exception,omitempty"` + RpcError *RpcError `protobuf:"bytes,5,opt,name=rpc_error" json:"rpc_error,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Response) Reset() { *m = Response{} } +func (m *Response) String() string { return proto.CompactTextString(m) } +func (*Response) ProtoMessage() {} + +func (m *Response) GetResponse() []byte { + if m != nil { + return m.Response + } + return nil +} + +func (m *Response) GetException() []byte { + if m != nil { + return m.Exception + } + return nil +} + +func (m *Response) GetApplicationError() *ApplicationError { + if m != nil { + return m.ApplicationError + } + return nil +} + +func (m *Response) GetJavaException() []byte { + if m != nil { + return m.JavaException + } + return nil +} + +func (m *Response) GetRpcError() *RpcError { + if m != nil { + return m.RpcError + } + return nil +} + +func init() { +} diff --git a/vendor/google.golang.org/appengine/internal/remote_api/remote_api.proto b/vendor/google.golang.org/appengine/internal/remote_api/remote_api.proto new file mode 100644 index 0000000000..f21763a4e2 --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/remote_api/remote_api.proto @@ -0,0 +1,44 @@ +syntax = "proto2"; +option go_package = "remote_api"; + +package remote_api; + +message Request { + required string service_name = 2; + required string method = 3; + required bytes request = 4; + optional string request_id = 5; +} + +message ApplicationError { + required int32 code = 1; + required string detail = 2; +} + +message RpcError { + enum ErrorCode { + UNKNOWN = 0; + CALL_NOT_FOUND = 1; + PARSE_ERROR = 2; + SECURITY_VIOLATION = 3; + OVER_QUOTA = 4; + REQUEST_TOO_LARGE = 5; + CAPABILITY_DISABLED = 6; + FEATURE_DISABLED = 7; + BAD_REQUEST = 8; + RESPONSE_TOO_LARGE = 9; + CANCELLED = 10; + REPLAY_ERROR = 11; + DEADLINE_EXCEEDED = 12; + } + required int32 code = 1; + optional string detail = 2; +} + +message Response { + optional bytes response = 1; + optional bytes exception = 2; + optional ApplicationError application_error = 3; + optional bytes java_exception = 4; + optional RpcError rpc_error = 5; +} diff --git a/vendor/google.golang.org/appengine/internal/transaction.go b/vendor/google.golang.org/appengine/internal/transaction.go new file mode 100644 index 0000000000..28a6d18120 --- /dev/null +++ b/vendor/google.golang.org/appengine/internal/transaction.go @@ -0,0 +1,107 @@ +// Copyright 2014 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package internal + +// This file implements hooks for applying datastore transactions. + +import ( + "errors" + "reflect" + + "github.com/golang/protobuf/proto" + netcontext "golang.org/x/net/context" + + basepb "google.golang.org/appengine/internal/base" + pb "google.golang.org/appengine/internal/datastore" +) + +var transactionSetters = make(map[reflect.Type]reflect.Value) + +// RegisterTransactionSetter registers a function that sets transaction information +// in a protocol buffer message. f should be a function with two arguments, +// the first being a protocol buffer type, and the second being *datastore.Transaction. +func RegisterTransactionSetter(f interface{}) { + v := reflect.ValueOf(f) + transactionSetters[v.Type().In(0)] = v +} + +// applyTransaction applies the transaction t to message pb +// by using the relevant setter passed to RegisterTransactionSetter. +func applyTransaction(pb proto.Message, t *pb.Transaction) { + v := reflect.ValueOf(pb) + if f, ok := transactionSetters[v.Type()]; ok { + f.Call([]reflect.Value{v, reflect.ValueOf(t)}) + } +} + +var transactionKey = "used for *Transaction" + +func transactionFromContext(ctx netcontext.Context) *transaction { + t, _ := ctx.Value(&transactionKey).(*transaction) + return t +} + +func withTransaction(ctx netcontext.Context, t *transaction) netcontext.Context { + return netcontext.WithValue(ctx, &transactionKey, t) +} + +type transaction struct { + transaction pb.Transaction + finished bool +} + +var ErrConcurrentTransaction = errors.New("internal: concurrent transaction") + +func RunTransactionOnce(c netcontext.Context, f func(netcontext.Context) error, xg bool) error { + if transactionFromContext(c) != nil { + return errors.New("nested transactions are not supported") + } + + // Begin the transaction. + t := &transaction{} + req := &pb.BeginTransactionRequest{ + App: proto.String(FullyQualifiedAppID(c)), + } + if xg { + req.AllowMultipleEg = proto.Bool(true) + } + if err := Call(c, "datastore_v3", "BeginTransaction", req, &t.transaction); err != nil { + return err + } + + // Call f, rolling back the transaction if f returns a non-nil error, or panics. + // The panic is not recovered. + defer func() { + if t.finished { + return + } + t.finished = true + // Ignore the error return value, since we are already returning a non-nil + // error (or we're panicking). + Call(c, "datastore_v3", "Rollback", &t.transaction, &basepb.VoidProto{}) + }() + if err := f(withTransaction(c, t)); err != nil { + return err + } + t.finished = true + + // Commit the transaction. + res := &pb.CommitResponse{} + err := Call(c, "datastore_v3", "Commit", &t.transaction, res) + if ae, ok := err.(*APIError); ok { + /* TODO: restore this conditional + if appengine.IsDevAppServer() { + */ + // The Python Dev AppServer raises an ApplicationError with error code 2 (which is + // Error.CONCURRENT_TRANSACTION) and message "Concurrency exception.". + if ae.Code == int32(pb.Error_BAD_REQUEST) && ae.Detail == "ApplicationError: 2 Concurrency exception." { + return ErrConcurrentTransaction + } + if ae.Code == int32(pb.Error_CONCURRENT_TRANSACTION) { + return ErrConcurrentTransaction + } + } + return err +} diff --git a/vendor/google.golang.org/appengine/namespace.go b/vendor/google.golang.org/appengine/namespace.go new file mode 100644 index 0000000000..21860ca082 --- /dev/null +++ b/vendor/google.golang.org/appengine/namespace.go @@ -0,0 +1,25 @@ +// Copyright 2012 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package appengine + +import ( + "fmt" + "regexp" + + "golang.org/x/net/context" + + "google.golang.org/appengine/internal" +) + +// Namespace returns a replacement context that operates within the given namespace. +func Namespace(c context.Context, namespace string) (context.Context, error) { + if !validNamespace.MatchString(namespace) { + return nil, fmt.Errorf("appengine: namespace %q does not match /%s/", namespace, validNamespace) + } + return internal.NamespacedContext(c, namespace), nil +} + +// validNamespace matches valid namespace names. +var validNamespace = regexp.MustCompile(`^[0-9A-Za-z._-]{0,100}$`) diff --git a/vendor/google.golang.org/appengine/timeout.go b/vendor/google.golang.org/appengine/timeout.go new file mode 100644 index 0000000000..05642a992a --- /dev/null +++ b/vendor/google.golang.org/appengine/timeout.go @@ -0,0 +1,20 @@ +// Copyright 2013 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package appengine + +import "golang.org/x/net/context" + +// IsTimeoutError reports whether err is a timeout error. +func IsTimeoutError(err error) bool { + if err == context.DeadlineExceeded { + return true + } + if t, ok := err.(interface { + IsTimeout() bool + }); ok { + return t.IsTimeout() + } + return false +}