Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/ops/ApplicationOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,18 @@ export function createApplicationExportTemplate({
}

export function getRealmManagedApplication({ state }: { state: State }) {
let realmManagedOrg = 'application';
if (state.getDeploymentType() === constants.CLOUD_DEPLOYMENT_TYPE_KEY) {
realmManagedOrg = `${getCurrentRealmName(state)}_application`;
let realmManagedApp = 'application';
if (
state.getDeploymentType() === constants.CLOUD_DEPLOYMENT_TYPE_KEY ||
state.getUseRealmPrefixOnManagedObjects() === true
) {
realmManagedApp = `${getCurrentRealmName(state)}_application`;
debugMessage({
message: `DeploymentType === cloud or UseRealmPrefixOnManagedObjects is true, returning '${realmManagedApp}'`,
state: state,
});
}
return realmManagedOrg;
return realmManagedApp;
}

export async function createApplication({
Expand Down
10 changes: 9 additions & 1 deletion src/ops/OrganizationOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { IdObjectSkeletonInterface } from '../api/ApiTypes';
import { queryAllManagedObjectsByType } from '../api/ManagedObjectApi';
import Constants from '../shared/Constants';
import { State } from '../shared/State';
import { debugMessage } from '../utils/Console';
import { FrodoError } from './FrodoError';

export type Organization = {
Expand Down Expand Up @@ -53,8 +54,15 @@ export default (state: State): Organization => {
*/
export function getRealmManagedOrganization({ state }: { state: State }) {
let realmManagedOrg = 'organization';
if (state.getDeploymentType() === Constants.CLOUD_DEPLOYMENT_TYPE_KEY) {
if (
state.getDeploymentType() === Constants.CLOUD_DEPLOYMENT_TYPE_KEY ||
state.getUseRealmPrefixOnManagedObjects() === true
) {
realmManagedOrg = `${state.getRealm()}_organization`;
debugMessage({
message: `DeploymentType === cloud or UseRealmPrefixOnManagedObjects is true, returning '${realmManagedOrg}'`,
state: state,
});
}
return realmManagedOrg;
}
Expand Down
10 changes: 10 additions & 0 deletions src/shared/State.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export type State = {
getPassword(): string;
setRealm(realm: string): void;
getRealm(): string;
setUseRealmPrefixOnManagedObjects(useRealmPrefixOnManagedObjects: boolean): void;
getUseRealmPrefixOnManagedObjects(): boolean;
setDeploymentType(type: string): void;
getDeploymentType(): string;
setAdminClientId(type: string): void;
Expand Down Expand Up @@ -211,6 +213,13 @@ export default (initialState: StateInterface): State => {
return state.realm || process.env.FRODO_REALM;
},

setUseRealmPrefixOnManagedObjects(useRealmPrefixOnManagedObjects: boolean) {
state.useRealmPrefixOnManagedObjects = useRealmPrefixOnManagedObjects;
},
getUseRealmPrefixOnManagedObjects() {
return state.useRealmPrefixOnManagedObjects || false;
},

setDeploymentType(type: string) {
state.deploymentType = type;
},
Expand Down Expand Up @@ -510,6 +519,7 @@ export interface StateInterface {
username?: string;
password?: string;
realm?: string;
useRealmPrefixOnManagedObjects?: boolean;
deploymentType?: string;
adminClientId?: string;
adminClientRedirectUri?: string;
Expand Down
10 changes: 9 additions & 1 deletion src/utils/ForgeRockUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getRealms } from '../ops/RealmOps';
import Constants from '../shared/Constants';
import { State } from '../shared/State';
import { debugMessage } from '../utils/Console';

export type FRUtils = {
applyNameCollisionPolicy(name: string): string;
Expand Down Expand Up @@ -211,8 +212,15 @@ export function getCurrentRealmManagedUser({
state: State;
}): string {
let realmManagedUser = 'user';
if (state.getDeploymentType() === Constants.CLOUD_DEPLOYMENT_TYPE_KEY) {
if (
state.getDeploymentType() === Constants.CLOUD_DEPLOYMENT_TYPE_KEY ||
state.getUseRealmPrefixOnManagedObjects() === true
) {
realmManagedUser = `${getCurrentRealmName(state)}_user`;
debugMessage({
message: `DeploymentType === cloud or UseRealmPrefixOnManagedObjects is true, returning '${realmManagedUser}'`,
state: state,
});
}
return realmManagedUser;
}
Expand Down
Loading