-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AUTO] Increment version to 2.16.0.0 #2067
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
53d418f
Update nextUrl validation to incorporate serverBasePath (#2048) (#2049)
opensearch-trigger-bot[bot] 0c0ffc3
[MDS] Adds datasource filter for version decoupling (#2051) (#2052)
DarshitChanpura 4d021e4
Add retry to bootstrap for windows related workflows (#2047) (#2058)
opensearch-trigger-bot[bot] fc30be9
[AUTO] Format opensearch_dashboards.json (#2059)
opensearch-trigger-bot[bot] 0e6e146
Adds 2.16 release notes (#2061) (#2062)
opensearch-trigger-bot[bot] b0834e0
Do not register tenancy app if disabled in yml (#2057) (#2065)
opensearch-trigger-bot[bot] 965d304
Increment version to 2.16.0.0
opensearch-ci-bot 3c0a789
Merge branch '2.16' into create-pull-request/2.16.0.0
derek-ho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,178 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
import { coreMock } from '../../../../src/core/public/mocks'; | ||
import { SecurityPlugin } from '../plugin.ts'; | ||
import * as pluginModule from '../plugin'; // Import the entire module to mock specific functions | ||
import { | ||
PLUGIN_AUDITLOG_APP_ID, | ||
PLUGIN_AUTH_APP_ID, | ||
PLUGIN_GET_STARTED_APP_ID, | ||
PLUGIN_PERMISSIONS_APP_ID, | ||
PLUGIN_ROLES_APP_ID, | ||
PLUGIN_TENANTS_APP_ID, | ||
PLUGIN_USERS_APP_ID, | ||
} from '../../common/index.ts'; | ||
|
||
// Mock the hasApiPermission function | ||
jest.mock('../plugin', () => { | ||
const originalModule = jest.requireActual('../plugin'); | ||
return { | ||
...originalModule, | ||
hasApiPermission: jest.fn(), // Mock the function here | ||
}; | ||
}); | ||
|
||
describe('SecurityPlugin', () => { | ||
let plugin; | ||
let coreSetup; | ||
let coreStart; | ||
let initializerContext; | ||
let deps; | ||
|
||
beforeEach(() => { | ||
coreSetup = coreMock.createSetup(); | ||
coreStart = coreMock.createStart(); | ||
initializerContext = { | ||
config: { | ||
get: jest.fn().mockReturnValue({ | ||
readonly_mode: { roles: [] }, | ||
multitenancy: { enabled: true, enable_aggregation_view: false }, | ||
clusterPermissions: { include: [] }, | ||
indexPermissions: { include: [] }, | ||
disabledTransportCategories: { exclude: [] }, | ||
disabledRestCategories: { exclude: [] }, | ||
ui: { autologout: false }, | ||
}), | ||
}, | ||
}; | ||
deps = { | ||
dataSource: { dataSourceEnabled: true }, | ||
savedObjectsManagement: { createSetup: jest.fn() }, | ||
}; | ||
}); | ||
|
||
it('does not call register function for certain applications when getNavGroupEnabled is off', async () => { | ||
// Mock hasApiPermission to return false | ||
pluginModule.hasApiPermission.mockResolvedValue(false); // Access the mock via the imported module | ||
|
||
// Instantiate the plugin after mocking | ||
plugin = new SecurityPlugin(initializerContext); | ||
|
||
// Override getNavGroupEnabled to return false | ||
coreSetup.chrome.navGroup = { | ||
...coreSetup.chrome.navGroup, | ||
getNavGroupEnabled: () => false, | ||
}; | ||
// Mock the core.application.register function | ||
const registerSpy = jest.spyOn(coreSetup.application, 'register'); | ||
|
||
// Execute the setup function | ||
await plugin.setup(coreSetup, deps); | ||
|
||
// Assert that the register function was not called for specific applications | ||
const registeredApps = registerSpy.mock.calls.map((call) => call[0].id); | ||
const expectedApps = [ | ||
PLUGIN_GET_STARTED_APP_ID, | ||
PLUGIN_AUTH_APP_ID, | ||
PLUGIN_ROLES_APP_ID, | ||
PLUGIN_USERS_APP_ID, | ||
PLUGIN_PERMISSIONS_APP_ID, | ||
PLUGIN_TENANTS_APP_ID, | ||
PLUGIN_AUDITLOG_APP_ID, | ||
]; | ||
|
||
expectedApps.forEach((app) => { | ||
expect(registeredApps).not.toContain(app); | ||
}); | ||
}); | ||
|
||
it('calls register function for certain applications when getNavGroupEnabled is on', async () => { | ||
// Mock hasApiPermission to return true | ||
pluginModule.hasApiPermission.mockResolvedValue(true); // Access the mock via the imported module | ||
|
||
// Instantiate the plugin after mocking | ||
plugin = new SecurityPlugin(initializerContext); | ||
|
||
// Override getNavGroupEnabled to return true | ||
coreSetup.chrome.navGroup = { | ||
...coreSetup.chrome.navGroup, | ||
getNavGroupEnabled: () => true, | ||
}; | ||
// Mock the core.application.register function | ||
const registerSpy = jest.spyOn(coreSetup.application, 'register'); | ||
|
||
// Execute the setup function | ||
await plugin.setup(coreSetup, deps); | ||
|
||
// Assert that the register function was called for specific applications | ||
const registeredApps = registerSpy.mock.calls.map((call) => call[0].id); | ||
const expectedApps = [ | ||
PLUGIN_GET_STARTED_APP_ID, | ||
PLUGIN_AUTH_APP_ID, | ||
PLUGIN_ROLES_APP_ID, | ||
PLUGIN_USERS_APP_ID, | ||
PLUGIN_PERMISSIONS_APP_ID, | ||
PLUGIN_TENANTS_APP_ID, | ||
PLUGIN_AUDITLOG_APP_ID, | ||
]; | ||
|
||
expectedApps.forEach((app) => { | ||
expect(registeredApps).toContain(app); | ||
}); | ||
}); | ||
|
||
it('does not call register function for tenant app when multitenancy is off', async () => { | ||
// Mock hasApiPermission to return true | ||
pluginModule.hasApiPermission.mockResolvedValue(true); | ||
|
||
// InitializerContext with multitenancy disabled | ||
initializerContext = { | ||
config: { | ||
get: jest.fn().mockReturnValue({ | ||
readonly_mode: { roles: [] }, | ||
multitenancy: { enabled: false, enable_aggregation_view: false }, | ||
clusterPermissions: { include: [] }, | ||
indexPermissions: { include: [] }, | ||
disabledTransportCategories: { exclude: [] }, | ||
disabledRestCategories: { exclude: [] }, | ||
ui: { autologout: false }, | ||
}), | ||
}, | ||
}; | ||
|
||
// Instantiate the plugin after mocking | ||
plugin = new SecurityPlugin(initializerContext); | ||
|
||
// Override getNavGroupEnabled to return true | ||
coreSetup.chrome.navGroup = { | ||
...coreSetup.chrome.navGroup, | ||
getNavGroupEnabled: () => true, | ||
}; | ||
// Mock the core.application.register function | ||
const registerSpy = jest.spyOn(coreSetup.application, 'register'); | ||
|
||
// Execute the setup function | ||
await plugin.setup(coreSetup, deps); | ||
|
||
// Assert that the register function was not called for tenancy app | ||
const registeredApps = registerSpy.mock.calls.map((call) => call[0].id); | ||
|
||
expect(registeredApps).not.toContain(PLUGIN_TENANTS_APP_ID); | ||
|
||
// Assert that other apps are registered because the feature flag is on | ||
expect(registeredApps).toContain(PLUGIN_GET_STARTED_APP_ID); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we close this one since it is carrying over all the other diffs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can close it. It is only carrying a PR that I didn't mean to backport to 2.16 after rebasing.