Repository: ctreminiom/go-atlassian
Pull request #100 (2022-01-19 23:12:35)

:sparkles: Added the Confluence Restriction Operation User service


Patch:
diff --git a/confluence/confluence.go b/confluence/confluence.go
index a26720d..125300e 100644
--- a/confluence/confluence.go
+++ b/confluence/confluence.go
@@ -56,6 +56,7 @@ func New(httpClient *http.Client, site string) (client *Client, err error) {
 			Operation: &ContentRestrictionOperationService{
 				client: client,
 				Group:  &ContentRestrictionOperationGroupService{client: client},
+				User:   &ContentRestrictionOperationUserService{client: client},
 			}},
 	}
 
diff --git a/confluence/contentRestrictionOperationUser.go b/confluence/contentRestrictionOperationUser.go
new file mode 100644
index 0000000..31ab1b7
--- /dev/null
+++ b/confluence/contentRestrictionOperationUser.go
@@ -0,0 +1,132 @@
+package confluence
+
+import (
+	"context"
+	"fmt"
+	"github.com/ctreminiom/go-atlassian/pkg/infra/models"
+	"net/http"
+	"net/url"
+	"strings"
+)
+
+type ContentRestrictionOperationUserService struct{ client *Client }
+
+// Get returns whether the specified content restriction applies to a user.
+// Docs: https://docs.go-atlassian.io/confluence-cloud/content/restrictions/operations/user#get-content-restriction-status-for-user
+func (c *ContentRestrictionOperationUserService) Get(ctx context.Context, contentID, operationKey, accountID string) (
+	response *ResponseScheme, err error) {
+
+	if len(contentID) == 0 {
+		return nil, models.ErrNoContentIDError
+	}
+
+	if len(operationKey) == 0 {
+		return nil, models.ErrNoContentRestrictionKeyError
+	}
+
+	if len(accountID) == 0 {
+		return nil, models.ErrNoAccountIDError
+	}
+
+	var endpoint strings.Builder
+	endpoint.WriteString(fmt.Sprintf("wiki/rest/api/content/%v/restriction/byOperation/%v/user", contentID, operationKey))
+
+	query := url.Values{}
+	query.Add("accountId", accountID)
+
+	if query.Encode() != "" {
+		endpoint.WriteString(fmt.Sprintf("?%v", query.Encode()))
+	}
+
+	request, err := c.client.newRequest(ctx, http.MethodGet, endpoint.String(), nil)
+	if err != nil {
+		return nil, err
+	}
+
+	response, err = c.client.Call(request, nil)
+	if err != nil {
+		return response, err
+	}
+
+	return
+}
+
+// Add adds a user to a content restriction. That is, grant read or update permission to the user for a piece of content.
+// Docs: https://docs.go-atlassian.io/confluence-cloud/content/restrictions/operations/user#add-user-to-content-restriction
+func (c *ContentRestrictionOperationUserService) Add(ctx context.Context, contentID, operationKey, accountID string) (
+	response *ResponseScheme, err error) {
+
+	if len(contentID) == 0 {
+		return nil, models.ErrNoContentIDError
+	}
+
+	if len(operationKey) == 0 {
+		return nil, models.ErrNoContentRestrictionKeyError
+	}
+
+	if len(accountID) == 0 {
+		return nil, models.ErrNoAccountIDError
+	}
+
+	var endpoint strings.Builder
+	endpoint.WriteString(fmt.Sprintf("wiki/rest/api/content/%v/restriction/byOperation/%v/user", contentID, operationKey))
+
+	query := url.Values{}
+	query.Add("accountId", accountID)
+
+	if query.Encode() != "" {
+		endpoint.WriteString(fmt.Sprintf("?%v", query.Encode()))
+	}
+
+	request, err := c.client.newRequest(ctx, http.MethodPut, endpoint.String(), nil)
+	if err != nil {
+		return nil, err
+	}
+
+	response, err = c.client.Call(request, nil)
+	if err != nil {
+		return response, err
+	}
+
+	return
+}
+
+// Remove removes a group from a content restriction. That is, remove read or update permission for the group for a piece of content.
+// Docs: https://docs.go-atlassian.io/confluence-cloud/content/restrictions/operations/user#remove-user-from-content-restriction
+func (c *ContentRestrictionOperationUserService) Remove(ctx context.Context, contentID, operationKey, accountID string) (
+	response *ResponseScheme, err error) {
+
+	if len(contentID) == 0 {
+		return nil, models.ErrNoContentIDError
+	}
+
+	if len(operationKey) == 0 {
+		return nil, models.ErrNoContentRestrictionKeyError
+	}
+
+	if len(accountID) == 0 {
+		return nil, models.ErrNoAccountIDError
+	}
+
+	var endpoint strings.Builder
+	endpoint.WriteString(fmt.Sprintf("wiki/rest/api/content/%v/restriction/byOperation/%v/user", contentID, operationKey))
+
+	query := url.Values{}
+	query.Add("accountId", accountID)
+
+	if query.Encode() != "" {
+		endpoint.WriteString(fmt.Sprintf("?%v", query.Encode()))
+	}
+
+	request, err := c.client.newRequest(ctx, http.MethodDelete, endpoint.String(), nil)
+	if err != nil {
+		return nil, err
+	}
+
+	response, err = c.client.Call(request, nil)
+	if err != nil {
+		return response, err
+	}
+
+	return
+}
diff --git a/confluence/contentRestrictionsOperation.go b/confluence/contentRestrictionsOperation.go
index 7d23b37..678e364 100644
--- a/confluence/contentRestrictionsOperation.go
+++ b/confluence/contentRestrictionsOperation.go
@@ -13,6 +13,7 @@ import (
 type ContentRestrictionOperationService struct {
 	client *Client
 	Group  *ContentRestrictionOperationGroupService
+	User   *ContentRestrictionOperationUserService
 }
 
 // Gets returns restrictions on a piece of content by operation.


Test patch:
diff --git a/confluence/contentRestrictionOperationUser_test.go b/confluence/contentRestrictionOperationUser_test.go
new file mode 100644
index 0000000..fb4f56d
--- /dev/null
+++ b/confluence/contentRestrictionOperationUser_test.go
@@ -0,0 +1,487 @@
+package confluence
+
+import (
+	"context"
+	"fmt"
+	"github.com/stretchr/testify/assert"
+	"net/http"
+	"net/url"
+	"testing"
+)
+
+func Test_Content_Restriction_Operation_User_Service_Get(t *testing.T) {
+
+	testCases := []struct {
+		name               string
+		contentID          string
+		operationKey       string
+		accountID          string
+		mockFile           string
+		wantHTTPMethod     string
+		endpoint           string
+		context            context.Context
+		wantHTTPCodeReturn int
+		wantErr            bool
+		expectedError      string
+	}{
+		{
+			name:               "when the params are correct",
+			contentID:          "7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			operationKey:       "read",
+			accountID:          "7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			wantHTTPMethod:     http.MethodGet,
+			endpoint:           "/wiki/rest/api/content/7747bbd7-ade1-401f-bcc2-eb24403e75f3/restriction/byOperation/read/user?accountId=7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			context:            context.Background(),
+			wantHTTPCodeReturn: http.StatusNoContent,
+		},
+
+		{
+			name:               "when the content id is not provided",
+			contentID:          "",
+			operationKey:       "read",
+			accountID:          "confluence-system-admins",
+			wantHTTPMethod:     http.MethodGet,
+			endpoint:           "/wiki/rest/api/content/7747bbd7-ade1-401f-bcc2-eb24403e75f3/restriction/byOperation/read/user?accountId=7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			context:            context.Background(),
+			wantHTTPCodeReturn: http.StatusNoContent,
+			wantErr:            true,
+			expectedError:      "confluence: no content id set",
+		},
+
+		{
+			name:               "when the operation key is not provided",
+			contentID:          "233838383",
+			operationKey:       "",
+			accountID:          "confluence-system-admins",
+			wantHTTPMethod:     http.MethodGet,
+			endpoint:           "/wiki/rest/api/content/7747bbd7-ade1-401f-bcc2-eb24403e75f3/restriction/byOperation/read/user?accountId=7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			context:            context.Background(),
+			wantHTTPCodeReturn: http.StatusNoContent,
+			wantErr:            true,
+			expectedError:      "confluence: no content restriction operation key set",
+		},
+
+		{
+			name:               "when the accountID is not provided",
+			contentID:          "233838383",
+			operationKey:       "read",
+			accountID:          "",
+			wantHTTPMethod:     http.MethodGet,
+			endpoint:           "/wiki/rest/api/content/7747bbd7-ade1-401f-bcc2-eb24403e75f3/restriction/byOperation/read/user?accountId=7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			context:            context.Background(),
+			wantHTTPCodeReturn: http.StatusNoContent,
+			wantErr:            true,
+			expectedError:      "jira: no account id set",
+		},
+
+		{
+			name:               "when the response status is not correct",
+			contentID:          "7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			operationKey:       "read",
+			accountID:          "7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			wantHTTPMethod:     http.MethodGet,
+			endpoint:           "/wiki/rest/api/content/7747bbd7-ade1-401f-bcc2-eb24403e75f3/restriction/byOperation/read/user?accountId=7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			context:            context.Background(),
+			wantHTTPCodeReturn: http.StatusBadRequest,
+			wantErr:            true,
+			expectedError:      "unexpected end of JSON input",
+		},
+
+		{
+			name:               "when the context is not provided",
+			contentID:          "233838383",
+			operationKey:       "read",
+			accountID:          "confluence-system-admins",
+			wantHTTPMethod:     http.MethodGet,
+			endpoint:           "/wiki/rest/api/content/7747bbd7-ade1-401f-bcc2-eb24403e75f3/restriction/byOperation/read/user?accountId=7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			context:            nil,
+			wantHTTPCodeReturn: http.StatusNoContent,
+			wantErr:            true,
+			expectedError:      "request creation failed: net/http: nil Context",
+		},
+	}
+	for _, testCase := range testCases {
+		t.Run(testCase.name, func(t *testing.T) {
+
+			//Init a new HTTP mock server
+			mockOptions := mockServerOptions{
+				Endpoint:           testCase.endpoint,
+				MockFilePath:       testCase.mockFile,
+				MethodAccepted:     testCase.wantHTTPMethod,
+				ResponseCodeWanted: testCase.wantHTTPCodeReturn,
+			}
+
+			mockServer, err := startMockServer(&mockOptions)
+			if err != nil {
+				t.Fatal(err)
+			}
+
+			defer mockServer.Close()
+
+			//Init the library instance
+			mockClient, err := startMockClient(mockServer.URL)
+			if err != nil {
+				t.Fatal(err)
+			}
+
+			service := &ContentRestrictionOperationUserService{client: mockClient}
+
+			gotResponse, err := service.Get(testCase.context, testCase.contentID, testCase.operationKey, testCase.accountID)
+
+			if testCase.wantErr {
+
+				if err != nil {
+					t.Logf("error returned: %v", err.Error())
+				}
+
+				assert.EqualError(t, err, testCase.expectedError)
+
+				if gotResponse != nil {
+					t.Logf("HTTP Code Wanted: %v, HTTP Code Returned: %v", testCase.wantHTTPCodeReturn, gotResponse.Code)
+				}
+
+			} else {
+
+				assert.NoError(t, err)
+				assert.NotEqual(t, gotResponse, nil)
+
+				apiEndpoint, err := url.Parse(gotResponse.Endpoint)
+				if err != nil {
+					t.Fatal(err)
+				}
+
+				var endpointToAssert string
+
+				if apiEndpoint.Query().Encode() != "" {
+					endpointToAssert = fmt.Sprintf("%v?%v", apiEndpoint.Path, apiEndpoint.Query().Encode())
+				} else {
+					endpointToAssert = apiEndpoint.Path
+				}
+
+				t.Logf("HTTP Endpoint Wanted: %v, HTTP Endpoint Returned: %v", testCase.endpoint, endpointToAssert)
+				assert.Equal(t, testCase.endpoint, endpointToAssert)
+
+				t.Logf("HTTP Code Wanted: %v, HTTP Code Returned: %v", testCase.wantHTTPCodeReturn, gotResponse.Code)
+				assert.Equal(t, gotResponse.Code, testCase.wantHTTPCodeReturn)
+			}
+		})
+	}
+}
+
+func Test_Content_Restriction_Operation_User_Service_Add(t *testing.T) {
+
+	testCases := []struct {
+		name               string
+		contentID          string
+		operationKey       string
+		accountID          string
+		mockFile           string
+		wantHTTPMethod     string
+		endpoint           string
+		context            context.Context
+		wantHTTPCodeReturn int
+		wantErr            bool
+		expectedError      string
+	}{
+		{
+			name:               "when the params are correct",
+			contentID:          "7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			operationKey:       "read",
+			accountID:          "7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			wantHTTPMethod:     http.MethodPut,
+			endpoint:           "/wiki/rest/api/content/7747bbd7-ade1-401f-bcc2-eb24403e75f3/restriction/byOperation/read/user?accountId=7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			context:            context.Background(),
+			wantHTTPCodeReturn: http.StatusNoContent,
+		},
+
+		{
+			name:               "when the content id is not provided",
+			contentID:          "",
+			operationKey:       "read",
+			accountID:          "confluence-system-admins",
+			wantHTTPMethod:     http.MethodPut,
+			endpoint:           "/wiki/rest/api/content/7747bbd7-ade1-401f-bcc2-eb24403e75f3/restriction/byOperation/read/user?accountId=7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			context:            context.Background(),
+			wantHTTPCodeReturn: http.StatusNoContent,
+			wantErr:            true,
+			expectedError:      "confluence: no content id set",
+		},
+
+		{
+			name:               "when the operation key is not provided",
+			contentID:          "233838383",
+			operationKey:       "",
+			accountID:          "confluence-system-admins",
+			wantHTTPMethod:     http.MethodPut,
+			endpoint:           "/wiki/rest/api/content/7747bbd7-ade1-401f-bcc2-eb24403e75f3/restriction/byOperation/read/user?accountId=7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			context:            context.Background(),
+			wantHTTPCodeReturn: http.StatusNoContent,
+			wantErr:            true,
+			expectedError:      "confluence: no content restriction operation key set",
+		},
+
+		{
+			name:               "when the accountID is not provided",
+			contentID:          "233838383",
+			operationKey:       "read",
+			accountID:          "",
+			wantHTTPMethod:     http.MethodPut,
+			endpoint:           "/wiki/rest/api/content/7747bbd7-ade1-401f-bcc2-eb24403e75f3/restriction/byOperation/read/user?accountId=7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			context:            context.Background(),
+			wantHTTPCodeReturn: http.StatusNoContent,
+			wantErr:            true,
+			expectedError:      "jira: no account id set",
+		},
+
+		{
+			name:               "when the response status is not correct",
+			contentID:          "7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			operationKey:       "read",
+			accountID:          "7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			wantHTTPMethod:     http.MethodPut,
+			endpoint:           "/wiki/rest/api/content/7747bbd7-ade1-401f-bcc2-eb24403e75f3/restriction/byOperation/read/user?accountId=7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			context:            context.Background(),
+			wantHTTPCodeReturn: http.StatusBadRequest,
+			wantErr:            true,
+			expectedError:      "unexpected end of JSON input",
+		},
+
+		{
+			name:               "when the context is not provided",
+			contentID:          "233838383",
+			operationKey:       "read",
+			accountID:          "confluence-system-admins",
+			wantHTTPMethod:     http.MethodPut,
+			endpoint:           "/wiki/rest/api/content/7747bbd7-ade1-401f-bcc2-eb24403e75f3/restriction/byOperation/read/user?accountId=7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			context:            nil,
+			wantHTTPCodeReturn: http.StatusNoContent,
+			wantErr:            true,
+			expectedError:      "request creation failed: net/http: nil Context",
+		},
+	}
+	for _, testCase := range testCases {
+		t.Run(testCase.name, func(t *testing.T) {
+
+			//Init a new HTTP mock server
+			mockOptions := mockServerOptions{
+				Endpoint:           testCase.endpoint,
+				MockFilePath:       testCase.mockFile,
+				MethodAccepted:     testCase.wantHTTPMethod,
+				ResponseCodeWanted: testCase.wantHTTPCodeReturn,
+			}
+
+			mockServer, err := startMockServer(&mockOptions)
+			if err != nil {
+				t.Fatal(err)
+			}
+
+			defer mockServer.Close()
+
+			//Init the library instance
+			mockClient, err := startMockClient(mockServer.URL)
+			if err != nil {
+				t.Fatal(err)
+			}
+
+			service := &ContentRestrictionOperationUserService{client: mockClient}
+
+			gotResponse, err := service.Add(testCase.context, testCase.contentID, testCase.operationKey, testCase.accountID)
+
+			if testCase.wantErr {
+
+				if err != nil {
+					t.Logf("error returned: %v", err.Error())
+				}
+
+				assert.EqualError(t, err, testCase.expectedError)
+
+				if gotResponse != nil {
+					t.Logf("HTTP Code Wanted: %v, HTTP Code Returned: %v", testCase.wantHTTPCodeReturn, gotResponse.Code)
+				}
+
+			} else {
+
+				assert.NoError(t, err)
+				assert.NotEqual(t, gotResponse, nil)
+
+				apiEndpoint, err := url.Parse(gotResponse.Endpoint)
+				if err != nil {
+					t.Fatal(err)
+				}
+
+				var endpointToAssert string
+
+				if apiEndpoint.Query().Encode() != "" {
+					endpointToAssert = fmt.Sprintf("%v?%v", apiEndpoint.Path, apiEndpoint.Query().Encode())
+				} else {
+					endpointToAssert = apiEndpoint.Path
+				}
+
+				t.Logf("HTTP Endpoint Wanted: %v, HTTP Endpoint Returned: %v", testCase.endpoint, endpointToAssert)
+				assert.Equal(t, testCase.endpoint, endpointToAssert)
+
+				t.Logf("HTTP Code Wanted: %v, HTTP Code Returned: %v", testCase.wantHTTPCodeReturn, gotResponse.Code)
+				assert.Equal(t, gotResponse.Code, testCase.wantHTTPCodeReturn)
+			}
+		})
+	}
+}
+
+func Test_Content_Restriction_Operation_User_Service_Remove(t *testing.T) {
+
+	testCases := []struct {
+		name               string
+		contentID          string
+		operationKey       string
+		accountID          string
+		mockFile           string
+		wantHTTPMethod     string
+		endpoint           string
+		context            context.Context
+		wantHTTPCodeReturn int
+		wantErr            bool
+		expectedError      string
+	}{
+		{
+			name:               "when the params are correct",
+			contentID:          "7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			operationKey:       "read",
+			accountID:          "7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			wantHTTPMethod:     http.MethodDelete,
+			endpoint:           "/wiki/rest/api/content/7747bbd7-ade1-401f-bcc2-eb24403e75f3/restriction/byOperation/read/user?accountId=7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			context:            context.Background(),
+			wantHTTPCodeReturn: http.StatusNoContent,
+		},
+
+		{
+			name:               "when the content id is not provided",
+			contentID:          "",
+			operationKey:       "read",
+			accountID:          "confluence-system-admins",
+			wantHTTPMethod:     http.MethodDelete,
+			endpoint:           "/wiki/rest/api/content/7747bbd7-ade1-401f-bcc2-eb24403e75f3/restriction/byOperation/read/user?accountId=7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			context:            context.Background(),
+			wantHTTPCodeReturn: http.StatusNoContent,
+			wantErr:            true,
+			expectedError:      "confluence: no content id set",
+		},
+
+		{
+			name:               "when the operation key is not provided",
+			contentID:          "233838383",
+			operationKey:       "",
+			accountID:          "confluence-system-admins",
+			wantHTTPMethod:     http.MethodDelete,
+			endpoint:           "/wiki/rest/api/content/7747bbd7-ade1-401f-bcc2-eb24403e75f3/restriction/byOperation/read/user?accountId=7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			context:            context.Background(),
+			wantHTTPCodeReturn: http.StatusNoContent,
+			wantErr:            true,
+			expectedError:      "confluence: no content restriction operation key set",
+		},
+
+		{
+			name:               "when the accountID is not provided",
+			contentID:          "233838383",
+			operationKey:       "read",
+			accountID:          "",
+			wantHTTPMethod:     http.MethodDelete,
+			endpoint:           "/wiki/rest/api/content/7747bbd7-ade1-401f-bcc2-eb24403e75f3/restriction/byOperation/read/user?accountId=7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			context:            context.Background(),
+			wantHTTPCodeReturn: http.StatusNoContent,
+			wantErr:            true,
+			expectedError:      "jira: no account id set",
+		},
+
+		{
+			name:               "when the response status is not correct",
+			contentID:          "7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			operationKey:       "read",
+			accountID:          "7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			wantHTTPMethod:     http.MethodDelete,
+			endpoint:           "/wiki/rest/api/content/7747bbd7-ade1-401f-bcc2-eb24403e75f3/restriction/byOperation/read/user?accountId=7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			context:            context.Background(),
+			wantHTTPCodeReturn: http.StatusBadRequest,
+			wantErr:            true,
+			expectedError:      "unexpected end of JSON input",
+		},
+
+		{
+			name:               "when the context is not provided",
+			contentID:          "233838383",
+			operationKey:       "read",
+			accountID:          "confluence-system-admins",
+			wantHTTPMethod:     http.MethodDelete,
+			endpoint:           "/wiki/rest/api/content/7747bbd7-ade1-401f-bcc2-eb24403e75f3/restriction/byOperation/read/user?accountId=7747bbd7-ade1-401f-bcc2-eb24403e75f3",
+			context:            nil,
+			wantHTTPCodeReturn: http.StatusNoContent,
+			wantErr:            true,
+			expectedError:      "request creation failed: net/http: nil Context",
+		},
+	}
+	for _, testCase := range testCases {
+		t.Run(testCase.name, func(t *testing.T) {
+
+			//Init a new HTTP mock server
+			mockOptions := mockServerOptions{
+				Endpoint:           testCase.endpoint,
+				MockFilePath:       testCase.mockFile,
+				MethodAccepted:     testCase.wantHTTPMethod,
+				ResponseCodeWanted: testCase.wantHTTPCodeReturn,
+			}
+
+			mockServer, err := startMockServer(&mockOptions)
+			if err != nil {
+				t.Fatal(err)
+			}
+
+			defer mockServer.Close()
+
+			//Init the library instance
+			mockClient, err := startMockClient(mockServer.URL)
+			if err != nil {
+				t.Fatal(err)
+			}
+
+			service := &ContentRestrictionOperationUserService{client: mockClient}
+
+			gotResponse, err := service.Remove(testCase.context, testCase.contentID, testCase.operationKey, testCase.accountID)
+
+			if testCase.wantErr {
+
+				if err != nil {
+					t.Logf("error returned: %v", err.Error())
+				}
+
+				assert.EqualError(t, err, testCase.expectedError)
+
+				if gotResponse != nil {
+					t.Logf("HTTP Code Wanted: %v, HTTP Code Returned: %v", testCase.wantHTTPCodeReturn, gotResponse.Code)
+				}
+
+			} else {
+
+				assert.NoError(t, err)
+				assert.NotEqual(t, gotResponse, nil)
+
+				apiEndpoint, err := url.Parse(gotResponse.Endpoint)
+				if err != nil {
+					t.Fatal(err)
+				}
+
+				var endpointToAssert string
+
+				if apiEndpoint.Query().Encode() != "" {
+					endpointToAssert = fmt.Sprintf("%v?%v", apiEndpoint.Path, apiEndpoint.Query().Encode())
+				} else {
+					endpointToAssert = apiEndpoint.Path
+				}
+
+				t.Logf("HTTP Endpoint Wanted: %v, HTTP Endpoint Returned: %v", testCase.endpoint, endpointToAssert)
+				assert.Equal(t, testCase.endpoint, endpointToAssert)
+
+				t.Logf("HTTP Code Wanted: %v, HTTP Code Returned: %v", testCase.wantHTTPCodeReturn, gotResponse.Code)
+				assert.Equal(t, gotResponse.Code, testCase.wantHTTPCodeReturn)
+			}
+		})
+	}
+}