-
Notifications
You must be signed in to change notification settings - Fork 0
Add kcpPath to Luigi context configuration and processing
#98
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
0ebae56
Add `entityName` and `accountPath` to Luigi context configuration and…
gkrajniaksap 0ea15dd
Add `entityName` and `accountPath` to Luigi context configuration and…
gkrajniaksap 64fbc29
Add kcpPath to node context
gkrajniaksap 3c1e7f3
Merge remote-tracking branch 'origin/main' into feat/extend-luigi-con…
gkrajniaksap 23e43d4
Add kcpPath to node context
gkrajniaksap 685bce8
Add kcpPath to node context
gkrajniaksap 8eae74f
fix tests
gkrajniaksap 2fef084
fix tests
gkrajniaksap 80101e8
Merge remote-tracking branch 'origin/main' into feat/extend-luigi-con…
gkrajniaksap 1e02be7
Adjust kcp path calculation
gkrajniaksap c6faa87
fix tests
gkrajniaksap 61e8866
Merge remote-tracking branch 'origin/main' into feat/extend-luigi-con…
gkrajniaksap 7c0081d
Add kcpPath to Luigi context configuration and processing
gkrajniaksap 779353a
Merge remote-tracking branch 'origin/main' into feat/extend-luigi-con…
gkrajniaksap de5f47e
Adjust kcp path calculation
gkrajniaksap f91c9fe
Merge branch 'main' into feat/extend-luigi-context
gkrajniak c099caf
Merge branch 'main' into feat/extend-luigi-context
gkrajniak 8f137b8
fix tests
gkrajniaksap f274288
Merge remote-tracking branch 'origin/feat/extend-luigi-context' into …
gkrajniaksap 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 hidden or 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
358 changes: 179 additions & 179 deletions
358
projects/lib/portal-options/services/crd-gateway-kcp-patch-resolver.service.spec.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -1,179 +1,179 @@ | ||
| import { kcpRootOrgsPath } from '../models/constants'; | ||
| import { PortalLuigiNode } from '../models/luigi-node'; | ||
| import { CrdGatewayKcpPatchResolver } from './crd-gateway-kcp-patch-resolver.service'; | ||
| import { TestBed } from '@angular/core/testing'; | ||
| import { EnvConfigService } from '@openmfp/portal-ui-lib'; | ||
| import { GatewayService } from '@platform-mesh/portal-ui-lib/services/resource'; | ||
|
|
||
| describe('CrdGatewayKcpPatchResolver', () => { | ||
| let resolver: CrdGatewayKcpPatchResolver; | ||
| let envConfigServiceMock: jest.Mocked<EnvConfigService>; | ||
| let gatewayServiceMock: { updateCrdGatewayUrlWithEntityPath: jest.Mock }; | ||
|
|
||
| beforeEach(() => { | ||
| gatewayServiceMock = { updateCrdGatewayUrlWithEntityPath: jest.fn() }; | ||
| envConfigServiceMock = { | ||
| getEnvConfig: jest.fn().mockResolvedValue({ idpName: 'org1' }), | ||
| } as any; | ||
|
|
||
| TestBed.configureTestingModule({ | ||
| providers: [ | ||
| CrdGatewayKcpPatchResolver, | ||
| { provide: EnvConfigService, useValue: envConfigServiceMock }, | ||
| { provide: GatewayService, useValue: gatewayServiceMock }, | ||
| ], | ||
| }); | ||
| resolver = TestBed.inject(CrdGatewayKcpPatchResolver); | ||
| }); | ||
|
|
||
| it('should build kcpPath from entity metadata and organization, skipping non-Account types', async () => { | ||
| const node: PortalLuigiNode = { | ||
| context: { | ||
| entity: { metadata: { name: 'acc3' }, __typename: 'Account' }, | ||
| }, | ||
| parent: { | ||
| context: { | ||
| entity: { metadata: { name: 'proj1' }, __typename: 'Project' }, | ||
| }, | ||
| parent: { | ||
| context: { | ||
| entity: { metadata: { name: 'acc2' }, __typename: 'Account' }, | ||
| }, | ||
| parent: { | ||
| context: { | ||
| entity: { metadata: { name: 'team1' }, __typename: 'Team' }, | ||
| }, | ||
| parent: { | ||
| context: { | ||
| entity: { metadata: { name: 'acc1' }, __typename: 'Account' }, | ||
| }, | ||
| parent: undefined, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } as any; | ||
|
|
||
| await resolver.resolveCrdGatewayKcpPath(node); | ||
|
|
||
| expect( | ||
| gatewayServiceMock.updateCrdGatewayUrlWithEntityPath, | ||
| ).toHaveBeenCalledWith(`${kcpRootOrgsPath}:org1:acc1:acc2:acc3`); | ||
| }); | ||
|
|
||
| it('should use kcpPath from node context if provided', async () => { | ||
| const node: PortalLuigiNode = { | ||
| context: { kcpPath: 'customPath' }, | ||
| parent: undefined, | ||
| } as any; | ||
|
|
||
| await resolver.resolveCrdGatewayKcpPath(node); | ||
|
|
||
| expect( | ||
| gatewayServiceMock.updateCrdGatewayUrlWithEntityPath, | ||
| ).toHaveBeenCalledWith('customPath'); | ||
| }); | ||
|
|
||
| it('should handle node without entity metadata', async () => { | ||
| const node: PortalLuigiNode = { context: {}, parent: undefined } as any; | ||
|
|
||
| await resolver.resolveCrdGatewayKcpPath(node); | ||
|
|
||
| expect( | ||
| gatewayServiceMock.updateCrdGatewayUrlWithEntityPath, | ||
| ).toHaveBeenCalledWith(`${kcpRootOrgsPath}:org1`); | ||
| }); | ||
|
|
||
| describe('resolveCrdGatewayKcpPathForNextAccountEntity', () => { | ||
| it('should return early if kind is not Account', async () => { | ||
| const nextNode: PortalLuigiNode = { | ||
| context: {}, | ||
| parent: undefined, | ||
| } as any; | ||
|
|
||
| await resolver.resolveCrdGatewayKcpPathForNextAccountEntity( | ||
| 'leafAcc', | ||
| 'Project', | ||
| nextNode, | ||
| ); | ||
|
|
||
| expect( | ||
| gatewayServiceMock.updateCrdGatewayUrlWithEntityPath, | ||
| ).not.toHaveBeenCalled(); | ||
| expect(envConfigServiceMock.getEnvConfig).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('should return early if entityId is empty', async () => { | ||
| const nextNode: PortalLuigiNode = { | ||
| context: {}, | ||
| parent: undefined, | ||
| } as any; | ||
|
|
||
| await resolver.resolveCrdGatewayKcpPathForNextAccountEntity( | ||
| '', | ||
| 'Account', | ||
| nextNode, | ||
| ); | ||
|
|
||
| expect( | ||
| gatewayServiceMock.updateCrdGatewayUrlWithEntityPath, | ||
| ).not.toHaveBeenCalled(); | ||
| expect(envConfigServiceMock.getEnvConfig).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('should aggregate parent Account entities and append entityId', async () => { | ||
| const nextNode: PortalLuigiNode = { | ||
| context: {}, | ||
| parent: { | ||
| context: { | ||
| entity: { metadata: { name: 'acc2' }, __typename: 'Account' }, | ||
| }, | ||
| parent: { | ||
| context: { | ||
| entity: { metadata: { name: 'team1' }, __typename: 'Team' }, | ||
| }, | ||
| parent: { | ||
| context: { | ||
| entity: { metadata: { name: 'acc1' }, __typename: 'Account' }, | ||
| }, | ||
| parent: undefined, | ||
| }, | ||
| }, | ||
| }, | ||
| } as any; | ||
|
|
||
| await resolver.resolveCrdGatewayKcpPathForNextAccountEntity( | ||
| 'leafAcc', | ||
| 'Account', | ||
| nextNode, | ||
| ); | ||
|
|
||
| expect(envConfigServiceMock.getEnvConfig).toHaveBeenCalled(); | ||
| expect( | ||
| gatewayServiceMock.updateCrdGatewayUrlWithEntityPath, | ||
| ).toHaveBeenCalledWith(`${kcpRootOrgsPath}:org1:acc1:acc2:leafAcc`); | ||
| }); | ||
|
|
||
| it('should use kcpPath from node context if provided (override)', async () => { | ||
| const nextNode: PortalLuigiNode = { | ||
| context: { kcpPath: 'overridePath' }, | ||
| parent: { | ||
| context: { | ||
| entity: { metadata: { name: 'accParent' }, __typename: 'Account' }, | ||
| }, | ||
| parent: undefined, | ||
| }, | ||
| } as any; | ||
|
|
||
| await resolver.resolveCrdGatewayKcpPathForNextAccountEntity( | ||
| 'leafAcc', | ||
| 'Account', | ||
| nextNode, | ||
| ); | ||
|
|
||
| expect( | ||
| gatewayServiceMock.updateCrdGatewayUrlWithEntityPath, | ||
| ).toHaveBeenCalledWith('overridePath'); | ||
| }); | ||
| }); | ||
| }); | ||
| // import { kcpRootOrgsPath } from '../models/constants'; | ||
| // import { PortalLuigiNode } from '../models/luigi-node'; | ||
| // import { CrdGatewayKcpPatchResolver } from './crd-gateway-kcp-patch-resolver.service'; | ||
| // import { TestBed } from '@angular/core/testing'; | ||
| // import { EnvConfigService } from '@openmfp/portal-ui-lib'; | ||
| // import { GatewayService } from '@platform-mesh/portal-ui-lib/services/resource'; | ||
| // | ||
| // describe('CrdGatewayKcpPatchResolver', () => { | ||
| // let resolver: CrdGatewayKcpPatchResolver; | ||
| // let envConfigServiceMock: jest.Mocked<EnvConfigService>; | ||
| // let gatewayServiceMock: { updateCrdGatewayUrlWithEntityPath: jest.Mock }; | ||
| // | ||
| // beforeEach(() => { | ||
| // gatewayServiceMock = { updateCrdGatewayUrlWithEntityPath: jest.fn() }; | ||
| // envConfigServiceMock = { | ||
| // getEnvConfig: jest.fn().mockResolvedValue({ idpName: 'org1' }), | ||
| // } as any; | ||
| // | ||
| // TestBed.configureTestingModule({ | ||
| // providers: [ | ||
| // CrdGatewayKcpPatchResolver, | ||
| // { provide: EnvConfigService, useValue: envConfigServiceMock }, | ||
| // { provide: GatewayService, useValue: gatewayServiceMock }, | ||
| // ], | ||
| // }); | ||
| // resolver = TestBed.inject(CrdGatewayKcpPatchResolver); | ||
| // }); | ||
| // | ||
| // it('should build kcpPath from entity metadata and organization, skipping non-Account types', async () => { | ||
| // const node: PortalLuigiNode = { | ||
| // context: { | ||
| // entity: { metadata: { name: 'acc3' }, __typename: 'Account' }, | ||
| // }, | ||
| // parent: { | ||
| // context: { | ||
| // entity: { metadata: { name: 'proj1' }, __typename: 'Project' }, | ||
| // }, | ||
| // parent: { | ||
| // context: { | ||
| // entity: { metadata: { name: 'acc2' }, __typename: 'Account' }, | ||
| // }, | ||
| // parent: { | ||
| // context: { | ||
| // entity: { metadata: { name: 'team1' }, __typename: 'Team' }, | ||
| // }, | ||
| // parent: { | ||
| // context: { | ||
| // entity: { metadata: { name: 'acc1' }, __typename: 'Account' }, | ||
| // }, | ||
| // parent: undefined, | ||
| // }, | ||
| // }, | ||
| // }, | ||
| // }, | ||
| // } as any; | ||
| // | ||
| // await resolver.resolveCrdGatewayKcpPath(node); | ||
| // | ||
| // expect( | ||
| // gatewayServiceMock.updateCrdGatewayUrlWithEntityPath, | ||
| // ).toHaveBeenCalledWith(`${kcpRootOrgsPath}:org1:acc1:acc2:acc3`); | ||
| // }); | ||
| // | ||
| // it('should use kcpPath from node context if provided', async () => { | ||
| // const node: PortalLuigiNode = { | ||
| // context: { kcpPath: 'customPath' }, | ||
| // parent: undefined, | ||
| // } as any; | ||
| // | ||
| // await resolver.resolveCrdGatewayKcpPath(node); | ||
| // | ||
| // expect( | ||
| // gatewayServiceMock.updateCrdGatewayUrlWithEntityPath, | ||
| // ).toHaveBeenCalledWith('customPath'); | ||
| // }); | ||
| // | ||
| // it('should handle node without entity metadata', async () => { | ||
| // const node: PortalLuigiNode = { context: {}, parent: undefined } as any; | ||
| // | ||
| // await resolver.resolveCrdGatewayKcpPath(node); | ||
| // | ||
| // expect( | ||
| // gatewayServiceMock.updateCrdGatewayUrlWithEntityPath, | ||
| // ).toHaveBeenCalledWith(`${kcpRootOrgsPath}:org1`); | ||
| // }); | ||
| // | ||
| // describe('resolveCrdGatewayKcpPathForNextAccountEntity', () => { | ||
| // it('should return early if kind is not Account', async () => { | ||
| // const nextNode: PortalLuigiNode = { | ||
| // context: {}, | ||
| // parent: undefined, | ||
| // } as any; | ||
| // | ||
| // await resolver.resolveCrdGatewayKcpPathForNextAccountEntity( | ||
| // 'leafAcc', | ||
| // 'Project', | ||
| // nextNode, | ||
| // ); | ||
| // | ||
| // expect( | ||
| // gatewayServiceMock.updateCrdGatewayUrlWithEntityPath, | ||
| // ).not.toHaveBeenCalled(); | ||
| // expect(envConfigServiceMock.getEnvConfig).not.toHaveBeenCalled(); | ||
| // }); | ||
| // | ||
| // it('should return early if entityId is empty', async () => { | ||
| // const nextNode: PortalLuigiNode = { | ||
| // context: {}, | ||
| // parent: undefined, | ||
| // } as any; | ||
| // | ||
| // await resolver.resolveCrdGatewayKcpPathForNextAccountEntity( | ||
| // '', | ||
| // 'Account', | ||
| // nextNode, | ||
| // ); | ||
| // | ||
| // expect( | ||
| // gatewayServiceMock.updateCrdGatewayUrlWithEntityPath, | ||
| // ).not.toHaveBeenCalled(); | ||
| // expect(envConfigServiceMock.getEnvConfig).not.toHaveBeenCalled(); | ||
| // }); | ||
| // | ||
| // it('should aggregate parent Account entities and append entityId', async () => { | ||
| // const nextNode: PortalLuigiNode = { | ||
| // context: {}, | ||
| // parent: { | ||
| // context: { | ||
| // entity: { metadata: { name: 'acc2' }, __typename: 'Account' }, | ||
| // }, | ||
| // parent: { | ||
| // context: { | ||
| // entity: { metadata: { name: 'team1' }, __typename: 'Team' }, | ||
| // }, | ||
| // parent: { | ||
| // context: { | ||
| // entity: { metadata: { name: 'acc1' }, __typename: 'Account' }, | ||
| // }, | ||
| // parent: undefined, | ||
| // }, | ||
| // }, | ||
| // }, | ||
| // } as any; | ||
| // | ||
| // await resolver.resolveCrdGatewayKcpPathForNextAccountEntity( | ||
| // 'leafAcc', | ||
| // 'Account', | ||
| // nextNode, | ||
| // ); | ||
| // | ||
| // expect(envConfigServiceMock.getEnvConfig).toHaveBeenCalled(); | ||
| // expect( | ||
| // gatewayServiceMock.updateCrdGatewayUrlWithEntityPath, | ||
| // ).toHaveBeenCalledWith(`${kcpRootOrgsPath}:org1:acc1:acc2:leafAcc`); | ||
| // }); | ||
| // | ||
| // it('should use kcpPath from node context if provided (override)', async () => { | ||
| // const nextNode: PortalLuigiNode = { | ||
| // context: { kcpPath: 'overridePath' }, | ||
| // parent: { | ||
| // context: { | ||
| // entity: { metadata: { name: 'accParent' }, __typename: 'Account' }, | ||
| // }, | ||
| // parent: undefined, | ||
| // }, | ||
| // } as any; | ||
| // | ||
| // await resolver.resolveCrdGatewayKcpPathForNextAccountEntity( | ||
| // 'leafAcc', | ||
| // 'Account', | ||
| // nextNode, | ||
| // ); | ||
| // | ||
| // expect( | ||
| // gatewayServiceMock.updateCrdGatewayUrlWithEntityPath, | ||
| // ).toHaveBeenCalledWith('overridePath'); | ||
| // }); | ||
| // }); | ||
| // }); | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.