blob: 6e477ae70458d7b4eff5c88e3f44c1134159fb5b [file] [log] [blame]
Jon Perritt33ed7412014-10-17 19:35:32 -05001// +build acceptance rackspace objectstorage v1
2
Jon Perritt8abd2c22014-10-16 20:28:51 -05003package v1
Jon Perritt33ed7412014-10-17 19:35:32 -05004
5import (
6 "bytes"
7 "testing"
8
9 raxCDNContainers "github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers"
10 raxCDNObjects "github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdnobjects"
11 raxContainers "github.com/rackspace/gophercloud/rackspace/objectstorage/v1/containers"
12 raxObjects "github.com/rackspace/gophercloud/rackspace/objectstorage/v1/objects"
13 th "github.com/rackspace/gophercloud/testhelper"
14)
15
16func TestCDNObjects(t *testing.T) {
17 raxClient, err := createClient(t, false)
18 th.AssertNoErr(t, err)
19
Ash Wilsonfef72b82014-10-24 15:46:45 -040020 createContResult := raxContainers.Create(raxClient, "gophercloud-test", nil)
21 th.AssertNoErr(t, createContResult.Err)
22 t.Logf("Headers from Create Container request: %+v\n", createContResult.Header)
Jon Perritt33ed7412014-10-17 19:35:32 -050023 defer func() {
Ash Wilsonfef72b82014-10-24 15:46:45 -040024 deleteResult := raxContainers.Delete(raxClient, "gophercloud-test")
25 th.AssertNoErr(t, deleteResult.Err)
Jon Perritt33ed7412014-10-17 19:35:32 -050026 }()
27
Jon Perritt10a7ec12014-10-27 11:29:33 -050028 header, err := raxObjects.Create(raxClient, "gophercloud-test", "test-object", bytes.NewBufferString("gophercloud cdn test"), nil).ExtractHeader()
29 th.AssertNoErr(t, err)
30 t.Logf("Headers from Create Object request: %+v\n", header)
Jon Perritt33ed7412014-10-17 19:35:32 -050031 defer func() {
Ash Wilsonfef72b82014-10-24 15:46:45 -040032 deleteResult := raxObjects.Delete(raxClient, "gophercloud-test", "test-object", nil)
33 th.AssertNoErr(t, deleteResult.Err)
Jon Perritt33ed7412014-10-17 19:35:32 -050034 }()
35
36 raxCDNClient, err := createClient(t, true)
37 th.AssertNoErr(t, err)
38
Ash Wilsonfef72b82014-10-24 15:46:45 -040039 enableResult := raxCDNContainers.Enable(raxCDNClient, "gophercloud-test", raxCDNContainers.EnableOpts{CDNEnabled: true, TTL: 900})
40 th.AssertNoErr(t, enableResult.Err)
41 t.Logf("Headers from Enable CDN Container request: %+v\n", enableResult.Header)
Jon Perritt33ed7412014-10-17 19:35:32 -050042
Ash Wilsonfef72b82014-10-24 15:46:45 -040043 deleteResult := raxCDNObjects.Delete(raxCDNClient, "gophercloud-test", "test-object", nil)
44 th.AssertNoErr(t, deleteResult.Err)
45 t.Logf("Headers from Delete CDN Object request: %+v\n", deleteResult.Err)
Jon Perritt33ed7412014-10-17 19:35:32 -050046}