mirror of
https://github.com/LukeHagar/sailpoint-cli.git
synced 2025-12-06 04:21:15 +00:00
57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
// Copyright (c) 2023, SailPoint Technologies, Inc. All rights reserved.
|
|
package connector
|
|
|
|
import (
|
|
"bytes"
|
|
"io"
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/golang/mock/gomock"
|
|
"github.com/sailpoint-oss/sailpoint-cli/internal/mocks"
|
|
)
|
|
|
|
func TestAccountDeleteWithoutInput(t *testing.T) {
|
|
ctrl := gomock.NewController(t)
|
|
defer ctrl.Finish()
|
|
|
|
client := mocks.NewMockClient(ctrl)
|
|
|
|
cmd := newConnInvokeAccountDeleteCmd(client)
|
|
addRequiredFlagsFromParentCmd(cmd)
|
|
|
|
b := new(bytes.Buffer)
|
|
cmd.SetOut(b)
|
|
cmd.SetArgs([]string{"-c", "test-connector", "--config-json", "{}"})
|
|
|
|
err := cmd.Execute()
|
|
if err == nil {
|
|
t.Errorf("failed to detect error: deleting account without identity")
|
|
}
|
|
}
|
|
|
|
func TestAccountDeleteWithIdentity(t *testing.T) {
|
|
ctrl := gomock.NewController(t)
|
|
defer ctrl.Finish()
|
|
|
|
i := `{"connectorRef":"test-connector","tag":"latest","type":"std:account:delete","config":{},` +
|
|
`"input":{"identity":"john.doe","key":{"simple":{"id":"john.doe"}}}}`
|
|
|
|
client := mocks.NewMockClient(ctrl)
|
|
client.EXPECT().
|
|
Post(gomock.Any(), gomock.Any(), "application/json", bytes.NewReader([]byte(i))).
|
|
Return(&http.Response{StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte("{}")))}, nil)
|
|
|
|
cmd := newConnInvokeAccountDeleteCmd(client)
|
|
addRequiredFlagsFromParentCmd(cmd)
|
|
|
|
b := new(bytes.Buffer)
|
|
cmd.SetOut(b)
|
|
cmd.SetArgs([]string{"john.doe", "-c", "test-connector", "--config-json", "{}"})
|
|
|
|
err := cmd.Execute()
|
|
if err != nil {
|
|
t.Errorf("command failed with err: %s", err)
|
|
}
|
|
}
|