diff --git a/dns_config/test/api_acl_test.go b/dns_config/test/api_acl_test.go index 46d107e..62a8ef8 100644 --- a/dns_config/test/api_acl_test.go +++ b/dns_config/test/api_acl_test.go @@ -5,89 +5,158 @@ Testing AclAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package dns_config +package dns_config_test import ( + "bytes" "context" + "encoding/json" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" openapiclient "github.com/infobloxopen/bloxone-go-client/dns_config" "github.com/infobloxopen/bloxone-go-client/internal" ) -func Test_dns_config_AclAPIService(t *testing.T) { - - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) - - t.Run("Test AclAPIService AclCreate", func(t *testing.T) { +var ConfigACLPost = openapiclient.ConfigACL{ + Comment: openapiclient.PtrString("This is a dummy ACL for testing."), + Id: openapiclient.PtrString("dummyAclId"), + Name: "dummyAclName", + Tags: make(map[string]interface{}), +} - t.Skip("skip test") // remove to run test +var ConfigACLPatch = openapiclient.ConfigACL{ + Comment: openapiclient.PtrString("This is an updated dummy ACL for testing."), + Id: ConfigACLPost.Id, + Name: "updatedDummyAclName", + Tags: make(map[string]interface{}), +} - resp, httpRes, err := apiClient.AclAPI.AclCreate(context.Background()).Execute() +func TestAclAPIService(t *testing.T) { + t.Run("Test AclAPIService AclCreate", func(t *testing.T) { + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dns/acl", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.ConfigACL + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigACLPost, reqBody) + + response := openapiclient.ConfigCreateACLResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AclAPI.AclCreate(context.Background()).Body(ConfigACLPost).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test AclAPIService AclDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.AclAPI.AclDelete(context.Background(), id).Execute() - - require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test AclAPIService AclList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/acl", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigListACLResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.AclAPI.AclList(context.Background()).Execute() - require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test AclAPIService AclRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.AclAPI.AclRead(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/acl/"+*ConfigACLPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigReadACLResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AclAPI.AclRead(context.Background(), *ConfigACLPost.Id).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test AclAPIService AclUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.AclAPI.AclUpdate(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dns/acl/"+*ConfigACLPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.ConfigACL + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigACLPatch, reqBody) + + response := openapiclient.ConfigUpdateACLResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AclAPI.AclUpdate(context.Background(), *ConfigACLPatch.Id).Body(ConfigACLPatch).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) + require.Equal(t, http.StatusOK, httpRes.StatusCode) + }) + t.Run("Test AclAPIService AclDelete", func(t *testing.T) { + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/dns/acl/"+*ConfigACLPost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.AclAPI.AclDelete(context.Background(), *ConfigACLPost.Id).Execute() + require.Nil(t, err) + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) } diff --git a/dns_config/test/api_auth_nsg_test.go b/dns_config/test/api_auth_nsg_test.go index 365aee3..4122458 100644 --- a/dns_config/test/api_auth_nsg_test.go +++ b/dns_config/test/api_auth_nsg_test.go @@ -5,89 +5,157 @@ Testing AuthNsgAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package dns_config +package dns_config_test import ( + "bytes" "context" + "encoding/json" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" openapiclient "github.com/infobloxopen/bloxone-go-client/dns_config" "github.com/infobloxopen/bloxone-go-client/internal" ) -func Test_dns_config_AuthNsgAPIService(t *testing.T) { +var ConfigAuthNSGPost = openapiclient.ConfigAuthNSG{ + Comment: openapiclient.PtrString("This is a dummy AuthNes for testing."), + Id: openapiclient.PtrString("dummyAuthNesId"), + Name: "dummyAuthNesName", + Tags: make(map[string]interface{}), +} +var ConfigAuthNSGPatch = openapiclient.ConfigAuthNSG{ + Comment: openapiclient.PtrString("This is an updated dummy AuthNsg for testing."), + Id: ConfigAuthNSGPost.Id, + Name: "updatedDummyAuthNsgName", + Tags: make(map[string]interface{}), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestAuthNsgAPIService(t *testing.T) { t.Run("Test AuthNsgAPIService AuthNsgCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.AuthNsgAPI.AuthNsgCreate(context.Background()).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dns/auth_nsg", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.ConfigAuthNSG + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigAuthNSGPost, reqBody) + + response := openapiclient.ConfigCreateAuthNSGResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AuthNsgAPI.AuthNsgCreate(context.Background()).Body(ConfigAuthNSGPost).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test AuthNsgAPIService AuthNsgDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.AuthNsgAPI.AuthNsgDelete(context.Background(), id).Execute() - - require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test AuthNsgAPIService AuthNsgList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/auth_nsg", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigListAuthNSGResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.AuthNsgAPI.AuthNsgList(context.Background()).Execute() - require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test AuthNsgAPIService AuthNsgRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.AuthNsgAPI.AuthNsgRead(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/auth_nsg/"+*ConfigAuthNSGPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigReadAuthNSGResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AuthNsgAPI.AuthNsgRead(context.Background(), *ConfigAuthNSGPost.Id).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test AuthNsgAPIService AuthNsgUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.AuthNsgAPI.AuthNsgUpdate(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dns/auth_nsg/"+*ConfigAuthNSGPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.ConfigAuthNSG + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigAuthNSGPatch, reqBody) + + response := openapiclient.ConfigUpdateAuthNSGResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AuthNsgAPI.AuthNsgUpdate(context.Background(), *ConfigAuthNSGPatch.Id).Body(ConfigAuthNSGPatch).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) + require.Equal(t, http.StatusOK, httpRes.StatusCode) + }) + t.Run("Test AuthNsgAPIService AuthNsgDelete", func(t *testing.T) { + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/dns/auth_nsg/"+*ConfigAuthNSGPost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.AuthNsgAPI.AuthNsgDelete(context.Background(), *ConfigAuthNSGPost.Id).Execute() + require.Nil(t, err) + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) } diff --git a/dns_config/test/api_auth_zone_test.go b/dns_config/test/api_auth_zone_test.go index bb3daaa..28d3a1d 100644 --- a/dns_config/test/api_auth_zone_test.go +++ b/dns_config/test/api_auth_zone_test.go @@ -5,101 +5,187 @@ Testing AuthZoneAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package dns_config +package dns_config_test import ( + "bytes" "context" + "encoding/json" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" openapiclient "github.com/infobloxopen/bloxone-go-client/dns_config" "github.com/infobloxopen/bloxone-go-client/internal" ) -func Test_dns_config_AuthZoneAPIService(t *testing.T) { +var ConfigCopyAuthZonePost = openapiclient.ConfigCopyAuthZone{ + Comment: openapiclient.PtrString("This is a copy AuthZone for testing."), + Id: openapiclient.PtrString("dummyAuthZoneId"), +} +var ConfigAuthZonePost = openapiclient.ConfigAuthZone{ + Comment: openapiclient.PtrString("This is a dummy AuthZone for testing."), + Id: openapiclient.PtrString("dummyAuthZoneId"), + Tags: make(map[string]interface{}), +} +var ConfigAuthZonePatch = openapiclient.ConfigAuthZone{ + Comment: openapiclient.PtrString("This is an updated dummy AuthZone for testing."), + Id: ConfigAuthZonePost.Id, + Tags: make(map[string]interface{}), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestAuthZoneAPIService(t *testing.T) { t.Run("Test AuthZoneAPIService AuthZoneCopy", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.AuthZoneAPI.AuthZoneCopy(context.Background()).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dns/auth_zone/copy", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.ConfigCopyAuthZone + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigCopyAuthZonePost, reqBody) + + response := openapiclient.ConfigCopyAuthZoneResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AuthZoneAPI.AuthZoneCopy(context.Background()).Body(ConfigCopyAuthZonePost).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test AuthZoneAPIService AuthZoneCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.AuthZoneAPI.AuthZoneCreate(context.Background()).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dns/auth_zone", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.ConfigAuthZone + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigAuthZonePost, reqBody) + + response := openapiclient.ConfigCreateAuthZoneResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AuthZoneAPI.AuthZoneCreate(context.Background()).Body(ConfigAuthZonePost).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test AuthZoneAPIService AuthZoneDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.AuthZoneAPI.AuthZoneDelete(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/dns/auth_zone/"+*ConfigAuthZonePost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.AuthZoneAPI.AuthZoneDelete(context.Background(), *ConfigAuthZonePost.Id).Execute() require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test AuthZoneAPIService AuthZoneList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/auth_zone", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigListAuthZoneResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.AuthZoneAPI.AuthZoneList(context.Background()).Execute() - require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test AuthZoneAPIService AuthZoneRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.AuthZoneAPI.AuthZoneRead(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/auth_zone/"+*ConfigAuthZonePost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigReadAuthZoneResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AuthZoneAPI.AuthZoneRead(context.Background(), *ConfigAuthZonePost.Id).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test AuthZoneAPIService AuthZoneUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.AuthZoneAPI.AuthZoneUpdate(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dns/auth_zone/"+*ConfigAuthZonePost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.ConfigAuthZone + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigAuthZonePatch, reqBody) + + response := openapiclient.ConfigUpdateAuthZoneResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AuthZoneAPI.AuthZoneUpdate(context.Background(), *ConfigAuthZonePatch.Id).Body(ConfigAuthZonePatch).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) } diff --git a/dns_config/test/api_cache_flush_test.go b/dns_config/test/api_cache_flush_test.go index a7ee097..a72586a 100644 --- a/dns_config/test/api_cache_flush_test.go +++ b/dns_config/test/api_cache_flush_test.go @@ -5,36 +5,54 @@ Testing CacheFlushAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package dns_config +package dns_config_test import ( + "bytes" "context" + "encoding/json" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" openapiclient "github.com/infobloxopen/bloxone-go-client/dns_config" "github.com/infobloxopen/bloxone-go-client/internal" ) -func Test_dns_config_CacheFlushAPIService(t *testing.T) { +var ConfigCacheFlushPost = openapiclient.ConfigCacheFlush{ + FlushSubdomains: openapiclient.PtrBool(true), + Fqdn: openapiclient.PtrString("dummyFqdn"), + Ophid: openapiclient.PtrString("dummyOphid"), + ServiceId: openapiclient.PtrString("dummyServiceId"), + Ttl: openapiclient.PtrInt64(120), + ViewName: openapiclient.PtrString("dummyViewName"), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestCacheFlushAPIService(t *testing.T) { t.Run("Test CacheFlushAPIService CacheFlushCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.CacheFlushAPI.CacheFlushCreate(context.Background()).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dns/cache_flush", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.ConfigCacheFlush + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigCacheFlushPost, reqBody) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + _, httpRes, err := apiClient.CacheFlushAPI.CacheFlushCreate(context.Background()).Body(ConfigCacheFlushPost).Execute() require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) } diff --git a/dns_config/test/api_convert_domain_name_test.go b/dns_config/test/api_convert_domain_name_test.go index 108d68d..b3b726d 100644 --- a/dns_config/test/api_convert_domain_name_test.go +++ b/dns_config/test/api_convert_domain_name_test.go @@ -5,38 +5,48 @@ Testing ConvertDomainNameAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package dns_config +package dns_config_test import ( + "bytes" "context" + "encoding/json" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" openapiclient "github.com/infobloxopen/bloxone-go-client/dns_config" "github.com/infobloxopen/bloxone-go-client/internal" ) -func Test_dns_config_ConvertDomainNameAPIService(t *testing.T) { +var domainName = "example.com" - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestConvertDomainNameAPIService(t *testing.T) { t.Run("Test ConvertDomainNameAPIService ConvertDomainNameConvert", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var domainName string - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/convert_domain_name/"+domainName, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigConvertDomainNameResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.ConvertDomainNameAPI.ConvertDomainNameConvert(context.Background(), domainName).Execute() - require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) } diff --git a/dns_config/test/api_convert_rname_test.go b/dns_config/test/api_convert_rname_test.go index 23ddedf..f5ed9fc 100644 --- a/dns_config/test/api_convert_rname_test.go +++ b/dns_config/test/api_convert_rname_test.go @@ -5,38 +5,48 @@ Testing ConvertRnameAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package dns_config +package dns_config_test import ( + "bytes" "context" + "encoding/json" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" openapiclient "github.com/infobloxopen/bloxone-go-client/dns_config" "github.com/infobloxopen/bloxone-go-client/internal" ) -func Test_dns_config_ConvertRnameAPIService(t *testing.T) { +var emailAddress = "test@example.com" - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestConvertRnameAPIService(t *testing.T) { t.Run("Test ConvertRnameAPIService ConvertRnameConvertRName", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var emailAddress string - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/convert_rname/"+emailAddress, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigConvertRNameResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.ConvertRnameAPI.ConvertRnameConvertRName(context.Background(), emailAddress).Execute() - require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) } diff --git a/dns_config/test/api_delegation_test.go b/dns_config/test/api_delegation_test.go index 9833d9f..91e4cb1 100644 --- a/dns_config/test/api_delegation_test.go +++ b/dns_config/test/api_delegation_test.go @@ -5,89 +5,167 @@ Testing DelegationAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package dns_config +package dns_config_test import ( + "bytes" "context" + "encoding/json" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" openapiclient "github.com/infobloxopen/bloxone-go-client/dns_config" "github.com/infobloxopen/bloxone-go-client/internal" ) -func Test_dns_config_DelegationAPIService(t *testing.T) { +var ConfigDelegationPost = openapiclient.ConfigDelegation{ + Id: openapiclient.PtrString("ConfigDelegationPost"), + Comment: nil, + DelegationServers: nil, + Disabled: nil, + Fqdn: nil, + Parent: nil, + ProtocolFqdn: nil, + Tags: make(map[string]interface{}), + View: nil, +} +var ConfigDelegationPatch = openapiclient.ConfigDelegation{ + Id: openapiclient.PtrString("ConfigDelegationPatch"), + Comment: nil, + DelegationServers: nil, + Disabled: nil, + Fqdn: nil, + Parent: nil, + ProtocolFqdn: nil, + Tags: make(map[string]interface{}), + View: nil, +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestDelegationAPIService(t *testing.T) { t.Run("Test DelegationAPIService DelegationCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.DelegationAPI.DelegationCreate(context.Background()).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dns/delegation", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.ConfigDelegation + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigDelegationPost, reqBody) + + response := openapiclient.ConfigCreateDelegationResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.DelegationAPI.DelegationCreate(context.Background()).Body(ConfigDelegationPost).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test DelegationAPIService DelegationDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.DelegationAPI.DelegationDelete(context.Background(), id).Execute() - - require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test DelegationAPIService DelegationList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/delegation", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigListDelegationResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.DelegationAPI.DelegationList(context.Background()).Execute() - require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test DelegationAPIService DelegationRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.DelegationAPI.DelegationRead(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/delegation/"+*ConfigDelegationPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigReadDelegationResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.DelegationAPI.DelegationRead(context.Background(), *ConfigDelegationPost.Id).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test DelegationAPIService DelegationUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.DelegationAPI.DelegationUpdate(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dns/delegation/"+*ConfigDelegationPatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + var reqBody openapiclient.ConfigDelegation + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigDelegationPatch, reqBody) + + response := openapiclient.ConfigUpdateDelegationResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.DelegationAPI.DelegationUpdate(context.Background(), *ConfigDelegationPatch.Id).Body(ConfigDelegationPatch).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) + require.Equal(t, http.StatusOK, httpRes.StatusCode) + }) + t.Run("Test DelegationAPIService DelegationDelete", func(t *testing.T) { + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/dns/delegation/"+*ConfigDelegationPost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.DelegationAPI.DelegationDelete(context.Background(), *ConfigDelegationPost.Id).Execute() + require.Nil(t, err) + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) } diff --git a/dns_config/test/api_forward_nsg_test.go b/dns_config/test/api_forward_nsg_test.go index 8d9ac14..f98b055 100644 --- a/dns_config/test/api_forward_nsg_test.go +++ b/dns_config/test/api_forward_nsg_test.go @@ -5,89 +5,167 @@ Testing ForwardNsgAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package dns_config +package dns_config_test import ( + "bytes" "context" + "encoding/json" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" openapiclient "github.com/infobloxopen/bloxone-go-client/dns_config" "github.com/infobloxopen/bloxone-go-client/internal" ) -func Test_dns_config_ForwardNsgAPIService(t *testing.T) { +var ConfigForwardNSGPost = openapiclient.ConfigForwardNSG{ + Id: openapiclient.PtrString("ConfigForwardNSGPost"), + Comment: nil, + ExternalForwarders: nil, + ForwardersOnly: nil, + Hosts: nil, + InternalForwarders: nil, + Name: "", + Nsgs: nil, + Tags: make(map[string]interface{}), +} +var ConfigForwardNSGPatch = openapiclient.ConfigForwardNSG{ + Id: openapiclient.PtrString("ConfigForwardNSGPatch"), + Comment: nil, + ExternalForwarders: nil, + ForwardersOnly: nil, + Hosts: nil, + InternalForwarders: nil, + Name: "", + Nsgs: nil, + Tags: make(map[string]interface{}), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestForwardNsgAPIService(t *testing.T) { t.Run("Test ForwardNsgAPIService ForwardNsgCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.ForwardNsgAPI.ForwardNsgCreate(context.Background()).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dns/forward_nsg", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.ConfigForwardNSG + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigForwardNSGPost, reqBody) + + response := openapiclient.ConfigCreateForwardNSGResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.ForwardNsgAPI.ForwardNsgCreate(context.Background()).Body(ConfigForwardNSGPost).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test ForwardNsgAPIService ForwardNsgDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.ForwardNsgAPI.ForwardNsgDelete(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/dns/forward_nsg/"+*ConfigForwardNSGPost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.ForwardNsgAPI.ForwardNsgDelete(context.Background(), *ConfigForwardNSGPost.Id).Execute() require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test ForwardNsgAPIService ForwardNsgList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/forward_nsg", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigListForwardNSGResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.ForwardNsgAPI.ForwardNsgList(context.Background()).Execute() - require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test ForwardNsgAPIService ForwardNsgRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.ForwardNsgAPI.ForwardNsgRead(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/forward_nsg/"+*ConfigForwardNSGPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigReadForwardNSGResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.ForwardNsgAPI.ForwardNsgRead(context.Background(), *ConfigForwardNSGPost.Id).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test ForwardNsgAPIService ForwardNsgUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.ForwardNsgAPI.ForwardNsgUpdate(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dns/forward_nsg/"+*ConfigForwardNSGPatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.ConfigForwardNSG + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigForwardNSGPatch, reqBody) + + response := openapiclient.ConfigUpdateForwardNSGResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.ForwardNsgAPI.ForwardNsgUpdate(context.Background(), *ConfigForwardNSGPatch.Id).Body(ConfigForwardNSGPatch).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) } diff --git a/dns_config/test/api_forward_zone_test.go b/dns_config/test/api_forward_zone_test.go index 683d1cd..32be5a7 100644 --- a/dns_config/test/api_forward_zone_test.go +++ b/dns_config/test/api_forward_zone_test.go @@ -5,101 +5,225 @@ Testing ForwardZoneAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package dns_config +package dns_config_test import ( + "bytes" "context" + "encoding/json" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" openapiclient "github.com/infobloxopen/bloxone-go-client/dns_config" "github.com/infobloxopen/bloxone-go-client/internal" ) -func Test_dns_config_ForwardZoneAPIService(t *testing.T) { - - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) - - t.Run("Test ForwardZoneAPIService ForwardZoneCopy", func(t *testing.T) { +var ConfigCopyForwardZonePost = openapiclient.ConfigCopyForwardZone{ + Id: openapiclient.PtrString("ConfigCopyForwardZonePost"), + Comment: nil, + ExternalForwarders: nil, + Hosts: nil, + InternalForwarders: nil, + Nsgs: nil, + Recursive: nil, + SkipOnError: nil, + TargetView: "", +} +var ConfigForwardZonePost = openapiclient.ConfigForwardZone{ + Id: openapiclient.PtrString("ConfigForwardZonePost"), + Comment: nil, + CreatedAt: nil, + Disabled: nil, + ExternalForwarders: nil, + ForwardOnly: nil, + Fqdn: nil, + Hosts: nil, + InternalForwarders: nil, + MappedSubnet: nil, + Mapping: nil, + Nsgs: nil, + Parent: nil, + ProtocolFqdn: nil, + Tags: make(map[string]interface{}), + UpdatedAt: nil, + View: nil, + Warnings: nil, +} - t.Skip("skip test") // remove to run test +var ConfigForwardZonePatch = openapiclient.ConfigForwardZone{ + Id: openapiclient.PtrString("ConfigForwardZonePatch"), + Comment: nil, + CreatedAt: nil, + Disabled: nil, + ExternalForwarders: nil, + ForwardOnly: nil, + Fqdn: nil, + Hosts: nil, + InternalForwarders: nil, + MappedSubnet: nil, + Mapping: nil, + Nsgs: nil, + Parent: nil, + ProtocolFqdn: nil, + Tags: make(map[string]interface{}), + UpdatedAt: nil, + View: nil, + Warnings: nil, +} - resp, httpRes, err := apiClient.ForwardZoneAPI.ForwardZoneCopy(context.Background()).Execute() +func TestForwardZoneAPIService(t *testing.T) { + t.Run("Test ForwardZoneAPIService ForwardZoneCopy", func(t *testing.T) { + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dns/forward_zone/copy", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.ConfigCopyForwardZone + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigCopyForwardZonePost, reqBody) + + response := openapiclient.ConfigCopyForwardZoneResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.ForwardZoneAPI.ForwardZoneCopy(context.Background()).Body(ConfigCopyForwardZonePost).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test ForwardZoneAPIService ForwardZoneCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.ForwardZoneAPI.ForwardZoneCreate(context.Background()).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dns/forward_zone", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.ConfigForwardZone + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigForwardZonePost, reqBody) + + response := openapiclient.ConfigCreateForwardZoneResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.ForwardZoneAPI.ForwardZoneCreate(context.Background()).Body(ConfigForwardZonePost).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test ForwardZoneAPIService ForwardZoneDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.ForwardZoneAPI.ForwardZoneDelete(context.Background(), id).Execute() - - require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test ForwardZoneAPIService ForwardZoneList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/forward_zone", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigListForwardZoneResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.ForwardZoneAPI.ForwardZoneList(context.Background()).Execute() - require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test ForwardZoneAPIService ForwardZoneRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.ForwardZoneAPI.ForwardZoneRead(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/forward_zone/"+*ConfigForwardZonePost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigReadForwardZoneResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.ForwardZoneAPI.ForwardZoneRead(context.Background(), *ConfigForwardZonePost.Id).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test ForwardZoneAPIService ForwardZoneUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.ForwardZoneAPI.ForwardZoneUpdate(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dns/forward_zone/"+*ConfigForwardZonePatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + var reqBody openapiclient.ConfigForwardZone + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigForwardZonePatch, reqBody) + + response := openapiclient.ConfigUpdateForwardZoneResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.ForwardZoneAPI.ForwardZoneUpdate(context.Background(), *ConfigForwardZonePatch.Id).Body(ConfigForwardZonePatch).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) + require.Equal(t, http.StatusOK, httpRes.StatusCode) + }) + t.Run("Test ForwardZoneAPIService ForwardZoneDelete", func(t *testing.T) { + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/dns/forward_zone/"+*ConfigForwardZonePost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.ForwardZoneAPI.ForwardZoneDelete(context.Background(), *ConfigForwardZonePost.Id).Execute() + require.Nil(t, err) + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) } diff --git a/dns_config/test/api_global_test.go b/dns_config/test/api_global_test.go index e114660..1a5f682 100644 --- a/dns_config/test/api_global_test.go +++ b/dns_config/test/api_global_test.go @@ -5,76 +5,133 @@ Testing GlobalAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package dns_config +package dns_config_test import ( + "bytes" "context" + "encoding/json" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" openapiclient "github.com/infobloxopen/bloxone-go-client/dns_config" "github.com/infobloxopen/bloxone-go-client/internal" ) -func Test_dns_config_GlobalAPIService(t *testing.T) { +var ConfigGlobalPatch = openapiclient.ConfigGlobal{ + Id: "Patch1", +} +var ConfigGlobalPatch2 = openapiclient.ConfigGlobal{ + Id: "Patch2", +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestGlobalAPIService(t *testing.T) { t.Run("Test GlobalAPIService GlobalRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/global", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigReadGlobalResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.GlobalAPI.GlobalRead(context.Background()).Execute() - require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test GlobalAPIService GlobalRead2", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.GlobalAPI.GlobalRead2(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/global/"+ConfigGlobalPatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigReadGlobalResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.GlobalAPI.GlobalRead2(context.Background(), ConfigGlobalPatch.Id).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test GlobalAPIService GlobalUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.GlobalAPI.GlobalUpdate(context.Background()).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dns/global", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.ConfigGlobal + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigGlobalPatch, reqBody) + + response := openapiclient.ConfigUpdateGlobalResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.GlobalAPI.GlobalUpdate(context.Background()).Body(ConfigGlobalPatch).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test GlobalAPIService GlobalUpdate2", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.GlobalAPI.GlobalUpdate2(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dns/global/"+ConfigGlobalPatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.ConfigGlobal + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigGlobalPatch2, reqBody) + + response := openapiclient.ConfigUpdateGlobalResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.GlobalAPI.GlobalUpdate2(context.Background(), ConfigGlobalPatch.Id).Body(ConfigGlobalPatch2).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) } diff --git a/dns_config/test/api_host_test.go b/dns_config/test/api_host_test.go index 8965b8e..672f427 100644 --- a/dns_config/test/api_host_test.go +++ b/dns_config/test/api_host_test.go @@ -5,64 +5,103 @@ Testing HostAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package dns_config +package dns_config_test import ( + "bytes" "context" + "encoding/json" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" openapiclient "github.com/infobloxopen/bloxone-go-client/dns_config" "github.com/infobloxopen/bloxone-go-client/internal" ) -func Test_dns_config_HostAPIService(t *testing.T) { +var ConfigHostPatch = openapiclient.ConfigHost{ + Id: openapiclient.PtrString("ConfigHostPatch"), + Tags: make(map[string]interface{}), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestHostAPIService(t *testing.T) { t.Run("Test HostAPIService HostList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/host", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigListHostResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.HostAPI.HostList(context.Background()).Execute() - require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test HostAPIService HostRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.HostAPI.HostRead(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/host/"+*ConfigHostPatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigReadHostResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.HostAPI.HostRead(context.Background(), *ConfigHostPatch.Id).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test HostAPIService HostUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.HostAPI.HostUpdate(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dns/host/"+*ConfigHostPatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.ConfigHost + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigHostPatch, reqBody) + + response := openapiclient.ConfigUpdateHostResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.HostAPI.HostUpdate(context.Background(), *ConfigHostPatch.Id).Body(ConfigHostPatch).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) } diff --git a/dns_config/test/api_lbdn_test.go b/dns_config/test/api_lbdn_test.go index 6433b4a..54e6336 100644 --- a/dns_config/test/api_lbdn_test.go +++ b/dns_config/test/api_lbdn_test.go @@ -5,89 +5,153 @@ Testing LbdnAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package dns_config +package dns_config_test import ( + "bytes" "context" + "encoding/json" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" openapiclient "github.com/infobloxopen/bloxone-go-client/dns_config" "github.com/infobloxopen/bloxone-go-client/internal" ) -func Test_dns_config_LbdnAPIService(t *testing.T) { +var ConfigLBDNPost = openapiclient.ConfigLBDN{ + Id: openapiclient.PtrString("ConfigLBDNPost"), + Tags: make(map[string]interface{}), +} +var ConfigLBDNPatch = openapiclient.ConfigLBDN{ + Id: openapiclient.PtrString("ConfigLBDNPatch"), + Tags: make(map[string]interface{}), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestLbdnAPIService(t *testing.T) { t.Run("Test LbdnAPIService LbdnCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.LbdnAPI.LbdnCreate(context.Background()).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dtc/lbdn", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.ConfigLBDN + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigLBDNPost, reqBody) + + response := openapiclient.ConfigCreateLBDNResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.LbdnAPI.LbdnCreate(context.Background()).Body(ConfigLBDNPost).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test LbdnAPIService LbdnDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.LbdnAPI.LbdnDelete(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/dtc/lbdn/"+*ConfigLBDNPost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.LbdnAPI.LbdnDelete(context.Background(), *ConfigLBDNPost.Id).Execute() require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test LbdnAPIService LbdnList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dtc/lbdn", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigListLBDNResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.LbdnAPI.LbdnList(context.Background()).Execute() - require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test LbdnAPIService LbdnRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.LbdnAPI.LbdnRead(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dtc/lbdn/"+*ConfigLBDNPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigReadLBDNResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.LbdnAPI.LbdnRead(context.Background(), *ConfigLBDNPost.Id).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test LbdnAPIService LbdnUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.LbdnAPI.LbdnUpdate(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dtc/lbdn/"+*ConfigLBDNPatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.ConfigLBDN + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigLBDNPatch, reqBody) + + response := openapiclient.ConfigUpdateLBDNResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.LbdnAPI.LbdnUpdate(context.Background(), *ConfigLBDNPatch.Id).Body(ConfigLBDNPatch).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) } diff --git a/dns_config/test/api_server_test.go b/dns_config/test/api_server_test.go index 485d79f..79d6824 100644 --- a/dns_config/test/api_server_test.go +++ b/dns_config/test/api_server_test.go @@ -5,89 +5,153 @@ Testing ServerAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package dns_config +package dns_config_test import ( + "bytes" "context" + "encoding/json" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" openapiclient "github.com/infobloxopen/bloxone-go-client/dns_config" "github.com/infobloxopen/bloxone-go-client/internal" ) -func Test_dns_config_ServerAPIService(t *testing.T) { +var ConfigServerPost = openapiclient.ConfigServer{ + Id: openapiclient.PtrString("ConfigServerPost"), + Tags: make(map[string]interface{}), +} +var ConfigServerPatch = openapiclient.ConfigServer{ + Id: openapiclient.PtrString("ConfigServerPatch"), + Tags: make(map[string]interface{}), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestServerAPIService(t *testing.T) { t.Run("Test ServerAPIService ServerCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.ServerAPI.ServerCreate(context.Background()).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dns/server", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.ConfigServer + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigServerPost, reqBody) + + response := openapiclient.ConfigCreateServerResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.ServerAPI.ServerCreate(context.Background()).Body(ConfigServerPost).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test ServerAPIService ServerDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.ServerAPI.ServerDelete(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/dns/server/"+*ConfigServerPost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.ServerAPI.ServerDelete(context.Background(), *ConfigServerPost.Id).Execute() require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test ServerAPIService ServerList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/server", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigListServerResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.ServerAPI.ServerList(context.Background()).Execute() - require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test ServerAPIService ServerRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.ServerAPI.ServerRead(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/server/"+*ConfigServerPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigReadServerResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.ServerAPI.ServerRead(context.Background(), *ConfigServerPost.Id).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test ServerAPIService ServerUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.ServerAPI.ServerUpdate(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dns/server/"+*ConfigServerPatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.ConfigServer + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigServerPatch, reqBody) + + response := openapiclient.ConfigUpdateServerResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.ServerAPI.ServerUpdate(context.Background(), *ConfigServerPatch.Id).Body(ConfigServerPatch).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) } diff --git a/dns_config/test/api_view_test.go b/dns_config/test/api_view_test.go index 47b4c37..9c97050 100644 --- a/dns_config/test/api_view_test.go +++ b/dns_config/test/api_view_test.go @@ -5,101 +5,190 @@ Testing ViewAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package dns_config +package dns_config_test import ( + "bytes" "context" + "encoding/json" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" openapiclient "github.com/infobloxopen/bloxone-go-client/dns_config" "github.com/infobloxopen/bloxone-go-client/internal" ) -func Test_dns_config_ViewAPIService(t *testing.T) { +var ConfigBulkCopyViewPost = openapiclient.ConfigBulkCopyView{ + AuthZoneConfig: nil, + ForwardZoneConfig: nil, + Recursive: nil, + Resources: nil, + SecondaryZoneConfig: nil, + SkipOnError: nil, + Target: "TargetPost", +} +var ConfigViewPost = openapiclient.ConfigView{ + Id: openapiclient.PtrString("ConfigViewPost"), + Tags: make(map[string]interface{}), +} +var ConfigViewPatch = openapiclient.ConfigView{ + Id: openapiclient.PtrString("ConfigViewPatch"), + Tags: make(map[string]interface{}), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestViewAPIService(t *testing.T) { t.Run("Test ViewAPIService ViewBulkCopy", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.ViewAPI.ViewBulkCopy(context.Background()).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dns/view/bulk_copy", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.ConfigBulkCopyView + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigBulkCopyViewPost, reqBody) + + response := openapiclient.ConfigBulkCopyResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.ViewAPI.ViewBulkCopy(context.Background()).Body(ConfigBulkCopyViewPost).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test ViewAPIService ViewCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.ViewAPI.ViewCreate(context.Background()).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dns/view", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.ConfigView + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigViewPost, reqBody) + + response := openapiclient.ConfigCreateViewResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.ViewAPI.ViewCreate(context.Background()).Body(ConfigViewPost).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test ViewAPIService ViewDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.ViewAPI.ViewDelete(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/dns/view/"+*ConfigViewPost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.ViewAPI.ViewDelete(context.Background(), *ConfigViewPost.Id).Execute() require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test ViewAPIService ViewList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/view", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigListViewResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.ViewAPI.ViewList(context.Background()).Execute() - require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test ViewAPIService ViewRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.ViewAPI.ViewRead(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/view/"+*ConfigViewPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.ConfigReadViewResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.ViewAPI.ViewRead(context.Background(), *ConfigViewPost.Id).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test ViewAPIService ViewUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.ViewAPI.ViewUpdate(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dns/view/"+*ConfigViewPatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.ConfigView + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, ConfigViewPatch, reqBody) + + response := openapiclient.ConfigUpdateViewResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.ViewAPI.ViewUpdate(context.Background(), *ConfigViewPatch.Id).Body(ConfigViewPatch).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) } diff --git a/dns_data/test/api_record_test.go b/dns_data/test/api_record_test.go index 8d3ff42..20e2a41 100644 --- a/dns_data/test/api_record_test.go +++ b/dns_data/test/api_record_test.go @@ -5,103 +5,185 @@ Testing RecordAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package dns_data +package dns_data_test import ( + "bytes" "context" + "encoding/json" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" openapiclient "github.com/infobloxopen/bloxone-go-client/dns_data" "github.com/infobloxopen/bloxone-go-client/internal" ) -func Test_dns_data_RecordAPIService(t *testing.T) { +var DataRecordPost = openapiclient.DataRecord{ + Id: openapiclient.PtrString("DataRecordPost"), + Tags: make(map[string]interface{}), +} +var DataSOASerialIncrementRequestPost = openapiclient.DataSOASerialIncrementRequest{ + Id: openapiclient.PtrString("IncrementRequest"), +} +var DataRecordPatch = openapiclient.DataRecord{ + Id: openapiclient.PtrString("DataRecordPatch"), + Tags: make(map[string]interface{}), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestRecordAPIService(t *testing.T) { t.Run("Test RecordAPIService RecordCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.RecordAPI.RecordCreate(context.Background()).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dns/record", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.DataRecord + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, DataRecordPost.Id, reqBody.Id) + require.Equal(t, DataRecordPost.Tags, reqBody.Tags) + + response := openapiclient.DataCreateRecordResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.RecordAPI.RecordCreate(context.Background()).Body(DataRecordPost).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test RecordAPIService RecordDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.RecordAPI.RecordDelete(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/dns/record/"+*DataRecordPost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.RecordAPI.RecordDelete(context.Background(), *DataRecordPost.Id).Execute() require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test RecordAPIService RecordList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/record", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.DataListRecordResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.RecordAPI.RecordList(context.Background()).Execute() - require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test RecordAPIService RecordRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.RecordAPI.RecordRead(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dns/record/"+*DataRecordPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.DataReadRecordResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.RecordAPI.RecordRead(context.Background(), *DataRecordPost.Id).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test RecordAPIService RecordSOASerialIncrement", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.RecordAPI.RecordSOASerialIncrement(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dns/record/"+*DataSOASerialIncrementRequestPost.Id+"/serial_increment", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.DataSOASerialIncrementRequest + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, DataSOASerialIncrementRequestPost, reqBody) + + response := openapiclient.DataSOASerialIncrementResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.RecordAPI.RecordSOASerialIncrement(context.Background(), *DataSOASerialIncrementRequestPost.Id).Body(DataSOASerialIncrementRequestPost).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test RecordAPIService RecordUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.RecordAPI.RecordUpdate(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dns/record/"+*DataRecordPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.DataRecord + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, DataRecordPatch, reqBody) + + response := openapiclient.DataUpdateRecordResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.RecordAPI.RecordUpdate(context.Background(), *DataRecordPost.Id).Body(DataRecordPatch).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) } diff --git a/infra_mgmt/test/api_detail_test.go b/infra_mgmt/test/api_detail_test.go deleted file mode 100644 index c78318d..0000000 --- a/infra_mgmt/test/api_detail_test.go +++ /dev/null @@ -1,52 +0,0 @@ -/* -Infrastructure Management API - -Testing DetailAPIService - -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package infra_mgmt - -import ( - "context" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - openapiclient "github.com/infobloxopen/bloxone-go-client/infra_mgmt" - "github.com/infobloxopen/bloxone-go-client/internal" -) - -func Test_infra_mgmt_DetailAPIService(t *testing.T) { - - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) - - t.Run("Test DetailAPIService DetailHostsList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.DetailAPI.DetailHostsList(context.Background()).Execute() - - require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test DetailAPIService DetailServicesList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.DetailAPI.DetailServicesList(context.Background()).Execute() - - require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - -} diff --git a/infra_mgmt/test/api_hosts_test.go b/infra_mgmt/test/api_hosts_test.go deleted file mode 100644 index f215a66..0000000 --- a/infra_mgmt/test/api_hosts_test.go +++ /dev/null @@ -1,146 +0,0 @@ -/* -Infrastructure Management API - -Testing HostsAPIService - -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package infra_mgmt - -import ( - "context" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - openapiclient "github.com/infobloxopen/bloxone-go-client/infra_mgmt" - "github.com/infobloxopen/bloxone-go-client/internal" -) - -func Test_infra_mgmt_HostsAPIService(t *testing.T) { - - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) - - t.Run("Test HostsAPIService HostsAssignTags", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.HostsAPI.HostsAssignTags(context.Background()).Execute() - - require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test HostsAPIService HostsCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.HostsAPI.HostsCreate(context.Background()).Execute() - - require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test HostsAPIService HostsDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.HostsAPI.HostsDelete(context.Background(), id).Execute() - - require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test HostsAPIService HostsDisconnect", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.HostsAPI.HostsDisconnect(context.Background(), id).Execute() - - require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test HostsAPIService HostsList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.HostsAPI.HostsList(context.Background()).Execute() - - require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test HostsAPIService HostsRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.HostsAPI.HostsRead(context.Background(), id).Execute() - - require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test HostsAPIService HostsReplace", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var fromResourceId string - var toResourceId string - - resp, httpRes, err := apiClient.HostsAPI.HostsReplace(context.Background(), fromResourceId, toResourceId).Execute() - - require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test HostsAPIService HostsUnassignTags", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.HostsAPI.HostsUnassignTags(context.Background()).Execute() - - require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test HostsAPIService HostsUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.HostsAPI.HostsUpdate(context.Background(), id).Execute() - - require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - -} diff --git a/infra_mgmt/test/api_services_test.go b/infra_mgmt/test/api_services_test.go deleted file mode 100644 index 1fff76e..0000000 --- a/infra_mgmt/test/api_services_test.go +++ /dev/null @@ -1,105 +0,0 @@ -/* -Infrastructure Management API - -Testing ServicesAPIService - -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package infra_mgmt - -import ( - "context" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - openapiclient "github.com/infobloxopen/bloxone-go-client/infra_mgmt" - "github.com/infobloxopen/bloxone-go-client/internal" -) - -func Test_infra_mgmt_ServicesAPIService(t *testing.T) { - - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) - - t.Run("Test ServicesAPIService ServicesApplications", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.ServicesAPI.ServicesApplications(context.Background()).Execute() - - require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test ServicesAPIService ServicesCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.ServicesAPI.ServicesCreate(context.Background()).Execute() - - require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test ServicesAPIService ServicesDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.ServicesAPI.ServicesDelete(context.Background(), id).Execute() - - require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test ServicesAPIService ServicesList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.ServicesAPI.ServicesList(context.Background()).Execute() - - require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test ServicesAPIService ServicesRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.ServicesAPI.ServicesRead(context.Background(), id).Execute() - - require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test ServicesAPIService ServicesUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.ServicesAPI.ServicesUpdate(context.Background(), id).Execute() - - require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - - }) - -} diff --git a/internal/utils.go b/internal/utils.go index 3600f5b..da62760 100644 --- a/internal/utils.go +++ b/internal/utils.go @@ -1,5 +1,19 @@ package internal +import "net/http" + type MappedNullable interface { ToMap() (map[string]interface{}, error) } + +type RoundTripFunc func(req *http.Request) *http.Response + +func (f RoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error) { + return f(req), nil +} + +func NewTestClient(testFn RoundTripFunc) *http.Client { + return &http.Client{ + Transport: RoundTripFunc(testFn), + } +} diff --git a/ipam/test/api_address_block_test.go b/ipam/test/api_address_block_test.go index 0894044..e6fbd86 100644 --- a/ipam/test/api_address_block_test.go +++ b/ipam/test/api_address_block_test.go @@ -5,187 +5,322 @@ Testing AddressBlockAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package ipam +package ipam_test import ( + "bytes" "context" + "encoding/json" + "github.com/stretchr/testify/assert" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/ipam" ) -func Test_ipam_AddressBlockAPIService(t *testing.T) { - - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) - - t.Run("Test AddressBlockAPIService AddressBlockCopy", func(t *testing.T) { - - t.Skip("skip test") // remove to run test +var cidrValue int64 = 34 - var id string +var IpamsvcCopyAddressBlockPost = openapiclient.IpamsvcCopyAddressBlock{ + Id: openapiclient.PtrString("Test Copy"), +} +var IpamsvcAddressBlockPost = openapiclient.IpamsvcAddressBlock{ + Id: openapiclient.PtrString("Test Create"), + Cidr: &cidrValue, + Tags: make(map[string]interface{}), +} +var IpamsvcAddressBlockPatch = openapiclient.IpamsvcAddressBlock{ + Id: openapiclient.PtrString("Test Update"), + Cidr: &cidrValue, + Tags: make(map[string]interface{}), +} - resp, httpRes, err := apiClient.AddressBlockAPI.AddressBlockCopy(context.Background(), id).Execute() +func TestAddressBlockAPIService(t *testing.T) { - require.Nil(t, err) + t.Run("Test AddressBlockAPIService AddressBlockCopy", func(t *testing.T) { + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/address_block/"+*IpamsvcCopyAddressBlockPost.Id+"/copy", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcCopyAddressBlock + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcCopyAddressBlockPost, reqBody) + + response := openapiclient.IpamsvcCopyAddressBlockResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AddressBlockAPI.AddressBlockCopy(context.Background(), *IpamsvcCopyAddressBlockPost.Id).Body(IpamsvcCopyAddressBlockPost).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - t.Run("Test AddressBlockAPIService AddressBlockCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.AddressBlockAPI.AddressBlockCreate(context.Background()).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/address_block", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcAddressBlock + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcAddressBlockPost, reqBody) + + response := openapiclient.IpamsvcCreateAddressBlockResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AddressBlockAPI.AddressBlockCreate(context.Background()).Body(IpamsvcAddressBlockPost).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - t.Run("Test AddressBlockAPIService AddressBlockCreateNextAvailableAB", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.AddressBlockAPI.AddressBlockCreateNextAvailableAB(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/address_block/"+*IpamsvcAddressBlockPost.Id+"/nextavailableaddressblock", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcCreateNextAvailableABResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AddressBlockAPI.AddressBlockCreateNextAvailableAB(context.Background(), *IpamsvcAddressBlockPost.Id).Cidr(34).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - t.Run("Test AddressBlockAPIService AddressBlockCreateNextAvailableIP", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.AddressBlockAPI.AddressBlockCreateNextAvailableIP(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/address_block/"+*IpamsvcAddressBlockPost.Id+"/nextavailableip", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcCreateNextAvailableIPResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AddressBlockAPI.AddressBlockCreateNextAvailableIP(context.Background(), *IpamsvcAddressBlockPost.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - t.Run("Test AddressBlockAPIService AddressBlockCreateNextAvailableSubnet", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.AddressBlockAPI.AddressBlockCreateNextAvailableSubnet(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/address_block/"+*IpamsvcAddressBlockPost.Id+"/nextavailablesubnet", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcCreateNextAvailableSubnetResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AddressBlockAPI.AddressBlockCreateNextAvailableSubnet(context.Background(), *IpamsvcAddressBlockPost.Id).Cidr(34).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - t.Run("Test AddressBlockAPIService AddressBlockDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.AddressBlockAPI.AddressBlockDelete(context.Background(), id).Execute() - - require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/address_block/"+*IpamsvcAddressBlockPost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.AddressBlockAPI.AddressBlockDelete(context.Background(), *IpamsvcAddressBlockPost.Id).Execute() + require.NoError(t, err) + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - t.Run("Test AddressBlockAPIService AddressBlockList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/address_block", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcListAddressBlockResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.AddressBlockAPI.AddressBlockList(context.Background()).Execute() - - require.Nil(t, err) + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - t.Run("Test AddressBlockAPIService AddressBlockListNextAvailableAB", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.AddressBlockAPI.AddressBlockListNextAvailableAB(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/address_block/"+*IpamsvcAddressBlockPost.Id+"/nextavailableaddressblock", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcNextAvailableABResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AddressBlockAPI.AddressBlockListNextAvailableAB(context.Background(), *IpamsvcAddressBlockPost.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test AddressBlockAPIService AddressBlockListNextAvailableIP", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.AddressBlockAPI.AddressBlockListNextAvailableIP(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/address_block/"+*IpamsvcAddressBlockPost.Id+"/nextavailableip", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcNextAvailableIPResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AddressBlockAPI.AddressBlockListNextAvailableIP(context.Background(), *IpamsvcAddressBlockPost.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - t.Run("Test AddressBlockAPIService AddressBlockListNextAvailableSubnet", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.AddressBlockAPI.AddressBlockListNextAvailableSubnet(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/address_block/"+*IpamsvcAddressBlockPost.Id+"/nextavailablesubnet", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcNextAvailableSubnetResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AddressBlockAPI.AddressBlockListNextAvailableSubnet(context.Background(), *IpamsvcAddressBlockPost.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - t.Run("Test AddressBlockAPIService AddressBlockRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.AddressBlockAPI.AddressBlockRead(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/address_block/"+*IpamsvcAddressBlockPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcReadAddressBlockResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AddressBlockAPI.AddressBlockRead(context.Background(), *IpamsvcAddressBlockPost.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - t.Run("Test AddressBlockAPIService AddressBlockUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.AddressBlockAPI.AddressBlockUpdate(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/address_block/"+*IpamsvcAddressBlockPatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcAddressBlock + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcAddressBlockPatch, reqBody) + + response := openapiclient.IpamsvcUpdateAddressBlockResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AddressBlockAPI.AddressBlockUpdate(context.Background(), *IpamsvcAddressBlockPatch.Id).Body(IpamsvcAddressBlockPatch).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - } diff --git a/ipam/test/api_address_test.go b/ipam/test/api_address_test.go index c1209ae..66382d6 100644 --- a/ipam/test/api_address_test.go +++ b/ipam/test/api_address_test.go @@ -5,89 +5,153 @@ Testing AddressAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package ipam +package ipam_test import ( + "bytes" "context" + "encoding/json" + "github.com/stretchr/testify/assert" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/ipam" ) -func Test_ipam_AddressAPIService(t *testing.T) { +var IpamsvcAddressPost = openapiclient.IpamsvcAddress{ + Id: openapiclient.PtrString("Test Create"), + Tags: make(map[string]interface{}), +} +var IpamsvcAddressPatch = openapiclient.IpamsvcAddress{ + Id: openapiclient.PtrString("Test Update"), + Tags: make(map[string]interface{}), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestAddressAPIService(t *testing.T) { t.Run("Test AddressAPIService AddressCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.AddressAPI.AddressCreate(context.Background()).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/address", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcAddress + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcAddressPost, reqBody) + + response := openapiclient.IpamsvcCreateAddressResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AddressAPI.AddressCreate(context.Background()).Body(IpamsvcAddressPost).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test AddressAPIService AddressDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.AddressAPI.AddressDelete(context.Background(), id).Execute() - - require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/address/"+*IpamsvcAddressPost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.AddressAPI.AddressDelete(context.Background(), *IpamsvcAddressPost.Id).Execute() + require.NoError(t, err) + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test AddressAPIService AddressList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/address", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcListAddressResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.AddressAPI.AddressList(context.Background()).Execute() - - require.Nil(t, err) + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test AddressAPIService AddressRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.AddressAPI.AddressRead(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/address/"+*IpamsvcAddressPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcReadAddressResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AddressAPI.AddressRead(context.Background(), *IpamsvcAddressPost.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test AddressAPIService AddressUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.AddressAPI.AddressUpdate(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/address/"+*IpamsvcAddressPatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcAddress + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcAddressPatch, reqBody) + + response := openapiclient.IpamsvcUpdateAddressResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AddressAPI.AddressUpdate(context.Background(), *IpamsvcAddressPatch.Id).Body(IpamsvcAddressPatch).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - } diff --git a/ipam/test/api_asm_test.go b/ipam/test/api_asm_test.go index d69768e..63e4f1d 100644 --- a/ipam/test/api_asm_test.go +++ b/ipam/test/api_asm_test.go @@ -5,62 +5,100 @@ Testing AsmAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package ipam +package ipam_test import ( + "bytes" "context" + "encoding/json" + "github.com/stretchr/testify/assert" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/ipam" ) -func Test_ipam_AsmAPIService(t *testing.T) { +var IpamsvcASMPost = openapiclient.IpamsvcASM{ + Id: openapiclient.PtrString("Test Create"), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestAsmAPIService(t *testing.T) { t.Run("Test AsmAPIService AsmCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.AsmAPI.AsmCreate(context.Background()).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/asm", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcASM + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcASMPost, reqBody) + + response := openapiclient.IpamsvcCreateASMResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AsmAPI.AsmCreate(context.Background()).Body(IpamsvcASMPost).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - t.Run("Test AsmAPIService AsmList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/asm", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcListASMResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.AsmAPI.AsmList(context.Background()).Execute() - - require.Nil(t, err) + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - t.Run("Test AsmAPIService AsmRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.AsmAPI.AsmRead(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/asm/"+*IpamsvcASMPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcReadASMResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.AsmAPI.AsmRead(context.Background(), *IpamsvcASMPost.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - } diff --git a/ipam/test/api_dhcp_host_test.go b/ipam/test/api_dhcp_host_test.go index 254c69c..5c294a2 100644 --- a/ipam/test/api_dhcp_host_test.go +++ b/ipam/test/api_dhcp_host_test.go @@ -5,78 +5,127 @@ Testing DhcpHostAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package ipam +package ipam_test import ( + "bytes" "context" + "encoding/json" + "github.com/stretchr/testify/assert" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/ipam" ) -func Test_ipam_DhcpHostAPIService(t *testing.T) { +var IpamsvcHostPatch = openapiclient.IpamsvcHost{ + Id: openapiclient.PtrString("Test"), + Tags: make(map[string]interface{}), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestDhcpHostAPIService(t *testing.T) { t.Run("Test DhcpHostAPIService DhcpHostList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/host", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcListHostResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.DhcpHostAPI.DhcpHostList(context.Background()).Execute() - - require.Nil(t, err) + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test DhcpHostAPIService DhcpHostListAssociations", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.DhcpHostAPI.DhcpHostListAssociations(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/host/"+*IpamsvcHostPatch.Id+"/associations", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcHostAssociationsResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.DhcpHostAPI.DhcpHostListAssociations(context.Background(), *IpamsvcHostPatch.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test DhcpHostAPIService DhcpHostRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.DhcpHostAPI.DhcpHostRead(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/host/"+*IpamsvcHostPatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcReadHostResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.DhcpHostAPI.DhcpHostRead(context.Background(), *IpamsvcHostPatch.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test DhcpHostAPIService DhcpHostUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.DhcpHostAPI.DhcpHostUpdate(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/host/"+*IpamsvcHostPatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcHost + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcHostPatch, reqBody) + + response := openapiclient.IpamsvcUpdateHostResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.DhcpHostAPI.DhcpHostUpdate(context.Background(), *IpamsvcHostPatch.Id).Body(IpamsvcHostPatch).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - } diff --git a/ipam/test/api_dns_usage_test.go b/ipam/test/api_dns_usage_test.go index f26257e..18ec09d 100644 --- a/ipam/test/api_dns_usage_test.go +++ b/ipam/test/api_dns_usage_test.go @@ -5,50 +5,75 @@ Testing DnsUsageAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package ipam +package ipam_test import ( + "bytes" "context" + "encoding/json" + "github.com/stretchr/testify/assert" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/ipam" ) -func Test_ipam_DnsUsageAPIService(t *testing.T) { +var IpamsvcDNSUsage = openapiclient.IpamsvcDNSUsage{ + Id: openapiclient.PtrString("Test"), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestDnsUsageAPIService(t *testing.T) { t.Run("Test DnsUsageAPIService DnsUsageList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/dns_usage", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcListDNSUsageResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.DnsUsageAPI.DnsUsageList(context.Background()).Execute() - - require.Nil(t, err) + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test DnsUsageAPIService DnsUsageRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.DnsUsageAPI.DnsUsageRead(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/dns_usage/"+*IpamsvcDNSUsage.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcReadDNSUsageResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.DnsUsageAPI.DnsUsageRead(context.Background(), *IpamsvcDNSUsage.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) } diff --git a/ipam/test/api_filter_test.go b/ipam/test/api_filter_test.go index 911c411..865bb48 100644 --- a/ipam/test/api_filter_test.go +++ b/ipam/test/api_filter_test.go @@ -5,36 +5,46 @@ Testing FilterAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package ipam +package ipam_test import ( + "bytes" "context" + "encoding/json" + "github.com/stretchr/testify/assert" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/ipam" ) -func Test_ipam_FilterAPIService(t *testing.T) { - - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestFilterAPIService(t *testing.T) { t.Run("Test FilterAPIService FilterList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/filter", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcListFilterResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.FilterAPI.FilterList(context.Background()).Execute() - - require.Nil(t, err) + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - } diff --git a/ipam/test/api_fixed_address_test.go b/ipam/test/api_fixed_address_test.go index 07629f5..a344827 100644 --- a/ipam/test/api_fixed_address_test.go +++ b/ipam/test/api_fixed_address_test.go @@ -5,89 +5,153 @@ Testing FixedAddressAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package ipam +package ipam_test import ( + "bytes" "context" + "encoding/json" + "github.com/stretchr/testify/assert" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/ipam" ) -func Test_ipam_FixedAddressAPIService(t *testing.T) { +var IpamsvcFixedAddressPost = openapiclient.IpamsvcFixedAddress{ + Id: openapiclient.PtrString("Test Create"), + Tags: make(map[string]interface{}), +} +var IpamsvcFixedAddressPatch = openapiclient.IpamsvcFixedAddress{ + Id: openapiclient.PtrString("Test Update"), + Tags: make(map[string]interface{}), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestFixedAddressAPIService(t *testing.T) { t.Run("Test FixedAddressAPIService FixedAddressCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.FixedAddressAPI.FixedAddressCreate(context.Background()).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/fixed_address", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcFixedAddress + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcFixedAddressPost, reqBody) + + response := openapiclient.IpamsvcCreateFixedAddressResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.FixedAddressAPI.FixedAddressCreate(context.Background()).Body(IpamsvcFixedAddressPost).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test FixedAddressAPIService FixedAddressDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.FixedAddressAPI.FixedAddressDelete(context.Background(), id).Execute() - - require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/fixed_address/"+*IpamsvcFixedAddressPost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.FixedAddressAPI.FixedAddressDelete(context.Background(), *IpamsvcFixedAddressPost.Id).Execute() + require.NoError(t, err) + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test FixedAddressAPIService FixedAddressList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/fixed_address", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcListFixedAddressResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.FixedAddressAPI.FixedAddressList(context.Background()).Execute() - - require.Nil(t, err) + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test FixedAddressAPIService FixedAddressRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.FixedAddressAPI.FixedAddressRead(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/fixed_address/"+*IpamsvcFixedAddressPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcReadFixedAddressResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.FixedAddressAPI.FixedAddressRead(context.Background(), *IpamsvcFixedAddressPost.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test FixedAddressAPIService FixedAddressUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.FixedAddressAPI.FixedAddressUpdate(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/fixed_address/"+*IpamsvcFixedAddressPatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcFixedAddress + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcFixedAddressPatch, reqBody) + + response := openapiclient.IpamsvcUpdateFixedAddressResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.FixedAddressAPI.FixedAddressUpdate(context.Background(), *IpamsvcAddressPatch.Id).Body(IpamsvcFixedAddressPatch).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - } diff --git a/ipam/test/api_global_test.go b/ipam/test/api_global_test.go index 481fde3..636e97c 100644 --- a/ipam/test/api_global_test.go +++ b/ipam/test/api_global_test.go @@ -5,76 +5,132 @@ Testing GlobalAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package ipam +package ipam_test import ( + "bytes" "context" + "encoding/json" + "github.com/stretchr/testify/assert" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/ipam" ) -func Test_ipam_GlobalAPIService(t *testing.T) { +var IpamsvcGlobalPatch1 = openapiclient.IpamsvcGlobal{ + Id: openapiclient.PtrString("Test 1"), +} +var IpamsvcGlobalPatch2 = openapiclient.IpamsvcGlobal{ + Id: openapiclient.PtrString("Test 2"), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestGlobalAPIService(t *testing.T) { t.Run("Test GlobalAPIService GlobalRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/global", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcReadGlobalResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.GlobalAPI.GlobalRead(context.Background()).Execute() - - require.Nil(t, err) + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test GlobalAPIService GlobalRead2", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.GlobalAPI.GlobalRead2(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/global/"+*IpamsvcGlobalPatch2.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcReadGlobalResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.GlobalAPI.GlobalRead2(context.Background(), *IpamsvcGlobalPatch2.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - t.Run("Test GlobalAPIService GlobalUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.GlobalAPI.GlobalUpdate(context.Background()).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/global", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcGlobal + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcGlobalPatch1, reqBody) + + response := openapiclient.IpamsvcUpdateGlobalResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.GlobalAPI.GlobalUpdate(context.Background()).Body(IpamsvcGlobalPatch1).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test GlobalAPIService GlobalUpdate2", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.GlobalAPI.GlobalUpdate2(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/global/"+*IpamsvcGlobalPatch2.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcGlobal + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcGlobalPatch2, reqBody) + + response := openapiclient.IpamsvcUpdateGlobalResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.GlobalAPI.GlobalUpdate2(context.Background(), *IpamsvcGlobalPatch2.Id).Body(IpamsvcGlobalPatch2).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - } diff --git a/ipam/test/api_ha_group_test.go b/ipam/test/api_ha_group_test.go index ecbd318..5ead8ec 100644 --- a/ipam/test/api_ha_group_test.go +++ b/ipam/test/api_ha_group_test.go @@ -5,89 +5,153 @@ Testing HaGroupAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package ipam +package ipam_test import ( + "bytes" "context" + "encoding/json" + "github.com/stretchr/testify/assert" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/ipam" ) -func Test_ipam_HaGroupAPIService(t *testing.T) { +var IpamsvcHAGroupPost = openapiclient.IpamsvcHAGroup{ + Id: openapiclient.PtrString("Test Create"), + Tags: make(map[string]interface{}), +} +var IpamsvcHAGroupPatch = openapiclient.IpamsvcHAGroup{ + Id: openapiclient.PtrString("Test Update"), + Tags: make(map[string]interface{}), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestHaGroupAPIService(t *testing.T) { t.Run("Test HaGroupAPIService HaGroupCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.HaGroupAPI.HaGroupCreate(context.Background()).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/ha_group", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcHAGroup + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcHAGroupPost, reqBody) + + response := openapiclient.IpamsvcCreateHAGroupResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.HaGroupAPI.HaGroupCreate(context.Background()).Body(IpamsvcHAGroupPost).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test HaGroupAPIService HaGroupDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.HaGroupAPI.HaGroupDelete(context.Background(), id).Execute() - - require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/ha_group/"+*IpamsvcHAGroupPost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.HaGroupAPI.HaGroupDelete(context.Background(), *IpamsvcHAGroupPost.Id).Execute() + require.NoError(t, err) + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test HaGroupAPIService HaGroupList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/ha_group", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcListHAGroupResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.HaGroupAPI.HaGroupList(context.Background()).Execute() - - require.Nil(t, err) + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test HaGroupAPIService HaGroupRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.HaGroupAPI.HaGroupRead(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/ha_group/"+*IpamsvcHAGroupPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcReadHAGroupResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.HaGroupAPI.HaGroupRead(context.Background(), *IpamsvcHAGroupPost.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test HaGroupAPIService HaGroupUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.HaGroupAPI.HaGroupUpdate(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/ha_group/"+*IpamsvcHAGroupPatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcHAGroup + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcHAGroupPatch, reqBody) + + response := openapiclient.IpamsvcUpdateHAGroupResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.HaGroupAPI.HaGroupUpdate(context.Background(), *IpamsvcHAGroupPatch.Id).Body(IpamsvcHAGroupPatch).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - } diff --git a/ipam/test/api_hardware_filter_test.go b/ipam/test/api_hardware_filter_test.go index 63cac0d..ffbf7d5 100644 --- a/ipam/test/api_hardware_filter_test.go +++ b/ipam/test/api_hardware_filter_test.go @@ -5,89 +5,153 @@ Testing HardwareFilterAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package ipam +package ipam_test import ( + "bytes" "context" + "encoding/json" + "github.com/stretchr/testify/assert" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/ipam" ) -func Test_ipam_HardwareFilterAPIService(t *testing.T) { +var IpamsvcHardwareFilterPost = openapiclient.IpamsvcHardwareFilter{ + Id: openapiclient.PtrString("Test Create"), + Tags: make(map[string]interface{}), +} +var IpamsvcHardwareFilterPatch = openapiclient.IpamsvcHardwareFilter{ + Id: openapiclient.PtrString("Test Update"), + Tags: make(map[string]interface{}), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestHardwareFilterAPIService(t *testing.T) { t.Run("Test HardwareFilterAPIService HardwareFilterCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.HardwareFilterAPI.HardwareFilterCreate(context.Background()).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/hardware_filter", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcHardwareFilter + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcHardwareFilterPost, reqBody) + + response := openapiclient.IpamsvcCreateHardwareFilterResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.HardwareFilterAPI.HardwareFilterCreate(context.Background()).Body(IpamsvcHardwareFilterPost).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test HardwareFilterAPIService HardwareFilterDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.HardwareFilterAPI.HardwareFilterDelete(context.Background(), id).Execute() - - require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/hardware_filter/"+*IpamsvcHardwareFilterPost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.HardwareFilterAPI.HardwareFilterDelete(context.Background(), *IpamsvcHardwareFilterPost.Id).Execute() + require.NoError(t, err) + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test HardwareFilterAPIService HardwareFilterList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/hardware_filter", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcListHardwareFilterResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.HardwareFilterAPI.HardwareFilterList(context.Background()).Execute() - - require.Nil(t, err) + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test HardwareFilterAPIService HardwareFilterRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.HardwareFilterAPI.HardwareFilterRead(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/hardware_filter/"+*IpamsvcHardwareFilterPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcReadHardwareFilterResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.HardwareFilterAPI.HardwareFilterRead(context.Background(), *IpamsvcHardwareFilterPost.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test HardwareFilterAPIService HardwareFilterUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.HardwareFilterAPI.HardwareFilterUpdate(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/hardware_filter/"+*IpamsvcHardwareFilterPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcHardwareFilter + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcHardwareFilterPatch, reqBody) + + response := openapiclient.IpamsvcUpdateHardwareFilterResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.HardwareFilterAPI.HardwareFilterUpdate(context.Background(), *IpamsvcHardwareFilterPost.Id).Body(IpamsvcHardwareFilterPatch).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - } diff --git a/ipam/test/api_ip_space_test.go b/ipam/test/api_ip_space_test.go index 51626e0..972ad70 100644 --- a/ipam/test/api_ip_space_test.go +++ b/ipam/test/api_ip_space_test.go @@ -5,115 +5,213 @@ Testing IpSpaceAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package ipam +package ipam_test import ( + "bytes" "context" + "encoding/json" + "github.com/stretchr/testify/assert" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/ipam" ) -func Test_ipam_IpSpaceAPIService(t *testing.T) { +var IpamsvcBulkCopyIPSpacePost = openapiclient.IpamsvcBulkCopyIPSpace{} +var IpamsvcCopyIPSpacePost = openapiclient.IpamsvcCopyIPSpace{ + Id: openapiclient.PtrString("Test Copy Post"), +} +var IpamsvcIPSpacePost = openapiclient.IpamsvcIPSpace{ + Id: openapiclient.PtrString("Test Post"), + Tags: make(map[string]interface{}), +} +var IpamsvcIPSpacePatch = openapiclient.IpamsvcIPSpace{ + Id: openapiclient.PtrString("Test Patch"), + Tags: make(map[string]interface{}), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestIpSpaceAPIService(t *testing.T) { t.Run("Test IpSpaceAPIService IpSpaceBulkCopy", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.IpSpaceAPI.IpSpaceBulkCopy(context.Background()).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/ip_space/bulk_copy", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcBulkCopyIPSpace + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcBulkCopyIPSpacePost, reqBody) + + response := openapiclient.IpamsvcBulkCopyIPSpaceResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.IpSpaceAPI.IpSpaceBulkCopy(context.Background()).Body(IpamsvcBulkCopyIPSpacePost).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test IpSpaceAPIService IpSpaceCopy", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.IpSpaceAPI.IpSpaceCopy(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/ip_space/"+*IpamsvcCopyIPSpacePost.Id+"/copy", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcCopyIPSpace + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcCopyIPSpacePost, reqBody) + + response := openapiclient.IpamsvcCopyIPSpaceResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.IpSpaceAPI.IpSpaceCopy(context.Background(), *IpamsvcCopyIPSpacePost.Id).Body(IpamsvcCopyIPSpacePost).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test IpSpaceAPIService IpSpaceCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.IpSpaceAPI.IpSpaceCreate(context.Background()).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/ip_space", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcIPSpace + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcIPSpacePost, reqBody) + + response := openapiclient.IpamsvcCreateIPSpaceResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.IpSpaceAPI.IpSpaceCreate(context.Background()).Body(IpamsvcIPSpacePost).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test IpSpaceAPIService IpSpaceDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.IpSpaceAPI.IpSpaceDelete(context.Background(), id).Execute() - - require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/ip_space/"+*IpamsvcIPSpacePost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.IpSpaceAPI.IpSpaceDelete(context.Background(), *IpamsvcIPSpacePost.Id).Execute() + require.NoError(t, err) + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test IpSpaceAPIService IpSpaceList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/ip_space", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcListIPSpaceResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.IpSpaceAPI.IpSpaceList(context.Background()).Execute() - - require.Nil(t, err) + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test IpSpaceAPIService IpSpaceRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.IpSpaceAPI.IpSpaceRead(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/ip_space/"+*IpamsvcIPSpacePost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcReadIPSpaceResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.IpSpaceAPI.IpSpaceRead(context.Background(), *IpamsvcIPSpacePost.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test IpSpaceAPIService IpSpaceUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.IpSpaceAPI.IpSpaceUpdate(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/ip_space/"+*IpamsvcIPSpacePatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcIPSpace + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcIPSpacePatch, reqBody) + + response := openapiclient.IpamsvcUpdateIPSpaceResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.IpSpaceAPI.IpSpaceUpdate(context.Background(), *IpamsvcIPSpacePatch.Id).Body(IpamsvcIPSpacePatch).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - } diff --git a/ipam/test/api_ipam_host_test.go b/ipam/test/api_ipam_host_test.go index 0775527..319c6ec 100644 --- a/ipam/test/api_ipam_host_test.go +++ b/ipam/test/api_ipam_host_test.go @@ -5,89 +5,152 @@ Testing IpamHostAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package ipam +package ipam_test import ( + "bytes" "context" + "encoding/json" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/ipam" ) -func Test_ipam_IpamHostAPIService(t *testing.T) { +var IpamsvcIpamHostPost = openapiclient.IpamsvcIpamHost{ + Id: openapiclient.PtrString("Test Post"), + Tags: make(map[string]interface{}), +} +var IpamsvcIpamHostPatch = openapiclient.IpamsvcIpamHost{ + Id: openapiclient.PtrString("Test Patch"), + Tags: make(map[string]interface{}), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestIpamHostAPIService(t *testing.T) { t.Run("Test IpamHostAPIService IpamHostCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.IpamHostAPI.IpamHostCreate(context.Background()).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/host", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcIpamHost + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, IpamsvcIpamHostPost, reqBody) + + response := openapiclient.IpamsvcCreateIpamHostResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.IpamHostAPI.IpamHostCreate(context.Background()).Body(IpamsvcIpamHostPost).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test IpamHostAPIService IpamHostDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.IpamHostAPI.IpamHostDelete(context.Background(), id).Execute() - - require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/host/"+*IpamsvcIpamHostPost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.IpamHostAPI.IpamHostDelete(context.Background(), *IpamsvcIpamHostPost.Id).Execute() + require.NoError(t, err) + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test IpamHostAPIService IpamHostList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/host", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcListIpamHostResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.IpamHostAPI.IpamHostList(context.Background()).Execute() - - require.Nil(t, err) + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test IpamHostAPIService IpamHostRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.IpamHostAPI.IpamHostRead(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/host/"+*IpamsvcIpamHostPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcReadIpamHostResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.IpamHostAPI.IpamHostRead(context.Background(), *IpamsvcIpamHostPost.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test IpamHostAPIService IpamHostUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.IpamHostAPI.IpamHostUpdate(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/host/"+*IpamsvcIpamHostPatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcIpamHost + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, IpamsvcIpamHostPatch, reqBody) + + response := openapiclient.IpamsvcUpdateIpamHostResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.IpamHostAPI.IpamHostUpdate(context.Background(), *IpamsvcIpamHostPatch.Id).Body(IpamsvcIpamHostPatch).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - } diff --git a/ipam/test/api_leases_command_test.go b/ipam/test/api_leases_command_test.go index b2775a0..29181b0 100644 --- a/ipam/test/api_leases_command_test.go +++ b/ipam/test/api_leases_command_test.go @@ -5,36 +5,52 @@ Testing LeasesCommandAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package ipam +package ipam_test import ( + "bytes" "context" + "encoding/json" + "github.com/stretchr/testify/assert" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/ipam" ) -func Test_ipam_LeasesCommandAPIService(t *testing.T) { +var IpamsvcLeasesCommandPost = openapiclient.IpamsvcLeasesCommand{} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestLeasesCommandAPIService(t *testing.T) { t.Run("Test LeasesCommandAPIService LeasesCommandCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.LeasesCommandAPI.LeasesCommandCreate(context.Background()).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/leases_command", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcLeasesCommand + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcLeasesCommandPost, reqBody) + + response := openapiclient.IpamsvcCreateLeasesCommandResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.LeasesCommandAPI.LeasesCommandCreate(context.Background()).Body(IpamsvcLeasesCommandPost).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - } diff --git a/ipam/test/api_option_code_test.go b/ipam/test/api_option_code_test.go index 1dad01a..a58c9e5 100644 --- a/ipam/test/api_option_code_test.go +++ b/ipam/test/api_option_code_test.go @@ -5,89 +5,152 @@ Testing OptionCodeAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package ipam +package ipam_test import ( + "bytes" "context" + "encoding/json" + "github.com/stretchr/testify/assert" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/ipam" ) -func Test_ipam_OptionCodeAPIService(t *testing.T) { +var IpamsvcOptionCodePost = openapiclient.IpamsvcOptionCode{ + Id: openapiclient.PtrString("Test Post"), +} +var IpamsvcOptionCodePatch = openapiclient.IpamsvcOptionCode{ + Id: openapiclient.PtrString("Test Patch"), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestOptionCodeAPIService(t *testing.T) { t.Run("Test OptionCodeAPIService OptionCodeCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.OptionCodeAPI.OptionCodeCreate(context.Background()).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/option_code", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcOptionCode + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcOptionCodePost, reqBody) + + response := openapiclient.IpamsvcCreateOptionCodeResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.OptionCodeAPI.OptionCodeCreate(context.Background()).Body(IpamsvcOptionCodePost).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test OptionCodeAPIService OptionCodeDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.OptionCodeAPI.OptionCodeDelete(context.Background(), id).Execute() - - require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/option_code/"+*IpamsvcOptionCodePost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.OptionCodeAPI.OptionCodeDelete(context.Background(), *IpamsvcOptionCodePost.Id).Execute() + require.NoError(t, err) + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test OptionCodeAPIService OptionCodeList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/option_code", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcListOptionCodeResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.OptionCodeAPI.OptionCodeList(context.Background()).Execute() - - require.Nil(t, err) + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test OptionCodeAPIService OptionCodeRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.OptionCodeAPI.OptionCodeRead(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/option_code/"+*IpamsvcOptionCodePost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcReadOptionCodeResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.OptionCodeAPI.OptionCodeRead(context.Background(), *IpamsvcOptionCodePost.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test OptionCodeAPIService OptionCodeUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.OptionCodeAPI.OptionCodeUpdate(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/option_code/"+*IpamsvcOptionCodePatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcOptionCode + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcOptionCodePatch, reqBody) + + response := openapiclient.IpamsvcUpdateOptionCodeResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.OptionCodeAPI.OptionCodeUpdate(context.Background(), *IpamsvcOptionCodePatch.Id).Body(IpamsvcOptionCodePatch).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - } diff --git a/ipam/test/api_option_filter_test.go b/ipam/test/api_option_filter_test.go index 9865419..1ee0b60 100644 --- a/ipam/test/api_option_filter_test.go +++ b/ipam/test/api_option_filter_test.go @@ -5,89 +5,153 @@ Testing OptionFilterAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package ipam +package ipam_test import ( + "bytes" "context" + "encoding/json" + "github.com/stretchr/testify/assert" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/ipam" ) -func Test_ipam_OptionFilterAPIService(t *testing.T) { +var IpamsvcOptionFilterPost = openapiclient.IpamsvcOptionFilter{ + Id: openapiclient.PtrString("Test Post"), + Tags: make(map[string]interface{}), +} +var IpamsvcOptionFilterPatch = openapiclient.IpamsvcOptionFilter{ + Id: openapiclient.PtrString("Test Patch"), + Tags: make(map[string]interface{}), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestOptionFilterAPIService(t *testing.T) { t.Run("Test OptionFilterAPIService OptionFilterCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.OptionFilterAPI.OptionFilterCreate(context.Background()).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/option_filter", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcOptionFilter + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcOptionFilterPost, reqBody) + + response := openapiclient.IpamsvcCreateOptionFilterResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.OptionFilterAPI.OptionFilterCreate(context.Background()).Body(IpamsvcOptionFilterPost).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test OptionFilterAPIService OptionFilterDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.OptionFilterAPI.OptionFilterDelete(context.Background(), id).Execute() - - require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/option_filter/"+*IpamsvcOptionFilterPost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.OptionFilterAPI.OptionFilterDelete(context.Background(), *IpamsvcOptionFilterPost.Id).Execute() + require.NoError(t, err) + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test OptionFilterAPIService OptionFilterList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/option_filter", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcListOptionFilterResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.OptionFilterAPI.OptionFilterList(context.Background()).Execute() - - require.Nil(t, err) + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test OptionFilterAPIService OptionFilterRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.OptionFilterAPI.OptionFilterRead(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/option_filter/"+*IpamsvcOptionFilterPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcReadOptionFilterResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.OptionFilterAPI.OptionFilterRead(context.Background(), *IpamsvcOptionFilterPost.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test OptionFilterAPIService OptionFilterUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.OptionFilterAPI.OptionFilterUpdate(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/option_filter/"+*IpamsvcOptionFilterPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcOptionFilter + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcOptionFilterPatch, reqBody) + + response := openapiclient.IpamsvcUpdateOptionFilterResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.OptionFilterAPI.OptionFilterUpdate(context.Background(), *IpamsvcOptionFilterPost.Id).Body(IpamsvcOptionFilterPatch).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - } diff --git a/ipam/test/api_option_group_test.go b/ipam/test/api_option_group_test.go index 9e448b2..e3bd9b2 100644 --- a/ipam/test/api_option_group_test.go +++ b/ipam/test/api_option_group_test.go @@ -5,89 +5,153 @@ Testing OptionGroupAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package ipam +package ipam_test import ( + "bytes" "context" + "encoding/json" + "github.com/stretchr/testify/assert" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/ipam" ) -func Test_ipam_OptionGroupAPIService(t *testing.T) { +var IpamsvcOptionGroupPost = openapiclient.IpamsvcOptionGroup{ + Id: openapiclient.PtrString("Test Post"), + Tags: make(map[string]interface{}), +} +var IpamsvcOptionGroupPatch = openapiclient.IpamsvcOptionGroup{ + Id: openapiclient.PtrString("Test Patch"), + Tags: make(map[string]interface{}), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func Test_ipam_OptionGroupAPIService(t *testing.T) { t.Run("Test OptionGroupAPIService OptionGroupCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.OptionGroupAPI.OptionGroupCreate(context.Background()).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/option_group", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcOptionGroup + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcOptionGroupPost, reqBody) + + response := openapiclient.IpamsvcCreateOptionGroupResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.OptionGroupAPI.OptionGroupCreate(context.Background()).Body(IpamsvcOptionGroupPost).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test OptionGroupAPIService OptionGroupDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.OptionGroupAPI.OptionGroupDelete(context.Background(), id).Execute() - - require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/option_group/"+*IpamsvcOptionGroupPost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.OptionGroupAPI.OptionGroupDelete(context.Background(), *IpamsvcOptionGroupPost.Id).Execute() + require.NoError(t, err) + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test OptionGroupAPIService OptionGroupList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/option_group", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcListOptionGroupResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.OptionGroupAPI.OptionGroupList(context.Background()).Execute() - - require.Nil(t, err) + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test OptionGroupAPIService OptionGroupRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.OptionGroupAPI.OptionGroupRead(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/option_group/"+*IpamsvcOptionGroupPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcReadOptionGroupResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.OptionGroupAPI.OptionGroupRead(context.Background(), *IpamsvcOptionGroupPost.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test OptionGroupAPIService OptionGroupUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.OptionGroupAPI.OptionGroupUpdate(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/option_group/"+*IpamsvcOptionGroupPatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcOptionGroup + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcOptionGroupPatch, reqBody) + + response := openapiclient.IpamsvcUpdateOptionGroupResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.OptionGroupAPI.OptionGroupUpdate(context.Background(), *IpamsvcOptionGroupPatch.Id).Body(IpamsvcOptionGroupPatch).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - } diff --git a/ipam/test/api_option_space_test.go b/ipam/test/api_option_space_test.go index 0fc8b74..2a8e1dd 100644 --- a/ipam/test/api_option_space_test.go +++ b/ipam/test/api_option_space_test.go @@ -5,89 +5,153 @@ Testing OptionSpaceAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package ipam +package ipam_test import ( + "bytes" "context" + "encoding/json" + "github.com/stretchr/testify/assert" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/ipam" ) -func Test_ipam_OptionSpaceAPIService(t *testing.T) { +var IpamsvcOptionSpacePost = openapiclient.IpamsvcOptionSpace{ + Id: openapiclient.PtrString("Test Post"), + Tags: make(map[string]interface{}), +} +var IpamsvcOptionSpacePatch = openapiclient.IpamsvcOptionSpace{ + Id: openapiclient.PtrString("Test Patch"), + Tags: make(map[string]interface{}), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestOptionSpaceAPIService(t *testing.T) { t.Run("Test OptionSpaceAPIService OptionSpaceCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.OptionSpaceAPI.OptionSpaceCreate(context.Background()).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/option_space", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcOptionSpace + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcOptionSpacePost, reqBody) + + response := openapiclient.IpamsvcCreateOptionSpaceResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.OptionSpaceAPI.OptionSpaceCreate(context.Background()).Body(IpamsvcOptionSpacePost).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test OptionSpaceAPIService OptionSpaceDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.OptionSpaceAPI.OptionSpaceDelete(context.Background(), id).Execute() - - require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/option_space/"+*IpamsvcOptionSpacePost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.OptionSpaceAPI.OptionSpaceDelete(context.Background(), *IpamsvcOptionSpacePost.Id).Execute() + require.NoError(t, err) + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test OptionSpaceAPIService OptionSpaceList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/option_space", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcListOptionSpaceResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.OptionSpaceAPI.OptionSpaceList(context.Background()).Execute() - - require.Nil(t, err) + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test OptionSpaceAPIService OptionSpaceRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.OptionSpaceAPI.OptionSpaceRead(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/option_space/"+*IpamsvcOptionSpacePost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcReadOptionSpaceResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.OptionSpaceAPI.OptionSpaceRead(context.Background(), *IpamsvcOptionSpacePost.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test OptionSpaceAPIService OptionSpaceUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.OptionSpaceAPI.OptionSpaceUpdate(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/option_space/"+*IpamsvcOptionSpacePatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcOptionSpace + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcOptionSpacePatch, reqBody) + + response := openapiclient.IpamsvcUpdateOptionSpaceResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.OptionSpaceAPI.OptionSpaceUpdate(context.Background(), *IpamsvcOptionSpacePatch.Id).Body(IpamsvcOptionSpacePatch).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - } diff --git a/ipam/test/api_range_test.go b/ipam/test/api_range_test.go index 9d95b53..f5ba4cc 100644 --- a/ipam/test/api_range_test.go +++ b/ipam/test/api_range_test.go @@ -5,117 +5,202 @@ Testing RangeAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package ipam +package ipam_test import ( + "bytes" "context" + "encoding/json" + "github.com/stretchr/testify/assert" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/ipam" ) -func Test_ipam_RangeAPIService(t *testing.T) { +var IpamsvcRangePost = openapiclient.IpamsvcRange{ + Id: openapiclient.PtrString("Test Post"), + Tags: make(map[string]interface{}), +} +var IpamsvcRangePatch = openapiclient.IpamsvcRange{ + Id: openapiclient.PtrString("Test Patch"), + Tags: make(map[string]interface{}), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestRangeAPIService(t *testing.T) { t.Run("Test RangeAPIService RangeCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.RangeAPI.RangeCreate(context.Background()).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/range", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcRange + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcRangePost, reqBody) + + response := openapiclient.IpamsvcCreateRangeResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.RangeAPI.RangeCreate(context.Background()).Body(IpamsvcRangePost).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test RangeAPIService RangeCreateNextAvailableIP", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.RangeAPI.RangeCreateNextAvailableIP(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/range/"+*IpamsvcRangePost.Id+"/nextavailableip", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcCreateNextAvailableIPResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.RangeAPI.RangeCreateNextAvailableIP(context.Background(), *IpamsvcRangePost.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test RangeAPIService RangeDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.RangeAPI.RangeDelete(context.Background(), id).Execute() - - require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/range/"+*IpamsvcRangePost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.RangeAPI.RangeDelete(context.Background(), *IpamsvcRangePost.Id).Execute() + require.NoError(t, err) + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test RangeAPIService RangeList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/range", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcListRangeResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.RangeAPI.RangeList(context.Background()).Execute() - - require.Nil(t, err) + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test RangeAPIService RangeListNextAvailableIP", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.RangeAPI.RangeListNextAvailableIP(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/range/"+*IpamsvcRangePost.Id+"/nextavailableip", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcNextAvailableIPResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.RangeAPI.RangeListNextAvailableIP(context.Background(), *IpamsvcRangePost.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test RangeAPIService RangeRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.RangeAPI.RangeRead(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/range/"+*IpamsvcRangePost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcReadRangeResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.RangeAPI.RangeRead(context.Background(), *IpamsvcRangePost.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test RangeAPIService RangeUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.RangeAPI.RangeUpdate(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/range/"+*IpamsvcRangePatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcRange + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcRangePatch, reqBody) + + response := openapiclient.IpamsvcUpdateRangeResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.RangeAPI.RangeUpdate(context.Background(), *IpamsvcRangePatch.Id).Body(IpamsvcRangePatch).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - } diff --git a/ipam/test/api_server_test.go b/ipam/test/api_server_test.go index bfbde6d..dbea89e 100644 --- a/ipam/test/api_server_test.go +++ b/ipam/test/api_server_test.go @@ -5,89 +5,153 @@ Testing ServerAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package ipam +package ipam_test import ( + "bytes" "context" + "encoding/json" + "github.com/stretchr/testify/assert" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/ipam" ) -func Test_ipam_ServerAPIService(t *testing.T) { +var IpamsvcServerPost = openapiclient.IpamsvcServer{ + Id: openapiclient.PtrString("Test Post"), + Tags: make(map[string]interface{}), +} +var IpamsvcServerPatch = openapiclient.IpamsvcServer{ + Id: openapiclient.PtrString("Test Patch"), + Tags: make(map[string]interface{}), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestServerAPIService(t *testing.T) { t.Run("Test ServerAPIService ServerCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.ServerAPI.ServerCreate(context.Background()).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/server", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcServer + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcServerPost, reqBody) + + response := openapiclient.IpamsvcCreateServerResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.ServerAPI.ServerCreate(context.Background()).Body(IpamsvcServerPost).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test ServerAPIService ServerDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.ServerAPI.ServerDelete(context.Background(), id).Execute() - - require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/server/"+*IpamsvcServerPost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.ServerAPI.ServerDelete(context.Background(), *IpamsvcServerPost.Id).Execute() + require.NoError(t, err) + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test ServerAPIService ServerList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/server", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcListServerResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.ServerAPI.ServerList(context.Background()).Execute() - - require.Nil(t, err) + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test ServerAPIService ServerRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.ServerAPI.ServerRead(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/server/"+*IpamsvcServerPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcReadServerResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.ServerAPI.ServerRead(context.Background(), *IpamsvcServerPost.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test ServerAPIService ServerUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.ServerAPI.ServerUpdate(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/dhcp/server/"+*IpamsvcServerPatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcServer + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcServerPatch, reqBody) + + response := openapiclient.IpamsvcUpdateServerResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.ServerAPI.ServerUpdate(context.Background(), *IpamsvcServerPatch.Id).Body(IpamsvcServerPatch).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - } diff --git a/ipam/test/api_subnet_test.go b/ipam/test/api_subnet_test.go index 3960d6e..821432c 100644 --- a/ipam/test/api_subnet_test.go +++ b/ipam/test/api_subnet_test.go @@ -5,131 +5,232 @@ Testing SubnetAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package ipam +package ipam_test import ( + "bytes" "context" + "encoding/json" + "github.com/stretchr/testify/assert" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/ipam" ) -func Test_ipam_SubnetAPIService(t *testing.T) { +var IpamsvcCopySubnetPost = openapiclient.IpamsvcCopySubnet{ + Id: openapiclient.PtrString("Test Copy"), +} +var IpamsvcSubnetPost = openapiclient.IpamsvcSubnet{ + Id: openapiclient.PtrString("Test Post"), + Tags: make(map[string]interface{}), +} +var IpamsvcSubnetPatch = openapiclient.IpamsvcSubnet{ + Id: openapiclient.PtrString("Test Patch"), + Tags: make(map[string]interface{}), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestSubnetAPIService(t *testing.T) { t.Run("Test SubnetAPIService SubnetCopy", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.SubnetAPI.SubnetCopy(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/subnet/"+*IpamsvcCopySubnetPost.Id+"/copy", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcCopySubnet + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcCopySubnetPost, reqBody) + + response := openapiclient.IpamsvcCopySubnetResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.SubnetAPI.SubnetCopy(context.Background(), *IpamsvcCopySubnetPost.Id).Body(IpamsvcCopySubnetPost).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test SubnetAPIService SubnetCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.SubnetAPI.SubnetCreate(context.Background()).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/subnet", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcSubnet + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcSubnetPost, reqBody) + + response := openapiclient.IpamsvcCreateSubnetResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.SubnetAPI.SubnetCreate(context.Background()).Body(IpamsvcSubnetPost).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test SubnetAPIService SubnetCreateNextAvailableIP", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.SubnetAPI.SubnetCreateNextAvailableIP(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/subnet/"+*IpamsvcSubnetPost.Id+"/nextavailableip", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcCreateNextAvailableIPResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.SubnetAPI.SubnetCreateNextAvailableIP(context.Background(), *IpamsvcSubnetPost.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test SubnetAPIService SubnetDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.SubnetAPI.SubnetDelete(context.Background(), id).Execute() - - require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/subnet/"+*IpamsvcSubnetPost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.SubnetAPI.SubnetDelete(context.Background(), *IpamsvcSubnetPost.Id).Execute() + require.NoError(t, err) + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test SubnetAPIService SubnetList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/subnet", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcListSubnetResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.SubnetAPI.SubnetList(context.Background()).Execute() - - require.Nil(t, err) + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test SubnetAPIService SubnetListNextAvailableIP", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.SubnetAPI.SubnetListNextAvailableIP(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/subnet/"+*IpamsvcSubnetPost.Id+"/nextavailableip", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcNextAvailableIPResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.SubnetAPI.SubnetListNextAvailableIP(context.Background(), *IpamsvcSubnetPost.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test SubnetAPIService SubnetRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.SubnetAPI.SubnetRead(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/subnet/"+*IpamsvcSubnetPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.IpamsvcReadSubnetResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.SubnetAPI.SubnetRead(context.Background(), *IpamsvcSubnetPost.Id).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test SubnetAPIService SubnetUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.SubnetAPI.SubnetUpdate(context.Background(), id).Execute() - - require.Nil(t, err) + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/ipam/subnet/"+*IpamsvcSubnetPatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.IpamsvcSubnet + assert.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + assert.Equal(t, IpamsvcSubnetPatch, reqBody) + + response := openapiclient.IpamsvcUpdateSubnetResponse{} + body, err := json.Marshal(response) + assert.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.SubnetAPI.SubnetUpdate(context.Background(), *IpamsvcSubnetPatch.Id).Body(IpamsvcSubnetPatch).Execute() + require.NoError(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) - } diff --git a/keys/test/api_generate_tsig_test.go b/keys/test/api_generate_tsig_test.go index 3ea00f9..e082806 100644 --- a/keys/test/api_generate_tsig_test.go +++ b/keys/test/api_generate_tsig_test.go @@ -5,36 +5,46 @@ Testing GenerateTsigAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package keys +package keys_test import ( + "bytes" "context" + "encoding/json" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/keys" ) -func Test_keys_GenerateTsigAPIService(t *testing.T) { - - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestGenerateTsigAPIService(t *testing.T) { t.Run("Test GenerateTsigAPIService GenerateTsigGenerateTSIG", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/keys/generate_tsig", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.KeysGenerateTSIGResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.GenerateTsigAPI.GenerateTsigGenerateTSIG(context.Background()).Execute() - require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) } diff --git a/keys/test/api_kerberos_test.go b/keys/test/api_kerberos_test.go index 21283c8..e76bb8e 100644 --- a/keys/test/api_kerberos_test.go +++ b/keys/test/api_kerberos_test.go @@ -5,77 +5,151 @@ Testing KerberosAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package keys +package keys_test import ( + "bytes" "context" + "encoding/json" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/keys" ) -func Test_keys_KerberosAPIService(t *testing.T) { +var KerberosKeyPatch = openapiclient.KerberosKey{ + Id: openapiclient.PtrString("KerberosKeyPost"), +} +var KerberosKeyPost = openapiclient.KerberosKey{ + Id: openapiclient.PtrString("KerberosKeyPatch"), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestKerberosAPIService(t *testing.T) { t.Run("Test KerberosAPIService KerberosDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.KerberosAPI.KerberosDelete(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/keys/kerberos/"+*KerberosKeyPost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.KerberosAPI.KerberosDelete(context.Background(), *KerberosKeyPost.Id).Execute() require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test KerberosAPIService KerberosList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/keys/kerberos", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.KeysListKerberosKeyResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.KerberosAPI.KerberosList(context.Background()).Execute() - require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test KerberosAPIService KerberosRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.KerberosAPI.KerberosRead(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/keys/kerberos/"+*KerberosKeyPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.KeysReadKerberosKeyResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.KerberosAPI.KerberosRead(context.Background(), *KerberosKeyPost.Id).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test KerberosAPIService KerberosUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.KerberosAPI.KerberosUpdate(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/keys/kerberos/"+*KerberosKeyPatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + var reqBody openapiclient.KerberosKey + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, KerberosKeyPatch, reqBody) + + response := openapiclient.KeysUpdateKerberosKeyResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.KerberosAPI.KerberosUpdate(context.Background(), *KerberosKeyPatch.Id).Body(KerberosKeyPatch).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) + require.Equal(t, http.StatusOK, httpRes.StatusCode) + }) + t.Run("Test KerberosAPIService KeysKerberosPost", func(t *testing.T) { + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/keys/kerberos", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.KerberosKey + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, KerberosKeyPost, reqBody) + + response := openapiclient.KeysListKerberosKeyResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.KerberosAPI.KeysKerberosPost(context.Background()).Body(KerberosKeyPost).Execute() + require.Nil(t, err) + require.NotNil(t, resp) + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) } diff --git a/keys/test/api_tsig_test.go b/keys/test/api_tsig_test.go index c11a32a..e5acadf 100644 --- a/keys/test/api_tsig_test.go +++ b/keys/test/api_tsig_test.go @@ -5,89 +5,153 @@ Testing TsigAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package keys +package keys_test import ( + "bytes" "context" + "encoding/json" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/keys" ) -func Test_keys_TsigAPIService(t *testing.T) { +var KeysTSIGKeyPost = openapiclient.KeysTSIGKey{ + Id: openapiclient.PtrString("KeysTsigPost"), + Tags: make(map[string]interface{}), +} +var KeysTSIGKeyPatch = openapiclient.KeysTSIGKey{ + Id: openapiclient.PtrString("KeysTsigPatch"), + Tags: make(map[string]interface{}), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestTsigAPIService(t *testing.T) { t.Run("Test TsigAPIService TsigCreate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.TsigAPI.TsigCreate(context.Background()).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/keys/tsig", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.KeysTSIGKey + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, KeysTSIGKeyPost, reqBody) + + response := openapiclient.KeysCreateTSIGKeyResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.TsigAPI.TsigCreate(context.Background()).Body(KeysTSIGKeyPost).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test TsigAPIService TsigDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - httpRes, err := apiClient.TsigAPI.TsigDelete(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodDelete, req.Method) + require.Equal(t, "/api/ddi/v1/keys/tsig/"+*KeysTSIGKeyPost.Id, req.URL.Path) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader([]byte{})), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + httpRes, err := apiClient.TsigAPI.TsigDelete(context.Background(), *KeysTSIGKeyPost.Id).Execute() require.Nil(t, err) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test TsigAPIService TsigList", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/keys/tsig", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.KeysListTSIGKeyResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) resp, httpRes, err := apiClient.TsigAPI.TsigList(context.Background()).Execute() - require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test TsigAPIService TsigRead", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.TsigAPI.TsigRead(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodGet, req.Method) + require.Equal(t, "/api/ddi/v1/keys/tsig/"+*KeysTSIGKeyPost.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Accept")) + + response := openapiclient.KeysReadTSIGKeyResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.TsigAPI.TsigRead(context.Background(), *KeysTSIGKeyPost.Id).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) t.Run("Test TsigAPIService TsigUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string - - resp, httpRes, err := apiClient.TsigAPI.TsigUpdate(context.Background(), id).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPatch, req.Method) + require.Equal(t, "/api/ddi/v1/keys/tsig/"+*KeysTSIGKeyPatch.Id, req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.KeysTSIGKey + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, KeysTSIGKeyPatch, reqBody) + + response := openapiclient.KeysUpdateTSIGKeyResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.TsigAPI.TsigUpdate(context.Background(), *KeysTSIGKeyPatch.Id).Body(KeysTSIGKeyPatch).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) } diff --git a/keys/test/api_upload_test.go b/keys/test/api_upload_test.go index f2cd257..d5449b7 100644 --- a/keys/test/api_upload_test.go +++ b/keys/test/api_upload_test.go @@ -5,36 +5,57 @@ Testing UploadAPIService */ -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package keys +package keys_test import ( + "bytes" "context" + "encoding/json" + "io" + "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/infobloxopen/bloxone-go-client/internal" openapiclient "github.com/infobloxopen/bloxone-go-client/keys" ) -func Test_keys_UploadAPIService(t *testing.T) { +var UploadRequestPost = openapiclient.UploadRequest{ + Comment: openapiclient.PtrString("Upload Request"), + Content: "SGVsbG8gd29ybGQ=", // "Hello world" in base64 + Type: openapiclient.UPLOADCONTENTTYPE_KEYTAB, // Replace "your_content_type" with the actual content type + Tags: make(map[string]interface{}), +} - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) +func TestUploadAPIService(t *testing.T) { t.Run("Test UploadAPIService UploadUpload", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - resp, httpRes, err := apiClient.UploadAPI.UploadUpload(context.Background()).Execute() - + configuration := internal.NewConfiguration() + configuration.HTTPClient = internal.NewTestClient(func(req *http.Request) *http.Response { + require.Equal(t, http.MethodPost, req.Method) + require.Equal(t, "/api/ddi/v1/keys/upload", req.URL.Path) + require.Equal(t, "application/json", req.Header.Get("Content-Type")) + + var reqBody openapiclient.UploadRequest + require.NoError(t, json.NewDecoder(req.Body).Decode(&reqBody)) + require.Equal(t, UploadRequestPost, reqBody) + + response := openapiclient.DdiuploadResponse{} + body, err := json.Marshal(response) + require.NoError(t, err) + + return &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewReader(body)), + Header: map[string][]string{"Content-Type": {"application/json"}}, + } + }) + apiClient := openapiclient.NewAPIClient(configuration) + resp, httpRes, err := apiClient.UploadAPI.UploadUpload(context.Background()).Body(UploadRequestPost).Execute() require.Nil(t, err) require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) - + require.Equal(t, http.StatusOK, httpRes.StatusCode) }) }