Skip to content

Commit 0c29184

Browse files
committed
Fix unit tests
1 parent 173fc65 commit 0c29184

38 files changed

Lines changed: 1300 additions & 1066 deletions

backend/.mockery.private.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,20 +157,28 @@ packages:
157157
pkgname: security
158158
filename: "{{.InterfaceName}}_mock_test.go"
159159

160-
github.com/asgardeo/thunder/internal/branding/mgt:
160+
github.com/asgardeo/thunder/internal/design/theme/mgt:
161161
config:
162162
all: true
163-
dir: internal/branding/mgt
163+
dir: internal/design/theme/mgt
164164
structname: '{{.InterfaceName}}Mock'
165-
pkgname: brandingmgt
165+
pkgname: thememgt
166166
filename: "{{.InterfaceName}}_mock_test.go"
167167

168-
github.com/asgardeo/thunder/internal/branding/resolve:
168+
github.com/asgardeo/thunder/internal/design/layout/mgt:
169169
config:
170170
all: true
171-
dir: internal/branding/resolve
171+
dir: internal/design/layout/mgt
172172
structname: '{{.InterfaceName}}Mock'
173-
pkgname: brandingresolve
173+
pkgname: layoutmgt
174+
filename: "{{.InterfaceName}}_mock_test.go"
175+
176+
github.com/asgardeo/thunder/internal/design/resolve:
177+
config:
178+
all: true
179+
dir: internal/design/resolve
180+
structname: '{{.InterfaceName}}Mock'
181+
pkgname: designresolve
174182
filename: "{{.InterfaceName}}_mock_test.go"
175183

176184
github.com/asgardeo/thunder/internal/oauth/oauth2/userinfo:

backend/.mockery.public.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,20 @@ packages:
349349
pkgname: observabilitymock
350350
filename: "{{.InterfaceName}}_mock.go"
351351

352-
github.com/asgardeo/thunder/internal/branding/mgt:
352+
github.com/asgardeo/thunder/internal/design/theme/mgt:
353353
config:
354354
all: true
355-
dir: tests/mocks/brandingmock
355+
dir: tests/mocks/design/thememock
356356
structname: '{{.InterfaceName}}Mock'
357-
pkgname: brandingmock
357+
pkgname: thememock
358+
filename: "{{.InterfaceName}}_mock.go"
359+
360+
github.com/asgardeo/thunder/internal/design/layout/mgt:
361+
config:
362+
all: true
363+
dir: tests/mocks/design/layoutmock
364+
structname: '{{.InterfaceName}}Mock'
365+
pkgname: layoutmock
358366
filename: "{{.InterfaceName}}_mock.go"
359367

360368
github.com/asgardeo/thunder/internal/system/crypto/hash:

backend/internal/application/error_constants.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -201,32 +201,24 @@ var (
201201
Error: "Invalid user type",
202202
ErrorDescription: "One or more user types in allowed_user_types do not exist in the system",
203203
}
204-
// ErrorBrandingNotFound is the error returned when branding is not found.
205-
// DEPRECATED: Use ErrorThemeNotFound and ErrorLayoutNotFound instead
206-
ErrorBrandingNotFound = serviceerror.ServiceError{
207-
Type: serviceerror.ClientErrorType,
208-
Code: "APP-1026",
209-
Error: "Branding not found",
210-
ErrorDescription: "The specified branding configuration does not exist",
211-
}
212204
// ErrorThemeNotFound is the error returned when theme is not found.
213205
ErrorThemeNotFound = serviceerror.ServiceError{
214206
Type: serviceerror.ClientErrorType,
215-
Code: "APP-1027",
207+
Code: "APP-1026",
216208
Error: "Theme not found",
217209
ErrorDescription: "The specified theme configuration does not exist",
218210
}
219211
// ErrorLayoutNotFound is the error returned when layout is not found.
220212
ErrorLayoutNotFound = serviceerror.ServiceError{
221213
Type: serviceerror.ClientErrorType,
222-
Code: "APP-1028",
214+
Code: "APP-1027",
223215
Error: "Layout not found",
224216
ErrorDescription: "The specified layout configuration does not exist",
225217
}
226218
// ErrorWhileRetrievingFlowDefinition is the error returned when there is an issue retrieving flow definition.
227219
ErrorWhileRetrievingFlowDefinition = serviceerror.ServiceError{
228220
Type: serviceerror.ClientErrorType,
229-
Code: "APP-1029",
221+
Code: "APP-1028",
230222
Error: "Error retrieving flow definition",
231223
ErrorDescription: "An error occurred while retrieving the flow definition",
232224
}

backend/internal/application/init_test.go

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"github.com/asgardeo/thunder/internal/cert"
2828
oauth2const "github.com/asgardeo/thunder/internal/oauth/oauth2/constants"
2929
"github.com/asgardeo/thunder/internal/system/config"
30-
"github.com/asgardeo/thunder/tests/mocks/brandingmock"
3130
"github.com/asgardeo/thunder/tests/mocks/certmock"
3231
"github.com/asgardeo/thunder/tests/mocks/flow/flowmgtmock"
3332
"github.com/asgardeo/thunder/tests/mocks/userschemamock"
@@ -46,14 +45,12 @@ type InitTestSuite struct {
4645
suite.Suite
4746
mockCertService *certmock.CertificateServiceInterfaceMock
4847
mockFlowMgtService *flowmgtmock.FlowMgtServiceInterfaceMock
49-
mockBrandingService *brandingmock.BrandingMgtServiceInterfaceMock
5048
mockUserSchemaService *userschemamock.UserSchemaServiceInterfaceMock
5149
}
5250

5351
func (suite *InitTestSuite) SetupTest() {
5452
suite.mockCertService = certmock.NewCertificateServiceInterfaceMock(suite.T())
5553
suite.mockFlowMgtService = flowmgtmock.NewFlowMgtServiceInterfaceMock(suite.T())
56-
suite.mockBrandingService = brandingmock.NewBrandingMgtServiceInterfaceMock(suite.T())
5754
suite.mockUserSchemaService = userschemamock.NewUserSchemaServiceInterfaceMock(suite.T())
5855
}
5956

@@ -85,6 +82,8 @@ func (suite *InitTestSuite) TestInitialize_WithDeclarativeResourcesDisabled() {
8582
mux,
8683
suite.mockCertService,
8784
suite.mockFlowMgtService,
85+
nil, // themeMgtService - not needed for this test
86+
nil, // layoutMgtService - not needed for this test
8887
suite.mockUserSchemaService,
8988
)
9089

@@ -475,11 +474,17 @@ func TestInitialize_Standalone(t *testing.T) {
475474
mux := http.NewServeMux()
476475
mockCertService := certmock.NewCertificateServiceInterfaceMock(t)
477476
mockFlowMgtService := flowmgtmock.NewFlowMgtServiceInterfaceMock(t)
478-
mockBrandingService := brandingmock.NewBrandingMgtServiceInterfaceMock(t)
479477
mockUserSchemaService := userschemamock.NewUserSchemaServiceInterfaceMock(t)
480478

481479
// Execute
482-
service, _, err := Initialize(mux, mockCertService, mockFlowMgtService, mockUserSchemaService)
480+
service, _, err := Initialize(
481+
mux,
482+
mockCertService,
483+
mockFlowMgtService,
484+
nil, // themeMgtService - not needed for this test
485+
nil, // layoutMgtService - not needed for this test
486+
mockUserSchemaService,
487+
)
483488

484489
// Assert
485490
assert.NoError(t, err)
@@ -515,11 +520,17 @@ func TestInitialize_WithDeclarativeResources_Standalone(t *testing.T) {
515520
mux := http.NewServeMux()
516521
mockCertService := certmock.NewCertificateServiceInterfaceMock(t)
517522
mockFlowMgtService := flowmgtmock.NewFlowMgtServiceInterfaceMock(t)
518-
mockBrandingService := brandingmock.NewBrandingMgtServiceInterfaceMock(t)
519523
mockUserSchemaService := userschemamock.NewUserSchemaServiceInterfaceMock(t)
520524

521525
// Execute
522-
service, _, err := Initialize(mux, mockCertService, mockFlowMgtService, mockUserSchemaService)
526+
service, _, err := Initialize(
527+
mux,
528+
mockCertService,
529+
mockFlowMgtService,
530+
nil, // themeMgtService - not needed for this test
531+
nil, // layoutMgtService - not needed for this test
532+
mockUserSchemaService,
533+
)
523534

524535
// Assert
525536
assert.NoError(t, err)

backend/internal/design/layout/mgt/handler.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,16 @@ func (lh *layoutMgtHandler) HandleLayoutListRequest(w http.ResponseWriter, r *ht
6161
return
6262
}
6363

64-
layouts := make([]Layout, 0, len(layoutList.Layouts))
64+
layouts := make([]LayoutListItem, 0, len(layoutList.Layouts))
6565
for _, layout := range layoutList.Layouts {
66-
layouts = append(layouts, Layout{
66+
layouts = append(layouts, LayoutListItem{
6767
ID: layout.ID,
6868
DisplayName: layout.DisplayName,
6969
Description: layout.Description,
70-
Layout: layout.Layout,
7170
})
7271
}
7372

74-
layoutListResponse := &LayoutListResponseWithFullLayouts{
73+
layoutListResponse := &LayoutListResponse{
7574
TotalResults: layoutList.TotalResults,
7675
StartIndex: layoutList.StartIndex,
7776
Count: layoutList.Count,

0 commit comments

Comments
 (0)