-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from fabric-testbed/project.educational
Project.educational support
- Loading branch information
Showing
5 changed files
with
161 additions
and
23 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,12 @@ | ||
# Overview | ||
|
||
This directory is used by the test harness, you can put the .jar files from authzforce distribution, like authzforce-ce-core-pdp-cli-20.1.0.jar, into this folder. Note that the test harness uses a combination of the jar files here and the running PDP Docker container. | ||
|
||
You can also add javalib/ folder in here to hold any missing java dependencies for starting the CLI jar above. For example | ||
|
||
javalib/ | ||
├── jaxb-api-2.2.11.jar | ||
├── jaxb-api-2.3.0.jar | ||
└── jaxb-runtime-2.2.11.jar | ||
|
||
|
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -22,7 +22,8 @@ | |
NOPDP = 'pdp-no.xml' | ||
|
||
# make sure the CLI executable and appropriate Java version are available | ||
AUTHZFORCECLI = '../authzforce/authzforce-ce-core-pdp-cli-20.1.0.jar' | ||
#AUTHZFORCECLI = '../authzforce/authzforce-ce-core-pdp-cli-20.1.0.jar' | ||
AUTHZFORCECLI = '../authzforce/authzforce-ce-core-pdp-cli-20.3.2.jar' | ||
PERMIT_REQUESTS = [ | ||
'../policies/alfa/Requests/orchestrator-request-simplest.json', | ||
'../policies/alfa/Requests/orchestrator-request-simple.json', | ||
|
@@ -63,10 +64,10 @@ def setUp(self) -> None: | |
makePDPFile(NOPOLICY, NOPOLICYID, NOPDP) | ||
|
||
def tearDown(self) -> None: | ||
print('Deleting pdp.xml file') | ||
os.unlink('pdp-tag.xml') | ||
os.unlink('pdp-yes.xml') | ||
os.unlink('pdp-no.xml') | ||
print('Deleting pdp.xml files') | ||
os.unlink(TAGPDP) | ||
os.unlink(YESPDP) | ||
os.unlink(NOPDP) | ||
pass | ||
|
||
def runOnAllRequests(self, pdpFile, outcome='Permit', printResponse=False): | ||
|
@@ -441,7 +442,7 @@ def testModifyFail1(self) -> None: | |
def testFABNetv4ExtOK(self) -> None: | ||
|
||
""" | ||
Test that adding FABNetv4 with proper tag works | ||
Test that adding FABNetv4Ext with proper tag works | ||
""" | ||
t = fu.ExperimentTopology() | ||
n1 = t.add_node(name='n1', site='RENC', capacities=fu.Capacities(core=1, ram=10, disk=25)) | ||
|
@@ -479,7 +480,7 @@ def testFABNetv4ExtOK(self) -> None: | |
def testFABNetv4ExtFail(self) -> None: | ||
|
||
""" | ||
Test that adding FABNetv4 with proper tag fails | ||
Test that adding FABNetv4Ext without proper tag fails | ||
""" | ||
t = fu.ExperimentTopology() | ||
n1 = t.add_node(name='n1', site='RENC', capacities=fu.Capacities(core=1, ram=10, disk=25)) | ||
|
@@ -517,7 +518,7 @@ def testFABNetv4ExtFail(self) -> None: | |
def testFABNetv6ExtOK(self) -> None: | ||
|
||
""" | ||
Test that adding FABNetv4 with proper tag works | ||
Test that adding FABNetv6Ext with proper tag works | ||
""" | ||
t = fu.ExperimentTopology() | ||
n1 = t.add_node(name='n1', site='RENC', capacities=fu.Capacities(core=1, ram=10, disk=25)) | ||
|
@@ -555,7 +556,7 @@ def testFABNetv6ExtOK(self) -> None: | |
def testFABNetv6ExtFail(self) -> None: | ||
|
||
""" | ||
Test that adding FABNetv4 with proper tag fails | ||
Test that adding FABNetv6Ext without proper tag fails | ||
""" | ||
t = fu.ExperimentTopology() | ||
n1 = t.add_node(name='n1', site='RENC', capacities=fu.Capacities(core=1, ram=10, disk=25)) | ||
|
@@ -684,4 +685,115 @@ def testFacilityFail(self) -> None: | |
authz.set_resource_subject_and_project(subject_id='[email protected]', project='MyProject') | ||
|
||
print(f"FacilityFail: {authz.transform_to_pdp_request()}") | ||
self.runOnStringRequest(authz.transform_to_pdp_request(), TAGPDP, 'Deny') | ||
self.runOnStringRequest(authz.transform_to_pdp_request(), TAGPDP, 'Deny') | ||
|
||
def testEducationalOK(self) -> None: | ||
|
||
""" | ||
Test that adding using EDUKY with Project.Educational is OK | ||
""" | ||
t = fu.ExperimentTopology() | ||
n1 = t.add_node(name='n1', site='EDUKY', capacities=fu.Capacities(core=1, ram=10, disk=25)) | ||
c1 = n1.add_component(name='c1', model_type=fu.ComponentModelType.SmartNIC_ConnectX_6) | ||
c2 = n1.add_component(name='c2', model_type=fu.ComponentModelType.SharedNIC_ConnectX_6) | ||
n2 = t.add_node(name='n2', site='EDUKY', capacities=fu.Capacities(core=10, ram=10, disk=35)) | ||
c4 = n2.add_component(name='c4', model_type=fu.ComponentModelType.SmartNIC_ConnectX_5) | ||
s1 = t.add_network_service(name='s1', nstype=fu.ServiceType.FABNetv6Ext, | ||
interfaces=[c1.interface_list[0]]) | ||
s2 = t.add_network_service(name='s2', nstype=fu.ServiceType.FABNetv6Ext, | ||
interfaces=[c4.interface_list[0]]) | ||
|
||
t.validate() | ||
|
||
authz = ResourceAuthZAttributes() | ||
|
||
now = datetime.datetime.now(datetime.timezone.utc) | ||
delta = datetime.timedelta(days=13, hours=11, minutes=7, seconds=4, milliseconds=10) | ||
future = now + delta | ||
|
||
authz.collect_resource_attributes(source=t) | ||
authz.set_action('create') | ||
authz.set_lifetime(future) | ||
authz.set_subject_attributes(subject_id='[email protected]', project='MyProject', project_tag=[ | ||
'VM.NoLimit', | ||
'Component.SmartNIC', 'Net.FABNetv6Ext', | ||
'Project.Educational' | ||
]) | ||
authz.set_resource_subject_and_project(subject_id='[email protected]', project='MyProject') | ||
|
||
print(f"EducationalOK: {authz.transform_to_pdp_request()}") | ||
self.runOnStringRequest(authz.transform_to_pdp_request(), TAGPDP) | ||
|
||
def testEducationalFail(self) -> None: | ||
|
||
""" | ||
Test that adding using non-UKY with Project.Educational fails | ||
""" | ||
t = fu.ExperimentTopology() | ||
n1 = t.add_node(name='n1', site='RENC', capacities=fu.Capacities(core=1, ram=10, disk=25)) | ||
c1 = n1.add_component(name='c1', model_type=fu.ComponentModelType.SmartNIC_ConnectX_6) | ||
c2 = n1.add_component(name='c2', model_type=fu.ComponentModelType.SharedNIC_ConnectX_6) | ||
n2 = t.add_node(name='n2', site='RENC', capacities=fu.Capacities(core=10, ram=10, disk=35)) | ||
c4 = n2.add_component(name='c4', model_type=fu.ComponentModelType.SmartNIC_ConnectX_5) | ||
s1 = t.add_network_service(name='s1', nstype=fu.ServiceType.FABNetv6Ext, | ||
interfaces=[c1.interface_list[0]]) | ||
s2 = t.add_network_service(name='s2', nstype=fu.ServiceType.FABNetv6Ext, | ||
interfaces=[c4.interface_list[0]]) | ||
|
||
t.validate() | ||
|
||
authz = ResourceAuthZAttributes() | ||
|
||
now = datetime.datetime.now(datetime.timezone.utc) | ||
delta = datetime.timedelta(days=13, hours=11, minutes=7, seconds=4, milliseconds=10) | ||
future = now + delta | ||
|
||
authz.collect_resource_attributes(source=t) | ||
authz.set_action('create') | ||
authz.set_lifetime(future) | ||
authz.set_subject_attributes(subject_id='[email protected]', project='MyProject', project_tag=[ | ||
'VM.NoLimit', | ||
'Component.SmartNIC', 'Net.FABNetv6Ext', | ||
'Project.Educational' | ||
]) | ||
authz.set_resource_subject_and_project(subject_id='[email protected]', project='MyProject') | ||
|
||
print(f"EducationalFail: {authz.transform_to_pdp_request()}") | ||
self.runOnStringRequest(authz.transform_to_pdp_request(), TAGPDP, 'Deny') | ||
|
||
def testEducationalMultisiteOK(self) -> None: | ||
|
||
""" | ||
Test that adding using non-UKY with Project.Educational and Slice.Multisite is OK | ||
""" | ||
t = fu.ExperimentTopology() | ||
n1 = t.add_node(name='n1', site='RENC', capacities=fu.Capacities(core=1, ram=10, disk=25)) | ||
c1 = n1.add_component(name='c1', model_type=fu.ComponentModelType.SmartNIC_ConnectX_6) | ||
c2 = n1.add_component(name='c2', model_type=fu.ComponentModelType.SharedNIC_ConnectX_6) | ||
n2 = t.add_node(name='n2', site='UKY', capacities=fu.Capacities(core=10, ram=10, disk=35)) | ||
c4 = n2.add_component(name='c4', model_type=fu.ComponentModelType.SmartNIC_ConnectX_5) | ||
s1 = t.add_network_service(name='s1', nstype=fu.ServiceType.FABNetv6Ext, | ||
interfaces=[c1.interface_list[0]]) | ||
s2 = t.add_network_service(name='s2', nstype=fu.ServiceType.FABNetv6Ext, | ||
interfaces=[c4.interface_list[0]]) | ||
|
||
t.validate() | ||
|
||
authz = ResourceAuthZAttributes() | ||
|
||
now = datetime.datetime.now(datetime.timezone.utc) | ||
delta = datetime.timedelta(days=13, hours=11, minutes=7, seconds=4, milliseconds=10) | ||
future = now + delta | ||
|
||
authz.collect_resource_attributes(source=t) | ||
authz.set_action('create') | ||
authz.set_lifetime(future) | ||
authz.set_subject_attributes(subject_id='[email protected]', project='MyProject', project_tag=[ | ||
'VM.NoLimit', | ||
'Component.SmartNIC', 'Net.FABNetv6Ext', | ||
'Project.Educational', 'Slice.Multisite' | ||
]) | ||
authz.set_resource_subject_and_project(subject_id='[email protected]', project='MyProject') | ||
|
||
print(f"EducationalMultisiteOK: {authz.transform_to_pdp_request()}") | ||
self.runOnStringRequest(authz.transform_to_pdp_request(), TAGPDP) |