Search in sources :

Example 26 with DefaultApplicationId

use of org.onosproject.core.DefaultApplicationId in project onos by opennetworkinglab.

the class SimpleGroupStoreTest method testGroupOperationFailure.

@Test
public void testGroupOperationFailure() {
    simpleGroupStore.deviceInitialAuditCompleted(D1, true);
    ApplicationId appId = new DefaultApplicationId(2, "org.groupstore.test");
    GroupKey key = new DefaultGroupKey("group1".getBytes());
    PortNumber[] ports = { PortNumber.portNumber(31), PortNumber.portNumber(32) };
    List<PortNumber> outPorts = new ArrayList<>();
    outPorts.add(ports[0]);
    outPorts.add(ports[1]);
    List<GroupBucket> buckets = new ArrayList<>();
    for (PortNumber portNumber : outPorts) {
        TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
        tBuilder.setOutput(portNumber).setEthDst(MacAddress.valueOf("00:00:00:00:00:02")).setEthSrc(MacAddress.valueOf("00:00:00:00:00:01")).pushMpls().setMpls(MplsLabel.mplsLabel(106));
        buckets.add(DefaultGroupBucket.createSelectGroupBucket(tBuilder.build()));
    }
    GroupBuckets groupBuckets = new GroupBuckets(buckets);
    GroupDescription groupDesc = new DefaultGroupDescription(D1, Group.Type.SELECT, groupBuckets, key, null, appId);
    InternalGroupStoreDelegate checkStoreGroupDelegate = new InternalGroupStoreDelegate(key, groupBuckets, GroupEvent.Type.GROUP_ADD_REQUESTED);
    simpleGroupStore.setDelegate(checkStoreGroupDelegate);
    // Testing storeGroup operation
    simpleGroupStore.storeGroupDescription(groupDesc);
    simpleGroupStore.unsetDelegate(checkStoreGroupDelegate);
    // Testing Group add operation failure
    Group createdGroup = simpleGroupStore.getGroup(D1, key);
    checkStoreGroupDelegate.verifyGroupId(createdGroup.id());
    GroupOperation groupAddOp = GroupOperation.createAddGroupOperation(createdGroup.id(), createdGroup.type(), createdGroup.buckets());
    InternalGroupStoreDelegate checkGroupAddFailureDelegate = new InternalGroupStoreDelegate(key, groupBuckets, GroupEvent.Type.GROUP_ADD_FAILED);
    simpleGroupStore.setDelegate(checkGroupAddFailureDelegate);
    simpleGroupStore.groupOperationFailed(D1, groupAddOp);
    // Testing Group modify operation failure
    simpleGroupStore.unsetDelegate(checkGroupAddFailureDelegate);
    GroupOperation groupModOp = GroupOperation.createModifyGroupOperation(createdGroup.id(), createdGroup.type(), createdGroup.buckets());
    InternalGroupStoreDelegate checkGroupModFailureDelegate = new InternalGroupStoreDelegate(key, groupBuckets, GroupEvent.Type.GROUP_UPDATE_FAILED);
    simpleGroupStore.setDelegate(checkGroupModFailureDelegate);
    simpleGroupStore.groupOperationFailed(D1, groupModOp);
    // Testing Group modify operation failure
    simpleGroupStore.unsetDelegate(checkGroupModFailureDelegate);
    GroupOperation groupDelOp = GroupOperation.createDeleteGroupOperation(createdGroup.id(), createdGroup.type());
    InternalGroupStoreDelegate checkGroupDelFailureDelegate = new InternalGroupStoreDelegate(key, groupBuckets, GroupEvent.Type.GROUP_REMOVE_FAILED);
    simpleGroupStore.setDelegate(checkGroupDelFailureDelegate);
    simpleGroupStore.groupOperationFailed(D1, groupDelOp);
}
Also used : DefaultGroup(org.onosproject.net.group.DefaultGroup) Group(org.onosproject.net.group.Group) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) ArrayList(java.util.ArrayList) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) GroupBuckets(org.onosproject.net.group.GroupBuckets) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId) PortNumber(org.onosproject.net.PortNumber) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupOperation(org.onosproject.net.group.GroupOperation) Test(org.junit.Test)

Example 27 with DefaultApplicationId

use of org.onosproject.core.DefaultApplicationId in project onos by opennetworkinglab.

the class DistributedSecurityModeStoreTest method setUp.

@Before
public void setUp() throws Exception {
    appId = new DefaultApplicationId(1, "test");
    testPermissions = new HashSet<Permission>();
    testPermission = new Permission("testClass", "testName");
    testPermissions.add(testPermission);
    testFeatures = new ArrayList<String>();
    testFeatures.add("testFeature");
    testRequiredApps = new ArrayList<String>();
    testRequiredApps.add("testRequiredApp");
    app = DefaultApplication.builder().withAppId(appId).withVersion(Version.version(1, 1, "patch", "build")).withTitle("testTitle").withDescription("testDes").withOrigin("testOri").withCategory("testCT").withUrl("testurl").withReadme("test").withIcon(null).withRole(ApplicationRole.ADMIN).withPermissions(testPermissions).withFeaturesRepo(Optional.ofNullable(null)).withFeatures(testFeatures).withRequiredApps(testRequiredApps).build();
    testLocations = new HashSet<String>();
    testLocations.add("locationA");
    testLocations.add("locationB");
    Set<ApplicationId> appIdSet = new HashSet<ApplicationId>();
    appIdSet.add(appId);
    localBundleAppDirectory = new ConcurrentHashMap<>();
    localBundleAppDirectory.put("testLocation", appIdSet);
    localAppBundleDirectory = new ConcurrentHashMap<>();
    localAppBundleDirectory.put(appId, testLocations);
    violations = new ConcurrentHashMap<ApplicationId, Set<Permission>>();
    violations.put(appId, testPermissions);
    testSecInfo = new SecurityInfo(testPermissions, SECURED);
    states = new ConcurrentHashMap<ApplicationId, SecurityInfo>();
    states.put(appId, testSecInfo);
}
Also used : HashSet(java.util.HashSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) Permission(org.onosproject.security.Permission) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 28 with DefaultApplicationId

use of org.onosproject.core.DefaultApplicationId in project onos by opennetworkinglab.

the class SecurityModeManagerTest method testGetPrintableRequestedPermissions.

@Test
public void testGetPrintableRequestedPermissions() {
    DefaultApplicationId appIdViolation;
    appIdViolation = new DefaultApplicationId(2, "violation");
    Map<Integer, List<Permission>> result = getPrintablePermissionMap(store.getRequestedPermissions(appIdViolation));
    assertNotNull(result.get(2).get(0));
    assertTrue(result.get(2).size() > 0);
    assertEquals("testNameViolation", result.get(2).get(0).getName());
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) Test(org.junit.Test)

Aggregations

DefaultApplicationId (org.onosproject.core.DefaultApplicationId)28 ApplicationId (org.onosproject.core.ApplicationId)19 Test (org.junit.Test)12 IntentMonitorAndRerouteService (org.onosproject.imr.IntentMonitorAndRerouteService)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 WebTarget (javax.ws.rs.client.WebTarget)3 Response (javax.ws.rs.core.Response)3 Before (org.junit.Before)3 TunnelService (org.onosproject.incubator.net.tunnel.TunnelService)3 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)3 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)3 FlowRule (org.onosproject.net.flow.FlowRule)3 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)3 EqualsTester (com.google.common.testing.EqualsTester)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 DefaultOpticalTunnelEndPoint (org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint)2