MCPcopy Create free account
hub / github.com/auth0/auth0-cli / TestAddLocalCallbackURLToClient

Function TestAddLocalCallbackURLToClient

internal/cli/utils_shared_test.go:180–256  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

178}
179
180func TestAddLocalCallbackURLToClient(t *testing.T) {
181 tests := []struct {
182 name string
183 intialClient *management.Client
184 finalClient *management.Client
185 apiError error
186 assertOutput func(t testing.TB, result bool)
187 assertError func(t testing.TB, err error)
188 }{
189 {
190 name: "adds the callback",
191 intialClient: &management.Client{ClientID: auth0.String("")},
192 finalClient: &management.Client{
193 Callbacks: &[]string{cliLoginTestingCallbackURL},
194 },
195 assertOutput: func(t testing.TB, result bool) {
196 assert.True(t, result)
197 },
198 assertError: func(t testing.TB, err error) {
199 t.Fail()
200 },
201 },
202 {
203 name: "does not add the callback when alredy present",
204 intialClient: &management.Client{
205 ClientID: auth0.String(""),
206 Callbacks: &[]string{
207 "http://localhost:3000",
208 cliLoginTestingCallbackURL,
209 },
210 },
211 assertOutput: func(t testing.TB, result bool) {
212 assert.False(t, result)
213 },
214 assertError: func(t testing.TB, err error) {
215 t.Fail()
216 },
217 },
218 {
219 name: "returns the API error",
220 intialClient: &management.Client{ClientID: auth0.String("")},
221 finalClient: &management.Client{
222 Callbacks: &[]string{cliLoginTestingCallbackURL},
223 },
224 apiError: errors.New("error"),
225 assertError: func(t testing.TB, err error) {
226 assert.Error(t, err)
227 },
228 },
229 }
230
231 for _, test := range tests {
232 t.Run(test.name, func(t *testing.T) {
233 ctrl := gomock.NewController(t)
234 defer ctrl.Finish()
235
236 timesAPIShouldBeCalled := 1
237 if test.finalClient == nil {

Callers

nothing calls this directly

Calls 5

EXPECTMethod · 0.95
NewMockClientAPIFunction · 0.92
UpdateMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected