Skip to content
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

Feature/#832 enable policy management #1039

Merged
merged 48 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
0c89231
feature(policy): add policy management view in administration
ds-mmaul May 27, 2024
131869f
feature(policy): add policy management view in administration
ds-mmaul May 28, 2024
517760a
feature(policy): add policy management view in administration list vi…
ds-mmaul May 29, 2024
67297dd
feature(policy): add policy management detailed view
ds-mmaul May 31, 2024
d14c37a
feature(policy): add policy management detailed view
ds-mmaul Jun 3, 2024
db6b8b7
feature(policy): add policy management template application and polic…
ds-mmaul Jun 4, 2024
87bf744
feature(policy): #832 removed pagination, added create and update api…
ds-mmaul Jun 5, 2024
fd06eab
feature(policy): #832 added form validation and policy download
ds-mmaul Jun 5, 2024
6fa731e
feature(policy): #832 added form validation and template error handling
ds-mmaul Jun 6, 2024
9dc3c25
feature(policy): #832 added form validation and template error handling
ds-mmaul Jun 6, 2024
6e01698
feature(policy): #832 support for single or multiple bpns
ds-mmaul Jun 6, 2024
dba021e
feature(policy): #832 support for single or multiple bpns
ds-mmaul Jun 6, 2024
a546d66
Merge branch 'refs/heads/main' into feature/#832-enable-policy-manage…
ds-mmaul Jun 6, 2024
debe905
feature(policy): #832 support for single or multiple bpns
ds-mmaul Jun 6, 2024
24eda6f
feature(policy): #832 support for single or multiple bpns
ds-mmaul Jun 6, 2024
00acde4
feature(policy): #832 fixed tests
ds-mmaul Jun 7, 2024
d1e0dab
feature(policy): #832 mapped get policies
ds-mmaul Jun 7, 2024
0c4b85b
feature(policy): #832 implemented feedback
ds-mmaul Jun 12, 2024
1e414eb
feature(policy): #832 implemented feedback
ds-mmaul Jun 12, 2024
db24bc8
feature(policy): #832 implemented feedback
ds-mmaul Jun 12, 2024
3f3d861
Merge branch 'refs/heads/main' into feature/#832-enable-policy-manage…
ds-mmaul Jun 12, 2024
f27db7e
feature(policy): #832 implemented feedback
ds-mmaul Jun 12, 2024
d6c5e04
feature(policy): #832 commented out template up and download feature
ds-mmaul Jun 12, 2024
2e73975
feature(policy): #832 fix code issues
ds-mmaul Jun 12, 2024
733262a
feature(policy): #832 fix test
ds-mmaul Jun 12, 2024
1992551
feature(policy): #832 added tests
ds-mmaul Jun 12, 2024
e1b8ebc
feature(policy): #832 added PUT mapping
ds-mmaul Jun 13, 2024
fedf947
Merge branch 'refs/heads/main' into feature/#832-enable-policy-manage…
ds-mmaul Jun 13, 2024
e018f18
feature(policy): #832 fix test
ds-mmaul Jun 13, 2024
480d47d
feature(policy): #832 added tests
ds-mmaul Jun 13, 2024
951e2c7
feature(policy): #832 added tests
ds-mmaul Jun 13, 2024
a28e3ee
feature(policy): #832 added tests
ds-mmaul Jun 13, 2024
030abd4
feature(policy): #832 added tests
ds-mmaul Jun 13, 2024
24f90db
feature(policy): #832 implemented feedback
ds-mmaul Jun 14, 2024
b3c612d
feature(policy): #832 implemented feedback
ds-mmaul Jun 14, 2024
ca1c0db
feature(policy): #832 implemented feedback
ds-mmaul Jun 14, 2024
f9c7446
feature(policy): #832 added tests
ds-mmaul Jun 14, 2024
c62256d
feature(policy): #832 added tests
ds-mmaul Jun 14, 2024
0529ab2
feature(policy): #832 added tests
ds-mmaul Jun 14, 2024
ce33498
feature(policy): #832 added tests
ds-mmaul Jun 14, 2024
3bbbf69
feature(policy): #832 added tests
ds-mmaul Jun 14, 2024
c66bc38
Merge branch 'refs/heads/main' into feature/#832-enable-policy-manage…
ds-mmaul Jun 14, 2024
920212b
feature(policy): #832 timestamp mapping
ds-mmaul Jun 14, 2024
a9032bf
feature(policy): #832 fix test
ds-mmaul Jun 17, 2024
9c67ed8
feature(policy): #832 fix test
ds-mmaul Jun 17, 2024
4b824ed
feature(policy): #832 fix test
ds-mmaul Jun 17, 2024
12a61f6
feature(policy): #832 add user manual
ds-mmaul Jun 17, 2024
9d5ecb1
feature(policy): #832 add user manual
ds-mmaul Jun 17, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ _**For better traceability add the corresponding GitHub issue number in each cha
- #965 Implement proxy functionality of the IRS policy store

### Added
- #832 added policymanagement list view, creator and editor
- #737 Added concept: Contract table -> parts link action
- XXX Added interceptor to EdcRestTemplates to log requests

Expand Down
116 changes: 89 additions & 27 deletions docs/src/docs/user/user-manual.adoc

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 21 additions & 2 deletions frontend/src/app/mocks/services/policy-mock/policy.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,31 @@
********************************************************************************/
import { environment } from '@env';
import { rest } from 'msw';
import { getPolicies } from './policy.model';
import { getPolicies, getPolicyById } from './policy.model';

export const policyHandler = (_ => {
return [
rest.get(`*${ environment.apiUrl }/policies`, (req, res, ctx) => {
return res(ctx.status(200), ctx.json(getPolicies()));
})
}),

rest.post(`*${ environment.apiUrl }/policies`, (req, res, ctx) => {
return res(ctx.status(201), ctx.json('success'));
}),

rest.get(`*${ environment.apiUrl }/policies/:policyId`, (req, res, ctx) => {
const { policyId } = req.params;
const policy = getPolicyById(policyId);
return res(ctx.status(200), ctx.json(policy));
}),

rest.put(`*${ environment.apiUrl }/policies`, (req, res, ctx) => {
return res(ctx.status(200), ctx.json('success'));
}),

rest.delete(`*${ environment.apiUrl }/policies/:policyId`, (req, res, ctx) => {
return res(ctx.status(200), ctx.json('success'));
}),

]
})();
31 changes: 31 additions & 0 deletions frontend/src/app/mocks/services/policy-mock/policy.model.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { getOperatorTypeSign, OperatorType } from '@page/policies/model/policy.model';

describe('getOperatorTypeSign', () => {
it('should return "=" for OperatorType.EQ', () => {
expect(getOperatorTypeSign(OperatorType.EQ)).toBe('=');
});

it('should return "!=" for OperatorType.NEQ', () => {
expect(getOperatorTypeSign(OperatorType.NEQ)).toBe('!=');
});

it('should return "<" for OperatorType.LT', () => {
expect(getOperatorTypeSign(OperatorType.LT)).toBe('<');
});

it('should return ">" for OperatorType.GT', () => {
expect(getOperatorTypeSign(OperatorType.GT)).toBe('>');
});

it('should return "<=" for OperatorType.LTEQ', () => {
expect(getOperatorTypeSign(OperatorType.LTEQ)).toBe('<=');
});

it('should return ">=" for OperatorType.GTEQ', () => {
expect(getOperatorTypeSign(OperatorType.GTEQ)).toBe('>=');
});

it('should return the string representation of the type for unknown types', () => {
expect(getOperatorTypeSign('UNKNOWN' as OperatorType)).toBe('UNKNOWN');
});
});
201 changes: 175 additions & 26 deletions frontend/src/app/mocks/services/policy-mock/policy.model.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { OperatorType, Policy, PolicyAction, PolicyResponseMap } from '@page/policies/model/policy.model';

/********************************************************************************
* Copyright (c) 2022, 2023, 2024 Contributors to the Eclipse Foundation
*
Expand All @@ -17,36 +19,183 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
// For now Mocks are built by current response (any). This is because Policy Model changes frequently
export const getPolicies = () => [
export const getPolicies = (): Policy[] => {
return mockedPolicyList;
};

export const getPolicyById = (policyId: string | ReadonlyArray<string>): Policy => {
return mockedPolicyList.filter(policy => policy.policyId === policyId)[0];
};


export const mockedPolicyList: Policy[] = [
{
policyId: "Mocked_Policy_Id",
createdOn: 1706690077.834424001,
validUntil: 1727740799.990000000,
permissions: [
'policyId': 'default-policy',
'bpn': 'BPNL00000003CML1,BPNL00000003CNKC',
'createdOn': '2024-05-29T06:18:40Z',
'validUntil': '2029-05-29T06:18:40Z',
'permissions': [
{
action: "USE",
constraints: [
{
'action': PolicyAction.USE,
'constraints': {
'and': null,
'or': [
{
'leftOperand': 'cx-policy:FrameworkAgreement',
'operatorTypeResponse': OperatorType.EQ,
'rightOperand': 'traceability:1.0',
},
{
'leftOperand': 'cx-policy:UsagePurpose',
'operatorTypeResponse': OperatorType.EQ,
'rightOperand': 'cx.core.industrycore:1',
},
],
},
},
],
},
{
'policyId': 'default-policy-2',
'bpn': 'BPNL00000003CML1',
'createdOn': '2024-05-29T06:18:40Z',
'validUntil': '2029-05-29T06:18:40Z',
'permissions': [
{
'action': PolicyAction.USE,
'constraints': {
'and': [
{
'leftOperand': 'cx-policy:FrameworkAgreement',
'operatorTypeResponse': OperatorType.EQ,
'rightOperand': 'traceability:1.0',
},
{
'leftOperand': 'cx-policy:UsagePurpose',
'operatorTypeResponse': OperatorType.EQ,
'rightOperand': 'cx.core.industrycore:1',
},
],
'or': null,
},
},
],
},
];

const mockedPolicies = {
page: 0,
pageCount: 0,
pageSize: 10,
totalItems: 2,

content: [
{
bpnSelection: [ 'BPN10000000OEM0A', 'BPN10000000OEM0B' ],
policyName: 'Mocked_Policy_Name_1',
policyId: 'Mocked_Policy_1',
accessType: PolicyAction.ACCESS,
createdOn: '2024-05-29T06:18:40Z',
validUntil: '2024-05-29T06:18:40Z',
constraints: [ 'Membership = active', 'AND FrameworkAgreement.traceability in [active]', 'AND PURPOSE = ID 3.1 Trace' ],
permissions: [
{
action: PolicyAction.USE,
constraint: {
and: [
{
leftOperand: 'PURPOSE',
operator: {
id: OperatorType.EQ,
},
rightOperand: 'ID 3.0 Trace',
},
],
or: [
{
leftOperand: 'PURPOSE',
operator: {
id: OperatorType.EQ,
},
rightOperand: 'ID 3.0 Trace',
},
],
},
},
],
},
{
bpnSelection: [ 'BPN10000000OEM0A', 'BPN10000000OEM0B' ],
policyName: 'Mocked_Policy_Name_2',
policyId: 'Mocked_Policy_2',
accessType: PolicyAction.USE,
createdOn: '2024-05-29T06:18:40Z',
validUntil: '2024-05-29T06:18:40Z',
constraints: [ 'PURPOSE = ID 3.1 Trace', 'OR PURPOSE = ID 3.0 Trace' ],
permissions: [
{
action: PolicyAction.USE,
constraint: {
and: [
{
leftOperand: "PURPOSE",
operatorTypeResponse: "EQ",
rightOperands: [
"ID 3.0 Trace"
]
leftOperand: 'PURPOSE',
operator: {
id: OperatorType.IN,
},
rightOperand: 'BMW',
},
],
or: [
{
leftOperand: "PURPOSE",
operatorTypeResponse: "EQ",
rightOperands: [
"ID 3.0 Trace"
]
}
leftOperand: 'PURPOSE',
operator: {
id: OperatorType.EQ,
},
rightOperand: 'ID 3.0 Trace',
},
],
or: []
}
]
}
]
}
]
},
},
],
},

],

};

export const MockPolicyResponseMap: PolicyResponseMap = {
'default': [
{
'validUntil': '2024-06-30T11:07:00Z',
'payload': {
'@context': {
'odrl': 'http://www.w3.org/ns/odrl/2/',
},
'@id': 'asdadasdas',
'policy': {
'policyId': 'asdadasdas',
'createdOn': '2024-06-13T09:07:32.229901783Z',
'validUntil': '2024-06-30T11:07:00Z',
'permissions': [
{
'action': PolicyAction.USE,
'constraint': {
'and': null,
'or': [
{
'leftOperand': 'asd',
'operator': {
'@id': OperatorType.EQ,
},
'odrl:rightOperand': 'dsa',
},
],
},
},
],
},
},
},
],
};

3 changes: 3 additions & 0 deletions frontend/src/app/modules/core/user/table-settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { NotificationsReceivedConfigurationModel } from '@shared/components/part
import { NotificationsSentConfigurationModel } from '@shared/components/parts-table/notifications-sent-configuration.model';
import { PartsAsBuiltConfigurationModel } from '@shared/components/parts-table/parts-as-built-configuration.model';
import { PartsAsPlannedConfigurationModel } from '@shared/components/parts-table/parts-as-planned-configuration.model';
import { PoliciesConfigurationModel } from '@shared/components/parts-table/policies-configuration.model';
import { TableViewConfig } from '@shared/components/parts-table/table-view-config.model';
import { ToastService } from '@shared/components/toasts/toast.service';
import { Subject } from 'rxjs';
Expand Down Expand Up @@ -112,6 +113,8 @@ export class TableSettingsService {
return new NotificationsSentConfigurationModel().filterConfiguration();
case TableType.RECEIVED_NOTIFICATION:
return new NotificationsReceivedConfigurationModel().filterConfiguration();
case TableType.POLICIES:
return new PoliciesConfigurationModel().filterConfiguration();
}
}

Expand Down
49 changes: 28 additions & 21 deletions frontend/src/app/modules/page/admin/admin.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,36 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {getI18nPageProvider} from '@core/i18n';
import {AdminFacade} from '@page/admin/core/admin.facade';
import {AdminService} from '@page/admin/core/admin.service';
import {ContractDetailComponent} from '@page/admin/presentation/contracts/contract-detail/contract-detail.component';
import {ContractsComponent} from '@page/admin/presentation/contracts/contracts.component';
import {ContractsFacade} from '@page/admin/presentation/contracts/contracts.facade';
import {ContractsState} from '@page/admin/presentation/contracts/contracts.state';
import {ModalModule} from '@shared/modules/modal/modal.module';
import {SharedModule} from '@shared/shared.module';
import {TemplateModule} from '@shared/template.module';
import {AdminRoutingModule} from './admin.routing';
import {AdminComponent} from './presentation/admin.component';
import {BpnConfigurationComponent} from './presentation/bpn-configuration/bpn-configuration.component';
import {SaveBpnConfigModal} from './presentation/bpn-configuration/save-modal/save-modal.component';
import {ImportJsonComponent} from './presentation/import-json/import-json.component';
import {NgxJsonViewerModule} from "ngx-json-viewer";
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { MatLineModule } from '@angular/material/core';
import { getI18nPageProvider } from '@core/i18n';
import { AdminFacade } from '@page/admin/core/admin.facade';
import { AdminService } from '@page/admin/core/admin.service';
import { ContractDetailComponent } from '@page/admin/presentation/contracts/contract-detail/contract-detail.component';
import { ContractsComponent } from '@page/admin/presentation/contracts/contracts.component';
import { ContractsFacade } from '@page/admin/presentation/contracts/contracts.facade';
import { ContractsState } from '@page/admin/presentation/contracts/contracts.state';
import { DeletionDialogComponent } from '@page/admin/presentation/policy-management/deletion-dialog/deletion-dialog.component';
import { PoliciesComponent } from '@page/admin/presentation/policy-management/policies/policies.component';
import { PoliciesFacade } from '@page/admin/presentation/policy-management/policies/policies.facade';
import { PoliciesState } from '@page/admin/presentation/policy-management/policies/policies.state';
import { PolicyEditorComponent } from '@page/admin/presentation/policy-management/policy-editor/policy-editor.component';
import { ModalModule } from '@shared/modules/modal/modal.module';
import { PolicyService } from '@shared/service/policy.service';
import { SharedModule } from '@shared/shared.module';
import { TemplateModule } from '@shared/template.module';
import { NgxJsonViewerModule } from 'ngx-json-viewer';
import { AdminRoutingModule } from './admin.routing';
import { AdminComponent } from './presentation/admin.component';
import { BpnConfigurationComponent } from './presentation/bpn-configuration/bpn-configuration.component';
import { SaveBpnConfigModal } from './presentation/bpn-configuration/save-modal/save-modal.component';
import { ImportJsonComponent } from './presentation/import-json/import-json.component';

@NgModule({
declarations: [ AdminComponent, BpnConfigurationComponent, SaveBpnConfigModal, ImportJsonComponent, ContractsComponent, ContractDetailComponent ],
imports: [CommonModule, TemplateModule, SharedModule, AdminRoutingModule, ModalModule, NgxJsonViewerModule],
providers: [ ...getI18nPageProvider('page.admin'), AdminService, AdminFacade, ContractsFacade, ContractsState ],
declarations: [ AdminComponent, BpnConfigurationComponent, SaveBpnConfigModal, ImportJsonComponent, ContractsComponent, ContractDetailComponent, PoliciesComponent, DeletionDialogComponent, PolicyEditorComponent ],
imports: [ CommonModule, TemplateModule, SharedModule, AdminRoutingModule, ModalModule, NgxJsonViewerModule, MatLineModule ],
providers: [ ...getI18nPageProvider('page.admin'), AdminService, AdminFacade, ContractsFacade, ContractsState, PoliciesFacade, PoliciesState, PolicyService ],
})
export class AdminModule {
}
Loading
Loading