Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit Test #18

Merged
merged 21 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0860545
test runs, more fields needed to be test
MinJiang00 Feb 1, 2024
698c338
tests done, except for kerberos
MinJiang00 Feb 13, 2024
36773af
keys done, dns waiting
MinJiang00 Feb 15, 2024
742121d
Complete unit tests for dns_data, dns_config, and keys modules
MinJiang00 Feb 26, 2024
5312a4c
Just ran make client
MinJiang00 Feb 26, 2024
497b6b2
ran go fmt ./...
MinJiang00 Feb 27, 2024
af9a75d
test runs, more fields needed to be test
MinJiang00 Feb 1, 2024
399e247
tests done, except for kerberos
MinJiang00 Feb 13, 2024
15c510d
keys done, dns waiting
MinJiang00 Feb 15, 2024
e54dc65
Complete unit tests for dns_data, dns_config, and keys modules
MinJiang00 Feb 26, 2024
420e3d5
Merge branch 'tsig-keys-test' of https://github.com/MinJiang00/bloxon…
MinJiang00 Feb 27, 2024
bc41d39
Tests
MinJiang00 Feb 27, 2024
f87b1f0
Unit Tests For Keys, DNS With Generator Working at version 7.3.0
MinJiang00 Feb 28, 2024
f21f253
Merge branch '7.3.0' into tsig-keys-test
MinJiang00 Feb 28, 2024
2fcdf42
Ran 'go fmt ./...' for formatting check and investigated version 7.3.0
MinJiang00 Feb 29, 2024
cd4449f
Merge branch 'tsig-keys-test' of https://github.com/MinJiang00/bloxon…
MinJiang00 Feb 29, 2024
c0c68a9
Complete unit tests for ipam, dhcp, dns_data, dns_config, and keys mo…
MinJiang00 Mar 1, 2024
16e3bf9
Complete unit tests for ipam, dhcp, dns_data, dns_config, and keys mo…
MinJiang00 Mar 1, 2024
e6e3085
Complete unit tests for dns_data, dns_config, and keys modules:
MinJiang00 Mar 4, 2024
4e63706
Complete unit tests for dns_data, dns_config, ipam/dhcp, infra_mgmt a…
MinJiang00 Mar 4, 2024
384a5f3
Complete unit tests for dns_data, dns_config, ipam/dhcp, infra_mgmt a…
MinJiang00 Mar 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
169 changes: 119 additions & 50 deletions dns_config/test/api_acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})

}
Loading
Loading