-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
180 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ jobs: | |
AIO_RUNTIME_AUTH: ${{ secrets.AIO_RUNTIME_AUTH_STAGE }} | ||
GROUP_CHECK_URL: ${{ vars.GROUP_CHECK_URL }} | ||
GRAYBOX_USER_GROUPS: ${{ vars.GRAYBOX_USER_GROUPS }} | ||
SPLUNK_HEC__HEC_TOKEN: ${{ secrets.SPLUNK_HEC_TOKEN_STAGE }} | ||
uses: adobe/[email protected] | ||
with: | ||
os: ${{ matrix.os }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* ************************************************************************ | ||
* ADOBE CONFIDENTIAL | ||
* ___________________ | ||
* | ||
* Copyright 2024 Adobe | ||
* All Rights Reserved. | ||
* | ||
* NOTICE: All information contained herein is, and remains | ||
* the property of Adobe and its suppliers, if any. The intellectual | ||
* and technical concepts contained herein are proprietary to Adobe | ||
* and its suppliers and are protected by all applicable intellectual | ||
* property laws, including trade secret and copyright laws. | ||
* Dissemination of this information or reproduction of this material | ||
* is strictly forbidden unless prior written permission is obtained | ||
* from Adobe. | ||
************************************************************************* */ | ||
|
||
const { validateAction } = require('../../actions/graybox/validateAction'); // Update the path accordingly | ||
const GrayboxUser = require('../../actions/grayboxUser'); | ||
|
||
const mockValidParams = { | ||
rootFolder: '/app', | ||
gbRootFolder: '/app-graybox', | ||
projectExcelPath: '/path/to/excel.xlsx', | ||
experienceName: '/max', | ||
spToken: 'abcde', | ||
adminPageUri: 'https://a.com/path?ref=branch&repo=app&owner=org', | ||
draftsOnly: true, | ||
promoteIgnorePaths: '/path1' | ||
}; | ||
|
||
// Mock GrayboxUser class and its methods | ||
jest.mock('../../actions/grayboxUser', () => jest.fn().mockImplementation(() => ({ | ||
isInGroups: jest.fn().mockResolvedValue(true) | ||
}))); | ||
|
||
describe('validateAction', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
test('should return 400 if required params are missing', async () => { | ||
const params = { | ||
// Missing some required parameters | ||
}; | ||
const grpIds = []; | ||
const result = await validateAction(params, grpIds); | ||
expect(result.code).toBe(400); | ||
}); | ||
|
||
test('should return 401 if user is not authorized', async () => { | ||
const params = mockValidParams; | ||
const grpIds = []; | ||
|
||
// Mocking user not authorized | ||
GrayboxUser.mockImplementation(() => ({ | ||
isInGroups: jest.fn().mockResolvedValue(false) | ||
})); | ||
const result = await validateAction(params, grpIds); | ||
expect(result.code).toBe(401); | ||
}); | ||
|
||
test('should return 200 if user is authorized and all required params are present', async () => { | ||
const params = mockValidParams; | ||
const grpIds = []; | ||
|
||
// Mocking user authorized | ||
GrayboxUser.mockImplementation(() => ({ | ||
isInGroups: jest.fn().mockResolvedValue(true) | ||
})); | ||
const result = await validateAction(params, grpIds); | ||
expect(result.code).toBe(200); | ||
}); | ||
|
||
test('should return 200 if ignoreUserCheck is true', async () => { | ||
const params = mockValidParams; | ||
const grpIds = []; | ||
const result = await validateAction(params, grpIds, true); | ||
expect(result.code).toBe(200); | ||
// GrayboxUser constructor should not get called | ||
expect(GrayboxUser).not.toHaveBeenCalled(); | ||
}); | ||
}); |