1509 lines
57 KiB
Go
1509 lines
57 KiB
Go
/*
|
|
STACKIT Key Management Service API
|
|
|
|
Testing DefaultApiService
|
|
|
|
*/
|
|
|
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech);
|
|
|
|
package kmsbeta
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"net/url"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/stackitcloud/stackit-sdk-go/core/config"
|
|
)
|
|
|
|
func Test_kmsbeta_DefaultApiService(t *testing.T) {
|
|
|
|
t.Run("Test DefaultApiService CreateKey", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
keyRingIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := Key{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
keyRingId := keyRingIdValue
|
|
createKeyPayload := CreateKeyPayload{}
|
|
|
|
resp, reqErr := apiClient.CreateKey(context.Background(), projectId, regionId, keyRingId).CreateKeyPayload(createKeyPayload).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService CreateKeyRing", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := KeyRing{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
createKeyRingPayload := CreateKeyRingPayload{}
|
|
|
|
resp, reqErr := apiClient.CreateKeyRing(context.Background(), projectId, regionId).CreateKeyRingPayload(createKeyRingPayload).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService CreateWrappingKey", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/wrappingkeys"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
keyRingIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := WrappingKey{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
keyRingId := keyRingIdValue
|
|
createWrappingKeyPayload := CreateWrappingKeyPayload{}
|
|
|
|
resp, reqErr := apiClient.CreateWrappingKey(context.Background(), projectId, regionId, keyRingId).CreateWrappingKeyPayload(createWrappingKeyPayload).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService Decrypt", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/decrypt"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
keyRingIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1)
|
|
keyIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1)
|
|
versionNumberValue := int64(123)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"versionNumber"+"}", url.PathEscape(ParameterValueToString(versionNumberValue, "versionNumber")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := DecryptedData{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
keyRingId := keyRingIdValue
|
|
keyId := keyIdValue
|
|
versionNumber := versionNumberValue
|
|
decryptPayload := DecryptPayload{}
|
|
|
|
resp, reqErr := apiClient.Decrypt(context.Background(), projectId, regionId, keyRingId, keyId, versionNumber).DecryptPayload(decryptPayload).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService DeleteKey", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
keyRingIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1)
|
|
keyIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
keyRingId := keyRingIdValue
|
|
keyId := keyIdValue
|
|
|
|
reqErr := apiClient.DeleteKey(context.Background(), projectId, regionId, keyRingId, keyId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService DeleteKeyRing", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
keyRingIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
keyRingId := keyRingIdValue
|
|
|
|
reqErr := apiClient.DeleteKeyRing(context.Background(), projectId, regionId, keyRingId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService DeleteWrappingKey", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/wrappingkeys/{wrappingKeyId}"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
keyRingIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1)
|
|
wrappingKeyIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"wrappingKeyId"+"}", url.PathEscape(ParameterValueToString(wrappingKeyIdValue, "wrappingKeyId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
keyRingId := keyRingIdValue
|
|
wrappingKeyId := wrappingKeyIdValue
|
|
|
|
reqErr := apiClient.DeleteWrappingKey(context.Background(), projectId, regionId, keyRingId, wrappingKeyId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService DestroyVersion", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/destroy"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
keyRingIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1)
|
|
keyIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1)
|
|
versionNumberValue := int64(123)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"versionNumber"+"}", url.PathEscape(ParameterValueToString(versionNumberValue, "versionNumber")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
keyRingId := keyRingIdValue
|
|
keyId := keyIdValue
|
|
versionNumber := versionNumberValue
|
|
|
|
reqErr := apiClient.DestroyVersion(context.Background(), projectId, regionId, keyRingId, keyId, versionNumber).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService DisableVersion", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/disable"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
keyRingIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1)
|
|
keyIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1)
|
|
versionNumberValue := int64(123)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"versionNumber"+"}", url.PathEscape(ParameterValueToString(versionNumberValue, "versionNumber")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
keyRingId := keyRingIdValue
|
|
keyId := keyIdValue
|
|
versionNumber := versionNumberValue
|
|
|
|
reqErr := apiClient.DisableVersion(context.Background(), projectId, regionId, keyRingId, keyId, versionNumber).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService EnableVersion", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/enable"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
keyRingIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1)
|
|
keyIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1)
|
|
versionNumberValue := int64(123)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"versionNumber"+"}", url.PathEscape(ParameterValueToString(versionNumberValue, "versionNumber")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
keyRingId := keyRingIdValue
|
|
keyId := keyIdValue
|
|
versionNumber := versionNumberValue
|
|
|
|
reqErr := apiClient.EnableVersion(context.Background(), projectId, regionId, keyRingId, keyId, versionNumber).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService Encrypt", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/encrypt"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
keyRingIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1)
|
|
keyIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1)
|
|
versionNumberValue := int64(123)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"versionNumber"+"}", url.PathEscape(ParameterValueToString(versionNumberValue, "versionNumber")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := EncryptedData{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
keyRingId := keyRingIdValue
|
|
keyId := keyIdValue
|
|
versionNumber := versionNumberValue
|
|
encryptPayload := EncryptPayload{}
|
|
|
|
resp, reqErr := apiClient.Encrypt(context.Background(), projectId, regionId, keyRingId, keyId, versionNumber).EncryptPayload(encryptPayload).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService GetKey", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
keyRingIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1)
|
|
keyIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := Key{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
keyRingId := keyRingIdValue
|
|
keyId := keyIdValue
|
|
|
|
resp, reqErr := apiClient.GetKey(context.Background(), projectId, regionId, keyRingId, keyId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService GetKeyRing", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
keyRingIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := KeyRing{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
keyRingId := keyRingIdValue
|
|
|
|
resp, reqErr := apiClient.GetKeyRing(context.Background(), projectId, regionId, keyRingId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService GetVersion", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
keyRingIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1)
|
|
keyIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1)
|
|
versionNumberValue := int64(123)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"versionNumber"+"}", url.PathEscape(ParameterValueToString(versionNumberValue, "versionNumber")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := Version{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
keyRingId := keyRingIdValue
|
|
keyId := keyIdValue
|
|
versionNumber := versionNumberValue
|
|
|
|
resp, reqErr := apiClient.GetVersion(context.Background(), projectId, regionId, keyRingId, keyId, versionNumber).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService GetWrappingKey", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/wrappingkeys/{wrappingKeyId}"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
keyRingIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1)
|
|
wrappingKeyIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"wrappingKeyId"+"}", url.PathEscape(ParameterValueToString(wrappingKeyIdValue, "wrappingKeyId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := WrappingKey{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
keyRingId := keyRingIdValue
|
|
wrappingKeyId := wrappingKeyIdValue
|
|
|
|
resp, reqErr := apiClient.GetWrappingKey(context.Background(), projectId, regionId, keyRingId, wrappingKeyId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService ImportKey", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/import"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
keyRingIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1)
|
|
keyIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := Version{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
keyRingId := keyRingIdValue
|
|
keyId := keyIdValue
|
|
importKeyPayload := ImportKeyPayload{}
|
|
|
|
resp, reqErr := apiClient.ImportKey(context.Background(), projectId, regionId, keyRingId, keyId).ImportKeyPayload(importKeyPayload).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService ListKeyRings", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := KeyRingList{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
|
|
resp, reqErr := apiClient.ListKeyRings(context.Background(), projectId, regionId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService ListKeys", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
keyRingIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := KeyList{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
keyRingId := keyRingIdValue
|
|
|
|
resp, reqErr := apiClient.ListKeys(context.Background(), projectId, regionId, keyRingId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService ListVersions", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
keyRingIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1)
|
|
keyIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := VersionList{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
keyRingId := keyRingIdValue
|
|
keyId := keyIdValue
|
|
|
|
resp, reqErr := apiClient.ListVersions(context.Background(), projectId, regionId, keyRingId, keyId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService ListWrappingKeys", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/wrappingkeys"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
keyRingIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := WrappingKeyList{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
keyRingId := keyRingIdValue
|
|
|
|
resp, reqErr := apiClient.ListWrappingKeys(context.Background(), projectId, regionId, keyRingId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService RestoreKey", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/restore"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
keyRingIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1)
|
|
keyIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
keyRingId := keyRingIdValue
|
|
keyId := keyIdValue
|
|
|
|
reqErr := apiClient.RestoreKey(context.Background(), projectId, regionId, keyRingId, keyId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService RestoreVersion", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/restore"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
keyRingIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1)
|
|
keyIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1)
|
|
versionNumberValue := int64(123)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"versionNumber"+"}", url.PathEscape(ParameterValueToString(versionNumberValue, "versionNumber")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
keyRingId := keyRingIdValue
|
|
keyId := keyIdValue
|
|
versionNumber := versionNumberValue
|
|
|
|
reqErr := apiClient.RestoreVersion(context.Background(), projectId, regionId, keyRingId, keyId, versionNumber).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService RotateKey", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/rotate"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
keyRingIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1)
|
|
keyIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := Version{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
keyRingId := keyRingIdValue
|
|
keyId := keyIdValue
|
|
|
|
resp, reqErr := apiClient.RotateKey(context.Background(), projectId, regionId, keyRingId, keyId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService Sign", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/sign"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
keyRingIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1)
|
|
keyIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1)
|
|
versionNumberValue := int64(123)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"versionNumber"+"}", url.PathEscape(ParameterValueToString(versionNumberValue, "versionNumber")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := SignedData{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
keyRingId := keyRingIdValue
|
|
keyId := keyIdValue
|
|
versionNumber := versionNumberValue
|
|
signPayload := SignPayload{}
|
|
|
|
resp, reqErr := apiClient.Sign(context.Background(), projectId, regionId, keyRingId, keyId, versionNumber).SignPayload(signPayload).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService Verify", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/verify"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
keyRingIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyRingId"+"}", url.PathEscape(ParameterValueToString(keyRingIdValue, "keyRingId")), -1)
|
|
keyIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"keyId"+"}", url.PathEscape(ParameterValueToString(keyIdValue, "keyId")), -1)
|
|
versionNumberValue := int64(123)
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"versionNumber"+"}", url.PathEscape(ParameterValueToString(versionNumberValue, "versionNumber")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := VerifiedData{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
testServer := httptest.NewServer(testDefaultApiServeMux)
|
|
defer testServer.Close()
|
|
|
|
configuration := &config.Configuration{
|
|
DefaultHeader: make(map[string]string),
|
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
Debug: false,
|
|
Region: "test_region",
|
|
Servers: config.ServerConfigurations{
|
|
{
|
|
URL: testServer.URL,
|
|
Description: "Localhost for kmsbeta_DefaultApi",
|
|
Variables: map[string]config.ServerVariable{
|
|
"region": {
|
|
DefaultValue: "test_region.",
|
|
EnumValues: []string{
|
|
"test_region.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
OperationServers: map[string]config.ServerConfigurations{},
|
|
}
|
|
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
|
|
if err != nil {
|
|
t.Fatalf("creating API client: %v", err)
|
|
}
|
|
|
|
projectId := projectIdValue
|
|
regionId := regionIdValue
|
|
keyRingId := keyRingIdValue
|
|
keyId := keyIdValue
|
|
versionNumber := versionNumberValue
|
|
verifyPayload := VerifyPayload{}
|
|
|
|
resp, reqErr := apiClient.Verify(context.Background(), projectId, regionId, keyRingId, keyId, versionNumber).VerifyPayload(verifyPayload).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
}
|