From 0860545368c146fa65e21b53e7e0529775fecda8 Mon Sep 17 00:00:00 2001 From: Min Jiang Date: Thu, 1 Feb 2024 10:00:58 -0800 Subject: [PATCH] test runs, more fields needed to be test --- keys/api_tsig.go | 1 + keys/model_keys_tsig_key.go | 2 + keys/test/api_tsig_test.go | 88 +++++++++++++++++++++++------------- keys/test/api_upload_test.go | 11 ++--- 4 files changed, 65 insertions(+), 37 deletions(-) diff --git a/keys/api_tsig.go b/keys/api_tsig.go index 4386f89..327f290 100644 --- a/keys/api_tsig.go +++ b/keys/api_tsig.go @@ -13,6 +13,7 @@ package keys import ( "bytes" "context" + _ "github.com/infobloxopen/bloxone-go-client/dns_config" "io" "net/http" "net/url" diff --git a/keys/model_keys_tsig_key.go b/keys/model_keys_tsig_key.go index 9ebb444..12c1ea5 100644 --- a/keys/model_keys_tsig_key.go +++ b/keys/model_keys_tsig_key.go @@ -13,6 +13,7 @@ package keys import ( "encoding/json" "time" + ) // checks if the KeysTSIGKey type satisfies the MappedNullable interface at compile time @@ -38,6 +39,7 @@ type KeysTSIGKey struct { Tags map[string]interface{} `json:"tags,omitempty"` // Time when the object has been updated. Equals to _created_at_ if not updated after creation. UpdatedAt *time.Time `json:"updated_at,omitempty"` + res interface{} } // NewKeysTSIGKey instantiates a new KeysTSIGKey object diff --git a/keys/test/api_tsig_test.go b/keys/test/api_tsig_test.go index c11a32a..31eee82 100644 --- a/keys/test/api_tsig_test.go +++ b/keys/test/api_tsig_test.go @@ -7,54 +7,76 @@ Testing TsigAPIService // Code generated by OpenAPI Generator (https://openapi-generator.tech); -package keys +package keys_test import ( "context" - "testing" - + "github.com/infobloxopen/bloxone-go-client/client" + openapiclient "github.com/infobloxopen/bloxone-go-client/keys" "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" + "net/http" + "strings" + "testing" ) func Test_keys_TsigAPIService(t *testing.T) { - - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) + rq := require.New(t) + c, err := client.NewAPIClient(client.Configuration{ClientName: "test"}) + rq.NoError(err) + apiClient := c.KeysAPI + dummyKey := openapiclient.KeysTSIGKey{ + Algorithm: openapiclient.PtrString("hmac_sha256"), + Comment: nil, // or use: String("This is a comment") + CreatedAt: nil, // or use: Time(time.Now()) + Id: nil, //openapiclient.PtrString("123"), + Name: "dummyKey36", + ProtocolName: nil, // or use: String("protocolName") + Secret: "XOJvQkcX6Og0CHFg+rQ27pqAB+EhSjVoI4Bs/JWegBc=", + Tags: nil, //make(map[string]interface{}), + UpdatedAt: nil, // or use: Time(time.Now()) + } + var createResp *openapiclient.KeysCreateTSIGKeyResponse // replace with the actual type of resp + var httpRes *http.Response 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() + //t.Skip("skip test") // remove to run test + ctx := context.Background() + req := apiClient.TsigAPI.TsigCreate(ctx) + req = req.Body(dummyKey) + createResp, httpRes, err = req.Execute() require.Nil(t, err) - require.NotNil(t, resp) + require.NotNil(t, createResp) assert.Equal(t, 200, httpRes.StatusCode) }) - t.Run("Test TsigAPIService TsigDelete", func(t *testing.T) { - - t.Skip("skip test") // remove to run test - - var id string + t.Run("Test TsigAPIService TsigList", func(t *testing.T) { - httpRes, err := apiClient.TsigAPI.TsigDelete(context.Background(), id).Execute() + //t.Skip("skip test") // remove to run test + req := apiClient.TsigAPI.TsigList(context.Background()).Fields("name") + resp, httpRes, err := req.Execute() require.Nil(t, err) + require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) }) - t.Run("Test TsigAPIService TsigList", func(t *testing.T) { + t.Run("Test TsigAPIService TsigRead", func(t *testing.T) { - t.Skip("skip test") // remove to run test + //t.Skip("skip test") // remove to run test - resp, httpRes, err := apiClient.TsigAPI.TsigList(context.Background()).Execute() + var id string + id = *createResp.GetResult().Id + lastSlash := strings.LastIndex(id, "/") + uuid := string(id[lastSlash+1:]) + + req := apiClient.TsigAPI.TsigRead(context.Background(), uuid) + req.Fields("name") + resp, httpRes, err := req.Execute() require.Nil(t, err) require.NotNil(t, resp) @@ -62,13 +84,17 @@ func Test_keys_TsigAPIService(t *testing.T) { }) - t.Run("Test TsigAPIService TsigRead", func(t *testing.T) { + t.Run("Test TsigAPIService TsigUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test + //t.Skip("skip test") // remove to run test var id string + id = *createResp.GetResult().Id + lastSlash := strings.LastIndex(id, "/") + uuid := id[lastSlash+1:] + req := apiClient.TsigAPI.TsigUpdate(context.Background(), uuid).Body(dummyKey) - resp, httpRes, err := apiClient.TsigAPI.TsigRead(context.Background(), id).Execute() + resp, httpRes, err := req.Execute() require.Nil(t, err) require.NotNil(t, resp) @@ -76,16 +102,16 @@ func Test_keys_TsigAPIService(t *testing.T) { }) - t.Run("Test TsigAPIService TsigUpdate", func(t *testing.T) { - - t.Skip("skip test") // remove to run test + t.Run("Test TsigAPIService TsigDelete", func(t *testing.T) { - var id string + //t.Skip("skip test") // remove to run test - resp, httpRes, err := apiClient.TsigAPI.TsigUpdate(context.Background(), id).Execute() + var id = *createResp.GetResult().Id + lastSlash := strings.LastIndex(id, "/") + uuid := string(id[lastSlash+1:]) + httpRes, err := apiClient.TsigAPI.TsigDelete(context.Background(), uuid).Execute() require.Nil(t, err) - require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) }) diff --git a/keys/test/api_upload_test.go b/keys/test/api_upload_test.go index f2cd257..220be43 100644 --- a/keys/test/api_upload_test.go +++ b/keys/test/api_upload_test.go @@ -11,19 +11,18 @@ package keys import ( "context" + "github.com/infobloxopen/bloxone-go-client/client" "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) { - - configuration := internal.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) + rq := require.New(t) + c, err := client.NewAPIClient(client.Configuration{ClientName: "test"}) + rq.NoError(err) + apiClient := c.KeysAPI t.Run("Test UploadAPIService UploadUpload", func(t *testing.T) {