-
Notifications
You must be signed in to change notification settings - Fork 174
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
Fixing dynamic tenancy changes for issues 1412 #1419
Changes from 4 commits
c7ed2d1
2710020
b909a2a
b7131fe
3450d12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: Cypress Tests Multitenancy Disabled | ||
|
||
on: [ push, pull_request ] | ||
|
||
env: | ||
TEST_BROWSER_HEADLESS: 1 | ||
CI: 1 | ||
FTR_PATH: 'ftr' | ||
START_CMD: 'node ../scripts/opensearch_dashboards --dev --no-base-path --no-watch --opensearch_security.multitenancy.enable_aggregation_view=true' | ||
OPENSEARCH_SNAPSHOT_CMD: 'node ../scripts/opensearch snapshot' | ||
SPEC: 'cypress/integration/plugins/security-dashboards-plugin/aggregation_view.js,' | ||
OPENSEARCH_VERSION: 3.0.0 | ||
PLUGIN_NAME: opensearch-security | ||
PLUGIN_VERSION: 3.0.0.0 | ||
|
||
jobs: | ||
tests: | ||
name: Run Cypress Tests Multitenancy Disabled | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ ubuntu-latest , windows-latest ] | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Set up JDK | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
|
||
- name: Checkout Branch | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download security plugin and create setup scripts | ||
uses: ./.github/actions/download-plugin | ||
with: | ||
opensearch-version: ${{ env.OPENSEARCH_VERSION }} | ||
plugin-name: ${{ env.PLUGIN_NAME }} | ||
plugin-version: ${{ env.PLUGIN_VERSION }} | ||
|
||
- name: Run Opensearch with A Single Plugin | ||
uses: opensearch-project/security/.github/actions/start-opensearch-with-one-plugin@main | ||
with: | ||
opensearch-version: ${{ env.OPENSEARCH_VERSION }} | ||
plugin-name: ${{ env.PLUGIN_NAME }} | ||
setup-script-name: setup | ||
|
||
- name: Run Dashboard with Security Dashboards Plugin | ||
uses: ./.github/actions/install-dashboards | ||
with: | ||
plugin_name: security-dashboards-plugin | ||
|
||
- name: Configure and Run OpenSearch Dashboards with Cypress Test Cases | ||
run: | | ||
cd ./OpenSearch-Dashboards | ||
echo 'server.host: "0.0.0.0"' >> ./config/opensearch_dashboards.yml | ||
echo 'opensearch.hosts: ["https://localhost:9200"]' >> ./config/opensearch_dashboards.yml | ||
echo 'opensearch.ssl.verificationMode: none' >> ./config/opensearch_dashboards.yml | ||
echo 'opensearch.username: "kibanaserver"' >> ./config/opensearch_dashboards.yml | ||
echo 'opensearch.password: "kibanaserver"' >> ./config/opensearch_dashboards.yml | ||
echo 'opensearch.requestHeadersWhitelist: [ authorization,securitytenant ]' >> ./config/opensearch_dashboards.yml | ||
echo 'opensearch_security.multitenancy.enabled: false' >> ./config/opensearch_dashboards.yml | ||
echo 'opensearch_security.readonly_mode.roles: ["kibana_read_only"]' >> ./config/opensearch_dashboards.yml | ||
echo 'opensearch_security.cookie.secure: false' >> ./config/opensearch_dashboards.yml | ||
nohup yarn start --no-base-path --no-watch & | ||
sleep 500 | ||
git clone https://github.com/opensearch-project/opensearch-dashboards-functional-test.git | ||
cd opensearch-dashboards-functional-test | ||
npm install cypress --save-dev | ||
yarn cypress:run-with-security --browser chrome --spec "cypress/integration/plugins/security-dashboards-plugin/inaccessible_tenancy_features.js" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,7 +85,7 @@ export function AccountNavButton(props: { | |
}, [props.coreStart.http]); | ||
|
||
// Check if the tenant modal should be shown on load | ||
if (isMultiTenancyEnabled && getShouldShowTenantPopup()) { | ||
if (isMultiTenancyEnabled && getShouldShowTenantPopup() && props.config.multitenancy.enabled) { | ||
setShouldShowTenantPopup(false); | ||
showTenantSwitchPanel(); | ||
} | ||
|
@@ -128,7 +128,7 @@ export function AccountNavButton(props: { | |
> | ||
View roles and identities | ||
</EuiButtonEmpty> | ||
{isMultiTenancyEnabled && ( | ||
{isMultiTenancyEnabled && props.config.multitenancy.enabled && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be extracted as a class-level variable:
and use the variable across the file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @DarshitChanpura |
||
<> | ||
{horizontalRule} | ||
<EuiButtonEmpty data-test-subj="switch-tenants" size="xs" onClick={showTenantSwitchPanel}> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,6 @@ import { showTableStatusMessage } from '../../utils/loading-spinner-utils'; | |
import { useContextMenuState } from '../../utils/context-menu'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you also update the fetchDatat method to be:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure will do. Thanks. |
||
import { generateResourceName } from '../../utils/resource-utils'; | ||
import { DocLinks } from '../../constants'; | ||
import { TenantInstructionView } from './tenant-instruction-view'; | ||
import { TenantList } from './tenant-list'; | ||
import { getBreadcrumbs, Route_MAP } from '../../app-router'; | ||
import { buildUrl } from '../../utils/url-builder'; | ||
|
@@ -92,30 +91,29 @@ export function ManageTab(props: AppDependencies) { | |
const [isPrivateTenantEnabled, setIsPrivateTenantEnabled] = useState(false); | ||
const [dashboardsDefaultTenant, setDashboardsDefaultTenant] = useState(''); | ||
|
||
const { http } = props.coreStart; | ||
|
||
const fetchData = useCallback(async () => { | ||
try { | ||
setLoading(true); | ||
const rawTenantData = await fetchTenants(props.coreStart.http); | ||
const rawTenantData = await fetchTenants(http); | ||
const processedTenantData = transformTenantData(rawTenantData); | ||
const activeTenant = await fetchCurrentTenant(props.coreStart.http); | ||
const currentUser = await getCurrentUser(props.coreStart.http); | ||
const activeTenant = await fetchCurrentTenant(http); | ||
const currentUser = await getCurrentUser(http); | ||
setCurrentUsername(currentUser); | ||
setCurrentTenant(resolveTenantName(activeTenant, currentUser)); | ||
setTenantData(processedTenantData); | ||
setIsMultiTenancyEnabled( | ||
(await getDashboardsInfo(props.coreStart.http)).multitenancy_enabled | ||
); | ||
setIsPrivateTenantEnabled( | ||
(await getDashboardsInfo(props.coreStart.http)).private_tenant_enabled | ||
); | ||
setDashboardsDefaultTenant((await getDashboardsInfo(props.coreStart.http)).default_tenant); | ||
const tenancyConfig = await getDashboardsInfo(http); | ||
setIsMultiTenancyEnabled(tenancyConfig.multitenancy_enabled); | ||
setIsPrivateTenantEnabled(tenancyConfig.private_tenant_enabled); | ||
setDashboardsDefaultTenant(tenancyConfig.default_tenant); | ||
} catch (e) { | ||
console.log(e); | ||
setErrorFlag(true); | ||
} finally { | ||
setLoading(false); | ||
} | ||
}, [props.coreStart.http]); | ||
}, [http]); | ||
|
||
React.useEffect(() => { | ||
fetchData(); | ||
|
@@ -479,9 +477,6 @@ export function ManageTab(props: AppDependencies) { | |
); | ||
}; | ||
|
||
if (!props.config.multitenancy.enabled) { | ||
return <TenantInstructionView />; | ||
} | ||
/* eslint-disable */ | ||
return ( | ||
<> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,7 +131,7 @@ describe('Tenant list', () => { | |
config={config1 as any} | ||
/> | ||
); | ||
expect(component.find(TenantInstructionView).length).toBe(1); | ||
expect(component.find(TenantInstructionView).length).toBe(0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For my understanding, why we change the test case here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We changes the way manage tab would look when multitenancy.enabled is false. Hence the result will change. This is now same as before we merged our changes for dynamic tenancy config. |
||
}); | ||
|
||
it('fetch data error', (done) => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,7 +155,11 @@ export class SecurityPlugin | |
}) | ||
); | ||
|
||
if (multitenancyEnabled && config.multitenancy.enable_aggregation_view) { | ||
if ( | ||
multitenancyEnabled && | ||
config.multitenancy.enabled && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just wanna double check L159 here. So is that mean that the configuration in frontend is more like a feature flag for dynamical configurable multi-tenancy feature? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not exactly. Configuration in frontend is like a feature flag for all tenancy features available in dashboards like switching tenant, updating tenancy configuration, aggregation view etc. |
||
config.multitenancy.enable_aggregation_view | ||
) { | ||
deps.savedObjectsManagement.columns.register( | ||
(tenantColumn as unknown) as SavedObjectsManagementColumn<string> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ import { SecurityPluginConfigType } from '..'; | |
import { GLOBAL_TENANT_SYMBOL, PRIVATE_TENANT_SYMBOL, globalTenantName } from '../../common'; | ||
|
||
export const PRIVATE_TENANTS: string[] = [PRIVATE_TENANT_SYMBOL, 'private']; | ||
export const GLOBAL_TENANTS: string[] = ['global', GLOBAL_TENANT_SYMBOL]; | ||
export const GLOBAL_TENANTS: string[] = ['global', GLOBAL_TENANT_SYMBOL, 'Global']; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just for my understanding, why don't we do the same to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it resolves to 'user'. |
||
/** | ||
* Resovles the tenant the user is using. | ||
* | ||
|
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 don't need
nohup
here, but I think this will also be fine.