-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix tenant label for custom tenant when both Global and Private tenan… (
#1277) * Fix tenant label for custom tenant when both Global and Private tenants are disabled Signed-off-by: Ryan Liang <[email protected]> (cherry picked from commit 1cffd90)
- Loading branch information
1 parent
f728d33
commit 198fd97
Showing
2 changed files
with
70 additions
and
3 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
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,57 @@ | ||
/* | ||
* 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 { resolve } from '../tenant_resolver'; | ||
|
||
describe("Resolve tenants when multitenancy is enabled and both 'Global' and 'Private' tenants are disabled", () => { | ||
function resolveWithConfig(config: any) { | ||
return resolve( | ||
config.username, | ||
config.requestedTenant, | ||
config.preferredTenants, | ||
config.availableTenants, | ||
config.globalTenantEnabled, | ||
config.privateTenantEnabled | ||
); | ||
} | ||
|
||
it('Resolve tenant with custom tenants, Global and Private disabled', () => { | ||
const adminConfig = { | ||
username: 'admin', | ||
requestedTenant: 'admin_tenant', | ||
preferredTenants: undefined, | ||
availableTenants: { global_tenant: true, admin_tenant: true, test_tenant: true, admin: true }, | ||
globalTenantEnabled: false, | ||
privateTenantEnabled: false, | ||
}; | ||
|
||
const adminResult = resolveWithConfig(adminConfig); | ||
expect(adminResult).toEqual('admin_tenant'); | ||
}); | ||
|
||
it('Resolve tenant without custom tenants, Global and Private disabled', () => { | ||
const nonadminConfig = { | ||
username: 'testuser', | ||
requestedTenant: undefined, | ||
preferredTenants: undefined, | ||
availableTenants: { global_tenant: true, testuser: true }, | ||
globalTenantEnabled: false, | ||
privateTenantEnabled: false, | ||
}; | ||
|
||
const nonadminResult = resolveWithConfig(nonadminConfig); | ||
expect(nonadminResult).toEqual('global_tenant'); | ||
}); | ||
}); |