Skip to content

Commit

Permalink
Add DeactivateSOL test
Browse files Browse the repository at this point in the history
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
  • Loading branch information
zevweiss committed Jan 9, 2024
1 parent 31c850a commit 105270e
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions grpc/rpc/bmc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,64 @@ func TestReset(t *testing.T) {
}
}

func newDeactivateSOLRequest(authErr bool) *v1.DeactivateSOLRequest {
var auth *v1.DirectAuthn
if authErr {
auth = &v1.DirectAuthn{
Host: &v1.Host{
Host: "",
},
Username: "ADMIN",
Password: "ADMIN",
}
} else {
auth = &v1.DirectAuthn{
Host: &v1.Host{
Host: "127.0.0.1",
},
Username: "ADMIN",
Password: "ADMIN",
}
}
return &v1.DeactivateSOLRequest{
Authn: &v1.Authn{
Authn: &v1.Authn_DirectAuthn{
DirectAuthn: auth,
},
},
Vendor: &v1.Vendor{
Name: "local",
},
}
}

func TestDeactivateSOL(t *testing.T) {
testCases := []struct {
name string
expectedErr error
in *v1.DeactivateSOLRequest
out *v1.DeactivateSOLResponse
}{
{"success", nil, newDeactivateSOLRequest(false), &v1.DeactivateSOLResponse{TaskId: ""}},
{"missing auth err", errors.New("input arguments are invalid: invalid field Authn.DirectAuthn.Host.Host: value '' must not be an empty string"), newDeactivateSOLRequest(true), nil},
}

for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
response, err := bmcService.DeactivateSOL(ctx, tc.in)
if err != nil {
diff := cmp.Diff(tc.expectedErr.Error(), err.Error())
if diff != "" {
t.Fatal(diff)
}
} else if response.TaskId == "" {
t.Fatal("expected taskId, got:", response.TaskId)
}
})
}
}

func newCreateUserRequest(authErr bool) *v1.CreateUserRequest {
var auth *v1.DirectAuthn
if authErr {
Expand Down

0 comments on commit 105270e

Please # to comment.