From a57d9687340458cb4f7861faace44da0e5b0dda1 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Mon, 15 Oct 2018 14:02:29 -0300 Subject: [PATCH] 14086: Add tests to prove that keep-web can serve past collection versions. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- sdk/go/arvadostest/fixtures.go | 1 + services/api/test/fixtures/collections.yml | 4 +-- services/keep-web/handler_test.go | 34 ++++++++++++++++++++++ services/keep-web/server_test.go | 1 + 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/sdk/go/arvadostest/fixtures.go b/sdk/go/arvadostest/fixtures.go index eb79b5b7d2..114faf17b7 100644 --- a/sdk/go/arvadostest/fixtures.go +++ b/sdk/go/arvadostest/fixtures.go @@ -23,6 +23,7 @@ const ( NonexistentCollection = "zzzzz-4zz18-totallynotexist" HelloWorldCollection = "zzzzz-4zz18-4en62shvi99lxd4" FooBarDirCollection = "zzzzz-4zz18-foonbarfilesdir" + WazVersion1Collection = "zzzzz-4zz18-25k12570yk1ver1" UserAgreementPDH = "b519d9cb706a29fc7ea24dbea2f05851+93" FooPdh = "1f4b0bc7583c2a7f9102c395f4ffc5e3+45" HelloWorldPdh = "55713e6a34081eb03609e7ad5fcad129+62" diff --git a/services/api/test/fixtures/collections.yml b/services/api/test/fixtures/collections.yml index 62bb644c0d..29b486c452 100644 --- a/services/api/test/fixtures/collections.yml +++ b/services/api/test/fixtures/collections.yml @@ -99,14 +99,14 @@ w_a_z_file: w_a_z_file_version_1: uuid: zzzzz-4zz18-25k12570yk1ver1 current_version_uuid: zzzzz-4zz18-25k12570yk134b3 - portable_data_hash: 8706aadd12a0ebc07d74cae88762ba9e+56 + portable_data_hash: ba4ba4c7b99a58806b1ed70ea1263afe+45 owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz created_at: 2015-02-09T10:53:38Z modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr modified_by_user_uuid: zzzzz-tpzed-d9tiejq69daie8f modified_at: 2015-02-09T10:53:38Z updated_at: 2015-02-09T10:53:38Z - manifest_text: ". 4c6c2c0ac8aa0696edd7316a3be5ca3c+5 0:5:w\\040\\141\\040z\n" + manifest_text: ". 4d20280d5e516a0109768d49ab0f3318+3 0:3:waz\n" name: "waz file" version: 1 diff --git a/services/keep-web/handler_test.go b/services/keep-web/handler_test.go index 4ea697bbed..39fb87fbaa 100644 --- a/services/keep-web/handler_test.go +++ b/services/keep-web/handler_test.go @@ -350,6 +350,28 @@ func (s *IntegrationSuite) TestVhostRedirectQueryTokenSiteFS(c *check.C) { c.Check(resp.Header().Get("Content-Disposition"), check.Matches, "attachment(;.*)?") } +func (s *IntegrationSuite) TestPastCollectionVersionFileAccess(c *check.C) { + s.testServer.Config.AttachmentOnlyHost = "download.example.com" + resp := s.testVhostRedirectTokenToCookie(c, "GET", + "download.example.com/c="+arvadostest.WazVersion1Collection+"/waz", + "?api_token="+arvadostest.ActiveToken, + "", + "", + http.StatusOK, + "waz", + ) + c.Check(resp.Header().Get("Content-Disposition"), check.Matches, "attachment(;.*)?") + resp = s.testVhostRedirectTokenToCookie(c, "GET", + "download.example.com/by_id/"+arvadostest.WazVersion1Collection+"/waz", + "?api_token="+arvadostest.ActiveToken, + "", + "", + http.StatusOK, + "waz", + ) + c.Check(resp.Header().Get("Content-Disposition"), check.Matches, "attachment(;.*)?") +} + func (s *IntegrationSuite) TestVhostRedirectQueryTokenTrustAllContent(c *check.C) { s.testServer.Config.TrustAllContent = true s.testVhostRedirectTokenToCookie(c, "GET", @@ -656,6 +678,18 @@ func (s *IntegrationSuite) TestDirectoryListing(c *check.C) { header: authHeader, expect: nil, }, + { + uri: "download.example.com/c=" + arvadostest.WazVersion1Collection, + header: authHeader, + expect: []string{"waz"}, + cutDirs: 1, + }, + { + uri: "download.example.com/by_id/" + arvadostest.WazVersion1Collection, + header: authHeader, + expect: []string{"waz"}, + cutDirs: 2, + }, } { c.Logf("HTML: %q => %q", trial.uri, trial.expect) resp := httptest.NewRecorder() diff --git a/services/keep-web/server_test.go b/services/keep-web/server_test.go index 7e738cb9f3..2a8f8cd794 100644 --- a/services/keep-web/server_test.go +++ b/services/keep-web/server_test.go @@ -403,6 +403,7 @@ func (s *IntegrationSuite) SetUpSuite(c *check.C) { kc.PutB([]byte("Hello world\n")) kc.PutB([]byte("foo")) kc.PutB([]byte("foobar")) + kc.PutB([]byte("waz")) } func (s *IntegrationSuite) TearDownSuite(c *check.C) { -- 2.30.2