github.com/gophercloud/gophercloud@v1.11.0/openstack/clustering/v1/clusters/testing/fixtures_test.go (about)

     1  package testing
     2  
     3  import (
     4  	"fmt"
     5  	"net/http"
     6  	"testing"
     7  	"time"
     8  
     9  	"github.com/gophercloud/gophercloud/openstack/clustering/v1/clusters"
    10  	th "github.com/gophercloud/gophercloud/testhelper"
    11  	fake "github.com/gophercloud/gophercloud/testhelper/client"
    12  )
    13  
    14  const ClusterResponse = `
    15  {
    16    "cluster": {
    17      "config": {},
    18      "created_at": "2015-02-10T14:26:14Z",
    19      "data": {},
    20      "dependents": {},
    21      "desired_capacity": 3,
    22      "domain": null,
    23      "id": "7d85f602-a948-4a30-afd4-e84f47471c15",
    24      "init_at": "2015-02-10T15:26:14Z",
    25      "max_size": 20,
    26      "metadata": {},
    27      "min_size": 1,
    28      "name": "cluster1",
    29      "nodes": [
    30        "b07c57c8-7ab2-47bf-bdf8-e894c0c601b9",
    31        "ecc23d3e-bb68-48f8-8260-c9cf6bcb6e61",
    32        "da1e9c87-e584-4626-a120-022da5062dac"
    33      ],
    34      "policies": [],
    35      "profile_id": "edc63d0a-2ca4-48fa-9854-27926da76a4a",
    36      "profile_name": "mystack",
    37      "project": "6e18cc2bdbeb48a5b3cad2dc499f6804",
    38      "status": "ACTIVE",
    39      "status_reason": "Cluster scale-in succeeded",
    40      "timeout": 3600,
    41      "updated_at": "2015-02-10T16:26:14Z",
    42      "user": "5e5bf8027826429c96af157f68dc9072"
    43    }
    44  }`
    45  
    46  var ExpectedCluster = clusters.Cluster{
    47  	Config:          map[string]interface{}{},
    48  	CreatedAt:       time.Date(2015, 2, 10, 14, 26, 14, 0, time.UTC),
    49  	Data:            map[string]interface{}{},
    50  	Dependents:      map[string]interface{}{},
    51  	DesiredCapacity: 3,
    52  	Domain:          "",
    53  	ID:              "7d85f602-a948-4a30-afd4-e84f47471c15",
    54  	InitAt:          time.Date(2015, 2, 10, 15, 26, 14, 0, time.UTC),
    55  	MaxSize:         20,
    56  	Metadata:        map[string]interface{}{},
    57  	MinSize:         1,
    58  	Name:            "cluster1",
    59  	Nodes: []string{
    60  		"b07c57c8-7ab2-47bf-bdf8-e894c0c601b9",
    61  		"ecc23d3e-bb68-48f8-8260-c9cf6bcb6e61",
    62  		"da1e9c87-e584-4626-a120-022da5062dac",
    63  	},
    64  	Policies:     []string{},
    65  	ProfileID:    "edc63d0a-2ca4-48fa-9854-27926da76a4a",
    66  	ProfileName:  "mystack",
    67  	Project:      "6e18cc2bdbeb48a5b3cad2dc499f6804",
    68  	Status:       "ACTIVE",
    69  	StatusReason: "Cluster scale-in succeeded",
    70  	Timeout:      3600,
    71  	UpdatedAt:    time.Date(2015, 2, 10, 16, 26, 14, 0, time.UTC),
    72  	User:         "5e5bf8027826429c96af157f68dc9072",
    73  }
    74  
    75  const ClusterResponse_EmptyTime = `
    76  {
    77    "cluster": {
    78      "config": {},
    79      "created_at": null,
    80      "data": {},
    81      "dependents": {},
    82      "desired_capacity": 3,
    83      "domain": null,
    84      "id": "7d85f602-a948-4a30-afd4-e84f47471c15",
    85      "init_at": null,
    86      "max_size": 20,
    87      "metadata": {},
    88      "min_size": 1,
    89      "name": "cluster1",
    90      "nodes": [
    91        "b07c57c8-7ab2-47bf-bdf8-e894c0c601b9",
    92        "ecc23d3e-bb68-48f8-8260-c9cf6bcb6e61",
    93        "da1e9c87-e584-4626-a120-022da5062dac"
    94      ],
    95      "policies": [],
    96      "profile_id": "edc63d0a-2ca4-48fa-9854-27926da76a4a",
    97      "profile_name": "mystack",
    98      "project": "6e18cc2bdbeb48a5b3cad2dc499f6804",
    99      "status": "ACTIVE",
   100      "status_reason": "Cluster scale-in succeeded",
   101      "timeout": 3600,
   102      "updated_at": null,
   103      "user": "5e5bf8027826429c96af157f68dc9072"
   104    }
   105  }`
   106  
   107  var ExpectedCluster_EmptyTime = clusters.Cluster{
   108  	Config:          map[string]interface{}{},
   109  	Data:            map[string]interface{}{},
   110  	Dependents:      map[string]interface{}{},
   111  	DesiredCapacity: 3,
   112  	Domain:          "",
   113  	ID:              "7d85f602-a948-4a30-afd4-e84f47471c15",
   114  	MaxSize:         20,
   115  	Metadata:        map[string]interface{}{},
   116  	MinSize:         1,
   117  	Name:            "cluster1",
   118  	Nodes: []string{
   119  		"b07c57c8-7ab2-47bf-bdf8-e894c0c601b9",
   120  		"ecc23d3e-bb68-48f8-8260-c9cf6bcb6e61",
   121  		"da1e9c87-e584-4626-a120-022da5062dac",
   122  	},
   123  	Policies:     []string{},
   124  	ProfileID:    "edc63d0a-2ca4-48fa-9854-27926da76a4a",
   125  	ProfileName:  "mystack",
   126  	Project:      "6e18cc2bdbeb48a5b3cad2dc499f6804",
   127  	Status:       "ACTIVE",
   128  	StatusReason: "Cluster scale-in succeeded",
   129  	Timeout:      3600,
   130  	User:         "5e5bf8027826429c96af157f68dc9072",
   131  }
   132  
   133  const ClusterResponse_Metadata = `
   134  {
   135    "cluster": {
   136      "config": {},
   137      "created_at": "2015-02-10T14:26:14Z",
   138      "data": {},
   139      "dependents": {},
   140      "desired_capacity": 3,
   141      "domain": null,
   142      "id": "7d85f602-a948-4a30-afd4-e84f47471c15",
   143      "init_at": "2015-02-10T15:26:14Z",
   144      "max_size": 20,
   145      "metadata": {
   146        "test": {
   147          "nil_interface": null,
   148          "bool_value": false,
   149          "string_value": "test_string",
   150          "float_value": 123.3
   151        },
   152        "foo": "bar"
   153      },
   154      "min_size": 1,
   155      "name": "cluster1",
   156      "nodes": [
   157        "b07c57c8-7ab2-47bf-bdf8-e894c0c601b9",
   158        "ecc23d3e-bb68-48f8-8260-c9cf6bcb6e61",
   159        "da1e9c87-e584-4626-a120-022da5062dac"
   160      ],
   161      "policies": [],
   162      "profile_id": "edc63d0a-2ca4-48fa-9854-27926da76a4a",
   163      "profile_name": "mystack",
   164      "project": "6e18cc2bdbeb48a5b3cad2dc499f6804",
   165      "status": "ACTIVE",
   166      "status_reason": "Cluster scale-in succeeded",
   167      "timeout": 3600,
   168      "updated_at": "2015-02-10T16:26:14Z",
   169      "user": "5e5bf8027826429c96af157f68dc9072"
   170    }
   171  }`
   172  
   173  var ExpectedCluster_Metadata = clusters.Cluster{
   174  	Config:          map[string]interface{}{},
   175  	CreatedAt:       time.Date(2015, 2, 10, 14, 26, 14, 0, time.UTC),
   176  	Data:            map[string]interface{}{},
   177  	Dependents:      map[string]interface{}{},
   178  	DesiredCapacity: 3,
   179  	Domain:          "",
   180  	ID:              "7d85f602-a948-4a30-afd4-e84f47471c15",
   181  	InitAt:          time.Date(2015, 2, 10, 15, 26, 14, 0, time.UTC),
   182  	MaxSize:         20,
   183  	MinSize:         1,
   184  	Metadata: map[string]interface{}{
   185  		"foo": "bar",
   186  		"test": map[string]interface{}{
   187  			"nil_interface": interface{}(nil),
   188  			"float_value":   float64(123.3),
   189  			"string_value":  "test_string",
   190  			"bool_value":    false,
   191  		},
   192  	},
   193  	Name: "cluster1",
   194  	Nodes: []string{
   195  		"b07c57c8-7ab2-47bf-bdf8-e894c0c601b9",
   196  		"ecc23d3e-bb68-48f8-8260-c9cf6bcb6e61",
   197  		"da1e9c87-e584-4626-a120-022da5062dac",
   198  	},
   199  	Policies:     []string{},
   200  	ProfileID:    "edc63d0a-2ca4-48fa-9854-27926da76a4a",
   201  	ProfileName:  "mystack",
   202  	Project:      "6e18cc2bdbeb48a5b3cad2dc499f6804",
   203  	Status:       "ACTIVE",
   204  	StatusReason: "Cluster scale-in succeeded",
   205  	Timeout:      3600,
   206  	UpdatedAt:    time.Date(2015, 2, 10, 16, 26, 14, 0, time.UTC),
   207  	User:         "5e5bf8027826429c96af157f68dc9072",
   208  }
   209  
   210  const ListResponse = `
   211  {
   212    "clusters": [
   213      {
   214        "config": {},
   215        "created_at": "2015-02-10T14:26:14Z",
   216        "data": {},
   217        "dependents": {},
   218        "desired_capacity": 3,
   219        "domain": null,
   220        "id": "7d85f602-a948-4a30-afd4-e84f47471c15",
   221        "init_at": "2015-02-10T15:26:14Z",
   222        "max_size": 20,
   223        "min_size": 1,
   224        "metadata": {},
   225        "name": "cluster1",
   226        "nodes": [
   227          "b07c57c8-7ab2-47bf-bdf8-e894c0c601b9",
   228          "ecc23d3e-bb68-48f8-8260-c9cf6bcb6e61",
   229          "da1e9c87-e584-4626-a120-022da5062dac"
   230        ],
   231        "policies": [],
   232        "profile_id": "edc63d0a-2ca4-48fa-9854-27926da76a4a",
   233        "profile_name": "mystack",
   234        "project": "6e18cc2bdbeb48a5b3cad2dc499f6804",
   235        "status": "ACTIVE",
   236        "status_reason": "Cluster scale-in succeeded",
   237        "timeout": 3600,
   238        "updated_at": "2015-02-10T16:26:14Z",
   239        "user": "5e5bf8027826429c96af157f68dc9072"
   240      },
   241  		{
   242  			"config": {},
   243  			"created_at": null,
   244  			"data": {},
   245  			"dependents": {},
   246  			"desired_capacity": 3,
   247  			"domain": null,
   248  			"id": "7d85f602-a948-4a30-afd4-e84f47471c15",
   249  			"init_at": null,
   250  			"max_size": 20,
   251  			"metadata": {},
   252  			"min_size": 1,
   253  			"name": "cluster1",
   254  			"nodes": [
   255  				"b07c57c8-7ab2-47bf-bdf8-e894c0c601b9",
   256  				"ecc23d3e-bb68-48f8-8260-c9cf6bcb6e61",
   257  				"da1e9c87-e584-4626-a120-022da5062dac"
   258  			],
   259  			"policies": [],
   260  			"profile_id": "edc63d0a-2ca4-48fa-9854-27926da76a4a",
   261  			"profile_name": "mystack",
   262  			"project": "6e18cc2bdbeb48a5b3cad2dc499f6804",
   263  			"status": "ACTIVE",
   264  			"status_reason": "Cluster scale-in succeeded",
   265  			"timeout": 3600,
   266  			"updated_at": null,
   267  			"user": "5e5bf8027826429c96af157f68dc9072"
   268    	}
   269  	]
   270  }`
   271  
   272  var ExpectedClusters = []clusters.Cluster{ExpectedCluster, ExpectedCluster_EmptyTime}
   273  
   274  const UpdateResponse = `
   275  {
   276    "cluster": {
   277      "config": {},
   278      "created_at": "2015-02-10T14:26:14Z",
   279      "data": {},
   280      "dependents": {},
   281      "desired_capacity": 4,
   282      "domain": null,
   283      "id": "7d85f602-a948-4a30-afd4-e84f47471c15",
   284      "init_at": "2015-02-10T15:26:14Z",
   285      "max_size": -1,
   286      "metadata": {},
   287      "min_size": 0,
   288      "name": "cluster1",
   289      "nodes": [
   290        "b07c57c8-7ab2-47bf-bdf8-e894c0c601b9",
   291        "ecc23d3e-bb68-48f8-8260-c9cf6bcb6e61",
   292        "da1e9c87-e584-4626-a120-022da5062dac"
   293      ],
   294      "policies": [],
   295      "profile_id": "edc63d0a-2ca4-48fa-9854-27926da76a4a",
   296      "profile_name": "profile1",
   297      "project": "6e18cc2bdbeb48a5b3cad2dc499f6804",
   298      "status": "ACTIVE",
   299      "status_reason": "Cluster scale-in succeeded",
   300      "timeout": 3600,
   301      "updated_at": "2015-02-10T16:26:14Z",
   302      "user": "5e5bf8027826429c96af157f68dc9072"
   303    }
   304  }`
   305  
   306  const UpdateResponse_EmptyTime = `
   307  {
   308    "cluster": {
   309      "config": {},
   310      "created_at": null,
   311      "data": {},
   312      "dependents": {},
   313      "desired_capacity": 3,
   314      "domain": null,
   315      "id": "7d85f602-a948-4a30-afd4-e84f47471c15",
   316      "init_at": null,
   317      "max_size": 20,
   318      "metadata": {},
   319      "min_size": 1,
   320      "name": "cluster1",
   321      "nodes": [
   322        "b07c57c8-7ab2-47bf-bdf8-e894c0c601b9",
   323        "ecc23d3e-bb68-48f8-8260-c9cf6bcb6e61",
   324        "da1e9c87-e584-4626-a120-022da5062dac"
   325      ],
   326      "policies": [],
   327      "profile_id": "edc63d0a-2ca4-48fa-9854-27926da76a4a",
   328      "profile_name": "mystack",
   329      "project": "6e18cc2bdbeb48a5b3cad2dc499f6804",
   330      "status": "ACTIVE",
   331      "status_reason": "Cluster scale-in succeeded",
   332      "timeout": 3600,
   333      "updated_at": null,
   334      "user": "5e5bf8027826429c96af157f68dc9072"
   335    }
   336  }`
   337  
   338  const ActionResponse = `
   339  {
   340    "action": "2a0ff107-e789-4660-a122-3816c43af703"
   341  }`
   342  
   343  const ExpectedActionID = "2a0ff107-e789-4660-a122-3816c43af703"
   344  
   345  const OperationActionResponse = `
   346  {
   347    "action": "2a0ff107-e789-4660-a122-3816c43af703"
   348  }`
   349  
   350  const OperationExpectedActionID = "2a0ff107-e789-4660-a122-3816c43af703"
   351  
   352  const ListPoliciesResult = `{
   353    "cluster_policies": [
   354      {
   355        "cluster_id":   "7d85f602-a948-4a30-afd4-e84f47471c15",
   356        "cluster_name": "cluster4",
   357        "enabled":      true,
   358        "id":           "06be3a1f-b238-4a96-a737-ceec5714087e",
   359        "policy_id":    "714fe676-a08f-4196-b7af-61d52eeded15",
   360        "policy_name":  "dp01",
   361        "policy_type":  "senlin.policy.deletion-1.0"
   362      }
   363    ]
   364  }`
   365  
   366  var ExpectedClusterPolicy = clusters.ClusterPolicy{
   367  	ClusterID:   "7d85f602-a948-4a30-afd4-e84f47471c15",
   368  	ClusterName: "cluster4",
   369  	Enabled:     true,
   370  	ID:          "06be3a1f-b238-4a96-a737-ceec5714087e",
   371  	PolicyID:    "714fe676-a08f-4196-b7af-61d52eeded15",
   372  	PolicyName:  "dp01",
   373  	PolicyType:  "senlin.policy.deletion-1.0",
   374  }
   375  
   376  var ExpectedListPolicies = []clusters.ClusterPolicy{ExpectedClusterPolicy}
   377  
   378  const GetPolicyResponse = `
   379  {
   380    "cluster_policy": {
   381      "cluster_id":   "7d85f602-a948-4a30-afd4-e84f47471c15",
   382      "cluster_name": "cluster4",
   383      "enabled":      true,
   384      "id":           "06be3a1f-b238-4a96-a737-ceec5714087e",
   385      "policy_id":    "714fe676-a08f-4196-b7af-61d52eeded15",
   386      "policy_name":  "dp01",
   387      "policy_type":  "senlin.policy.deletion-1.0"
   388    }
   389  }`
   390  
   391  const CollectResponse = `
   392  {
   393    "cluster_attributes": [{
   394      "id": "foo",
   395      "value":   "bar"
   396    }
   397    ]	
   398  }`
   399  
   400  var ExpectedCollectAttributes = []clusters.ClusterAttributes{
   401  	{
   402  		ID:    "foo",
   403  		Value: string("bar"),
   404  	},
   405  }
   406  
   407  func HandleCreateClusterSuccessfully(t *testing.T) {
   408  	th.Mux.HandleFunc("/v1/clusters", func(w http.ResponseWriter, r *http.Request) {
   409  		th.TestMethod(t, r, "POST")
   410  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   411  
   412  		w.Header().Add("Content-Type", "application/json")
   413  		w.Header().Add("X-OpenStack-Request-ID", "req-781e9bdc-4163-46eb-91c9-786c53188bbb")
   414  		w.Header().Add("Location", "http://senlin.cloud.blizzard.net:8778/v1/actions/625628cd-f877-44be-bde0-fec79f84e13d")
   415  		w.WriteHeader(http.StatusOK)
   416  
   417  		fmt.Fprint(w, ClusterResponse)
   418  	})
   419  }
   420  
   421  func HandleCreateClusterEmptyTimeSuccessfully(t *testing.T) {
   422  	th.Mux.HandleFunc("/v1/clusters", func(w http.ResponseWriter, r *http.Request) {
   423  		th.TestMethod(t, r, "POST")
   424  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   425  
   426  		w.Header().Add("Content-Type", "application/json")
   427  		w.WriteHeader(http.StatusOK)
   428  
   429  		fmt.Fprint(w, ClusterResponse_EmptyTime)
   430  	})
   431  }
   432  
   433  func HandleCreateClusterMetadataSuccessfully(t *testing.T) {
   434  	th.Mux.HandleFunc("/v1/clusters", func(w http.ResponseWriter, r *http.Request) {
   435  		th.TestMethod(t, r, "POST")
   436  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   437  
   438  		w.Header().Add("Content-Type", "application/json")
   439  		w.WriteHeader(http.StatusOK)
   440  
   441  		fmt.Fprint(w, ClusterResponse_Metadata)
   442  	})
   443  }
   444  
   445  func HandleGetClusterSuccessfully(t *testing.T) {
   446  	th.Mux.HandleFunc("/v1/clusters/7d85f602-a948-4a30-afd4-e84f47471c15", func(w http.ResponseWriter, r *http.Request) {
   447  		th.TestMethod(t, r, "GET")
   448  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   449  
   450  		w.Header().Add("Content-Type", "application/json")
   451  		w.WriteHeader(http.StatusOK)
   452  
   453  		fmt.Fprint(w, ClusterResponse)
   454  	})
   455  }
   456  
   457  func HandleGetClusterEmptyTimeSuccessfully(t *testing.T) {
   458  	th.Mux.HandleFunc("/v1/clusters/7d85f602-a948-4a30-afd4-e84f47471c15", func(w http.ResponseWriter, r *http.Request) {
   459  		th.TestMethod(t, r, "GET")
   460  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   461  
   462  		w.Header().Add("Content-Type", "application/json")
   463  		w.WriteHeader(http.StatusOK)
   464  
   465  		fmt.Fprint(w, ClusterResponse_EmptyTime)
   466  	})
   467  }
   468  
   469  func HandleListClusterSuccessfully(t *testing.T) {
   470  	th.Mux.HandleFunc("/v1/clusters", func(w http.ResponseWriter, r *http.Request) {
   471  		th.TestMethod(t, r, "GET")
   472  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   473  
   474  		w.Header().Add("Content-Type", "application/json")
   475  		w.WriteHeader(http.StatusOK)
   476  
   477  		fmt.Fprint(w, ListResponse)
   478  	})
   479  }
   480  
   481  func HandleUpdateClusterSuccessfully(t *testing.T) {
   482  	th.Mux.HandleFunc("/v1/clusters/"+ExpectedCluster.ID, func(w http.ResponseWriter, r *http.Request) {
   483  		th.TestMethod(t, r, "PATCH")
   484  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   485  
   486  		w.Header().Add("Content-Type", "application/json")
   487  		w.WriteHeader(http.StatusOK)
   488  
   489  		fmt.Fprint(w, ClusterResponse)
   490  	})
   491  }
   492  
   493  func HandleUpdateClusterEmptyTimeSuccessfully(t *testing.T) {
   494  	th.Mux.HandleFunc("/v1/clusters/"+ExpectedCluster_EmptyTime.ID, func(w http.ResponseWriter, r *http.Request) {
   495  		th.TestMethod(t, r, "PATCH")
   496  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   497  
   498  		w.Header().Add("Content-Type", "application/json")
   499  		w.WriteHeader(http.StatusOK)
   500  
   501  		fmt.Fprint(w, UpdateResponse_EmptyTime)
   502  	})
   503  }
   504  
   505  func HandleDeleteClusterSuccessfully(t *testing.T) {
   506  	th.Mux.HandleFunc("/v1/clusters/6dc6d336e3fc4c0a951b5698cd1236ee", func(w http.ResponseWriter, r *http.Request) {
   507  		th.TestMethod(t, r, "DELETE")
   508  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   509  
   510  		w.Header().Add("Content-Type", "application/json")
   511  		w.WriteHeader(http.StatusNoContent)
   512  	})
   513  }
   514  
   515  func HandleResizeSuccessfully(t *testing.T) {
   516  	th.Mux.HandleFunc("/v1/clusters/7d85f602-a948-4a30-afd4-e84f47471c15/actions", func(w http.ResponseWriter, r *http.Request) {
   517  		th.TestMethod(t, r, "POST")
   518  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   519  
   520  		w.Header().Add("Content-Type", "application/json")
   521  		w.WriteHeader(http.StatusOK)
   522  
   523  		fmt.Fprint(w, ActionResponse)
   524  	})
   525  }
   526  
   527  func HandleScaleInSuccessfully(t *testing.T) {
   528  	th.Mux.HandleFunc("/v1/clusters/edce3528-864f-41fb-8759-f4707925cc09/actions", func(w http.ResponseWriter, r *http.Request) {
   529  		th.TestMethod(t, r, "POST")
   530  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   531  
   532  		w.Header().Add("Content-Type", "application/json")
   533  		w.WriteHeader(http.StatusOK)
   534  
   535  		fmt.Fprint(w, ActionResponse)
   536  	})
   537  }
   538  
   539  func HandleScaleOutSuccessfully(t *testing.T) {
   540  	th.Mux.HandleFunc("/v1/clusters/edce3528-864f-41fb-8759-f4707925cc09/actions", func(w http.ResponseWriter, r *http.Request) {
   541  		th.TestMethod(t, r, "POST")
   542  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   543  
   544  		w.Header().Add("Content-Type", "application/json")
   545  		w.WriteHeader(http.StatusOK)
   546  
   547  		fmt.Fprint(w, ActionResponse)
   548  	})
   549  }
   550  
   551  func HandleListPoliciesSuccessfully(t *testing.T) {
   552  	th.Mux.HandleFunc("/v1/clusters/7d85f602-a948-4a30-afd4-e84f47471c15/policies", func(w http.ResponseWriter, r *http.Request) {
   553  		th.TestMethod(t, r, "GET")
   554  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   555  
   556  		w.Header().Add("Content-Type", "application/json")
   557  		w.WriteHeader(http.StatusOK)
   558  
   559  		fmt.Fprint(w, ListPoliciesResult)
   560  	})
   561  }
   562  
   563  func HandleGetPolicySuccessfully(t *testing.T) {
   564  	th.Mux.HandleFunc("/v1/clusters/7d85f602-a948-4a30-afd4-e84f47471c15/policies/714fe676-a08f-4196-b7af-61d52eeded15", func(w http.ResponseWriter, r *http.Request) {
   565  		th.TestMethod(t, r, "GET")
   566  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   567  
   568  		w.Header().Add("Content-Type", "application/json")
   569  		w.WriteHeader(http.StatusOK)
   570  
   571  		fmt.Fprint(w, GetPolicyResponse)
   572  	})
   573  }
   574  
   575  func HandleRecoverSuccessfully(t *testing.T) {
   576  	th.Mux.HandleFunc("/v1/clusters/edce3528-864f-41fb-8759-f4707925cc09/actions", func(w http.ResponseWriter, r *http.Request) {
   577  		th.TestMethod(t, r, "POST")
   578  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   579  
   580  		w.Header().Add("Content-Type", "application/json")
   581  		w.WriteHeader(http.StatusOK)
   582  
   583  		fmt.Fprint(w, ActionResponse)
   584  	})
   585  }
   586  
   587  func HandleAttachPolicySuccessfully(t *testing.T) {
   588  	th.Mux.HandleFunc("/v1/clusters/7d85f602-a948-4a30-afd4-e84f47471c15/actions", func(w http.ResponseWriter, r *http.Request) {
   589  		th.TestMethod(t, r, "POST")
   590  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   591  
   592  		w.Header().Add("Content-Type", "application/json")
   593  		w.WriteHeader(http.StatusOK)
   594  
   595  		fmt.Fprint(w, ActionResponse)
   596  	})
   597  }
   598  
   599  func HandleDetachPolicySuccessfully(t *testing.T) {
   600  	th.Mux.HandleFunc("/v1/clusters/7d85f602-a948-4a30-afd4-e84f47471c15/actions", func(w http.ResponseWriter, r *http.Request) {
   601  		th.TestMethod(t, r, "POST")
   602  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   603  
   604  		w.Header().Add("Content-Type", "application/json")
   605  		w.WriteHeader(http.StatusOK)
   606  
   607  		fmt.Fprint(w, ActionResponse)
   608  	})
   609  }
   610  
   611  func HandleUpdatePolicySuccessfully(t *testing.T) {
   612  	th.Mux.HandleFunc("/v1/clusters/7d85f602-a948-4a30-afd4-e84f47471c15/actions", func(w http.ResponseWriter, r *http.Request) {
   613  		th.TestMethod(t, r, "POST")
   614  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   615  
   616  		w.Header().Add("Content-Type", "application/json")
   617  		w.WriteHeader(http.StatusOK)
   618  
   619  		fmt.Fprint(w, ActionResponse)
   620  	})
   621  }
   622  
   623  func HandleCheckSuccessfully(t *testing.T) {
   624  	th.Mux.HandleFunc("/v1/clusters/edce3528-864f-41fb-8759-f4707925cc09/actions", func(w http.ResponseWriter, r *http.Request) {
   625  		th.TestMethod(t, r, "POST")
   626  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   627  
   628  		w.Header().Add("Content-Type", "application/json")
   629  		w.WriteHeader(http.StatusOK)
   630  
   631  		fmt.Fprint(w, ActionResponse)
   632  	})
   633  }
   634  
   635  func HandleLifecycleSuccessfully(t *testing.T) {
   636  	th.Mux.HandleFunc("/v1/clusters/edce3528-864f-41fb-8759-f4707925cc09/actions", func(w http.ResponseWriter, r *http.Request) {
   637  		th.TestMethod(t, r, "POST")
   638  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   639  
   640  		w.Header().Add("Content-Type", "application/json")
   641  		w.Header().Add("X-OpenStack-Request-ID", "req-781e9bdc-4163-46eb-91c9-786c53188bbb")
   642  		w.Header().Add("Location", "http://senlin.cloud.blizzard.net:8778/v1/actions/2a0ff107-e789-4660-a122-3816c43af703")
   643  		w.WriteHeader(http.StatusAccepted)
   644  
   645  		fmt.Fprint(w, ActionResponse)
   646  	})
   647  }
   648  
   649  func HandleAddNodesSuccessfully(t *testing.T) {
   650  	th.Mux.HandleFunc("/v1/clusters/7d85f602-a948-4a30-afd4-e84f47471c15/actions", func(w http.ResponseWriter, r *http.Request) {
   651  		th.TestMethod(t, r, "POST")
   652  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   653  
   654  		w.Header().Add("Content-Type", "application/json")
   655  		w.Header().Add("X-OpenStack-Request-ID", "req-781e9bdc-4163-46eb-91c9-786c53188bbb")
   656  		w.WriteHeader(http.StatusAccepted)
   657  
   658  		fmt.Fprint(w, ActionResponse)
   659  	})
   660  }
   661  
   662  func HandleRemoveNodesSuccessfully(t *testing.T) {
   663  	th.Mux.HandleFunc("/v1/clusters/7d85f602-a948-4a30-afd4-e84f47471c15/actions", func(w http.ResponseWriter, r *http.Request) {
   664  		th.TestMethod(t, r, "POST")
   665  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   666  		w.Header().Add("Content-Type", "application/json")
   667  		w.Header().Add("X-OpenStack-Request-ID", "req-781e9bdc-4163-46eb-91c9-786c53188bbb")
   668  		w.WriteHeader(http.StatusAccepted)
   669  		fmt.Fprint(w, ActionResponse)
   670  	})
   671  }
   672  
   673  func HandleReplaceNodeSuccessfully(t *testing.T) {
   674  	th.Mux.HandleFunc("/v1/clusters/7d85f602-a948-4a30-afd4-e84f47471c15/actions", func(w http.ResponseWriter, r *http.Request) {
   675  		th.TestMethod(t, r, "POST")
   676  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   677  		w.Header().Add("Content-Type", "application/json")
   678  		w.Header().Add("X-OpenStack-Request-ID", "req-781e9bdc-4163-46eb-91c9-786c53188bbb")
   679  		w.WriteHeader(http.StatusAccepted)
   680  		fmt.Fprint(w, ActionResponse)
   681  	})
   682  }
   683  
   684  func HandleClusterCollectSuccessfully(t *testing.T) {
   685  	th.Mux.HandleFunc("/v1/clusters/7d85f602-a948-4a30-afd4-e84f47471c15/attrs/foo.bar", func(w http.ResponseWriter, r *http.Request) {
   686  		th.TestMethod(t, r, "GET")
   687  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   688  		w.Header().Add("Content-Type", "application/json")
   689  		w.Header().Add("X-OpenStack-Request-ID", "req-781e9bdc-4163-46eb-91c9-786c53188bbb")
   690  		w.WriteHeader(http.StatusOK)
   691  		fmt.Fprint(w, CollectResponse)
   692  	})
   693  }
   694  
   695  func HandleOpsSuccessfully(t *testing.T) {
   696  	th.Mux.HandleFunc("/v1/clusters/7d85f602-a948-4a30-afd4-e84f47471c15/ops", func(w http.ResponseWriter, r *http.Request) {
   697  		th.TestMethod(t, r, "POST")
   698  		th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
   699  
   700  		w.Header().Add("Content-Type", "application/json")
   701  		w.WriteHeader(http.StatusAccepted)
   702  
   703  		fmt.Fprint(w, OperationActionResponse)
   704  	})
   705  }