github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/bms/v2/keypairs/testing/requests_test.go (about) 1 package testing 2 3 import ( 4 "fmt" 5 "net/http" 6 "testing" 7 8 "github.com/huaweicloud/golangsdk/openstack/bms/v2/keypairs" 9 th "github.com/huaweicloud/golangsdk/testhelper" 10 "github.com/huaweicloud/golangsdk/testhelper/client" 11 ) 12 13 func TestList(t *testing.T) { 14 th.SetupHTTP() 15 defer th.TeardownHTTP() 16 17 th.Mux.HandleFunc("/os-keypairs", func(w http.ResponseWriter, r *http.Request) { 18 th.TestMethod(t, r, "GET") 19 th.TestHeader(t, r, "X-Auth-Token", client.TokenID) 20 21 w.Header().Add("Content-Type", "application/json") 22 w.WriteHeader(http.StatusOK) 23 24 fmt.Fprintf(w, ListOutput) 25 }) 26 27 actual, err := keypairs.List(client.ServiceClient(), keypairs.ListOpts{}) 28 th.AssertNoErr(t, err) 29 expected := []keypairs.KeyPair{ 30 { 31 32 Name: "c2c-firstkey", 33 PublicKey: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCyUHvhG56/beGw/23/zYGQJ9YUmsMiRhigdbuhpS7QgPMG1LMlW32Homqph166GXpfRvo66vwO+vTrQu9xLR0Z4oYntKDGtc9pF5SRE7nsSjxmtrs2GjJB+dBsk0WgSxVUZP0jV59ecJJhWz5IvtjDJ7UkuwmDv27GLDVnuADS4uAeXXhUKKHnCgkYXLgOsSbp52e9oq2ulMNCZ3RWtFLHE/phShPYjDvZ/8grG2WKkhsf65cR71CIOaOfDbf6AfOyUr0xFLeGg+elSE/g4IHe4yCZodAjGlvE78jkBdEIXb6wmr0nWY033KiunMyWX2ERey5rcQ1XI4YuUgP2ApCd Generated-by-Nova\n", 34 Fingerprint: "68:17:18:4c:4f:a7:05:68:71:01:3c:f1:db:4c:38:4f", 35 }, 36 { 37 38 Name: "c2c-secondkey", 39 PublicKey: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD2iZGC1Gr6YWjjobcqA5SP150HA4FzCbDk1r91KKr7GHpeVSsnaXM+e/Eh6VB04ahnF4bllz3fgXfeFgTbVfMbIOcomqU1KmtZpcXOjCVrHo4I6dpAisZ8yO6mBjbbl440Xgocs2UqnWVTlW2vf0O0IFmPODJLN7P1r1r2Vfd0gnZpGN5/J8HvzsQLtdbmttl/ylxkbrq/20bIlY1VF3FXNO7KeREJTwDgdo3xRTFBXMkbSAj9b7dBlN4nhB0lXl8lnAGAA+nkJ69Av3UE0yaG2jYJcW9yjqLuIH3GMFGXSdqLMitdGqfR0o8RhHW40xZM7wMOXUbShy2r4u7uGUXv Generated-by-Nova\n", 40 Fingerprint: "a7:c0:d6:6b:60:32:15:fe:f7:74:37:18:85:7a:fa:31", 41 }, 42 } 43 th.AssertDeepEquals(t, expected, actual) 44 }