Search in sources :

Example 6 with PerunSessionImpl

use of cz.metacentrum.perun.core.impl.PerunSessionImpl in project perun by CESNET.

the class PerunBlImpl method getPerunSession.

/**
	 * This method is used only internally.
	 *
	 */
public PerunSession getPerunSession() throws InternalErrorException {
    PerunPrincipal principal = new PerunPrincipal(INTERNALPRINCIPAL, ExtSourcesManager.EXTSOURCE_NAME_INTERNAL, ExtSourcesManager.EXTSOURCE_INTERNAL);
    PerunClient client = new PerunClient();
    return new PerunSessionImpl(this, principal, client);
}
Also used : PerunClient(cz.metacentrum.perun.core.api.PerunClient) PerunPrincipal(cz.metacentrum.perun.core.api.PerunPrincipal) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl)

Example 7 with PerunSessionImpl

use of cz.metacentrum.perun.core.impl.PerunSessionImpl in project perun by CESNET.

the class urn_perun_member_group_attribute_def_virt_isGroupAdminTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_member_group_attribute_def_virt_isGroupAdmin();
    usersManager = perun.getUsersManager();
    vosManager = perun.getVosManager();
    membersManager = perun.getMembersManager();
    groupsManager = perun.getGroupsManager();
    final PerunPrincipal pp = new PerunPrincipal("perunTests", ExtSourcesManager.EXTSOURCE_NAME_INTERNAL, ExtSourcesManager.EXTSOURCE_INTERNAL);
    this.session = new PerunSessionImpl(perun, pp, new PerunClient());
    this.attrDef = classInstance.getAttributeDefinition();
    this.attribute = new Attribute(attrDef);
    this.user = setUpUser();
    this.vo = setUpVo();
    this.member = setUpMember(vo);
    this.group = setUpGroup(vo, member);
}
Also used : PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) Before(org.junit.Before)

Example 8 with PerunSessionImpl

use of cz.metacentrum.perun.core.impl.PerunSessionImpl in project perun by CESNET.

the class ModulesUtilsEntryIntegrationTest method haveTheSameAttributeWithTheSameNamespace2ForGroup.

@Test
public void haveTheSameAttributeWithTheSameNamespace2ForGroup() throws Exception {
    System.out.println(CLASS_NAME + "haveTheSameAttributeWithTheSameNamespace2ForGroup");
    vo = setUpVo();
    facility = setUpFacility();
    resource = setUpResource();
    group = setUpGroup();
    List<Group> groups = new ArrayList<Group>();
    groups.add(group);
    List<Attribute> attrs = setUpGroupAttribute();
    perun.getAttributesManagerBl().setAttribute(sess, group, attrs.get(0));
    Attribute attr = attrs.get(0);
    attr.setValue("Jina value");
    assertEquals(1, modulesUtilsBl.haveTheSameAttributeWithTheSameNamespace((PerunSessionImpl) sess, group, attrs.get(0)));
}
Also used : Group(cz.metacentrum.perun.core.api.Group) Attribute(cz.metacentrum.perun.core.api.Attribute) ArrayList(java.util.ArrayList) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 9 with PerunSessionImpl

use of cz.metacentrum.perun.core.impl.PerunSessionImpl in project perun by CESNET.

the class ModulesUtilsEntryIntegrationTest method haveTheSameAttributeWithTheSameNamespace2ForResource.

@Test
public void haveTheSameAttributeWithTheSameNamespace2ForResource() throws Exception {
    System.out.println(CLASS_NAME + "haveTheSameAttributeWithTheSameNamespace2");
    vo = setUpVo();
    facility = setUpFacility();
    resource = setUpResource();
    List<Resource> resources = new ArrayList<Resource>();
    resources.add(resource);
    List<Attribute> attrs = setUpResourceAttribute();
    perun.getAttributesManagerBl().setAttribute(sess, resource, attrs.get(0));
    Attribute attr = attrs.get(0);
    attr.setValue("Jina value");
    assertEquals(1, modulesUtilsBl.haveTheSameAttributeWithTheSameNamespace((PerunSessionImpl) sess, resource, attrs.get(0)));
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) ArrayList(java.util.ArrayList) Resource(cz.metacentrum.perun.core.api.Resource) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 10 with PerunSessionImpl

use of cz.metacentrum.perun.core.impl.PerunSessionImpl in project perun by CESNET.

the class ModulesUtilsEntryIntegrationTest method haveRightToWriteAttributeInAnyGroupOrResource.

@Test
public void haveRightToWriteAttributeInAnyGroupOrResource() throws Exception {
    System.out.println(CLASS_NAME + "haveRightToWriteAttributeInAnyGroupOrResource");
    Attribute minGID = new Attribute(perun.getAttributesManagerBl().getAttributeDefinition(sess, AttributesManager.NS_ENTITYLESS_ATTR_DEF + ":namespace-minGID"));
    perun.getAttributesManagerBl().setAttribute(sess, namespace, minGID);
    vo = setUpVo();
    facility = setUpFacility();
    resource = setUpResource();
    group = setUpGroup();
    List<Group> groups = new ArrayList<Group>();
    List<Resource> resources = new ArrayList<Resource>();
    groups.add(group);
    resources.add(resource);
    assertTrue(modulesUtilsBl.haveRightToWriteAttributeInAnyGroupOrResource((PerunSessionImpl) sess, groups, null, minGID, minGID));
    assertTrue(modulesUtilsBl.haveRightToWriteAttributeInAnyGroupOrResource((PerunSessionImpl) sess, null, resources, minGID, minGID));
    assertTrue(modulesUtilsBl.haveRightToWriteAttributeInAnyGroupOrResource((PerunSessionImpl) sess, groups, resources, minGID, minGID));
    assertFalse(modulesUtilsBl.haveRightToWriteAttributeInAnyGroupOrResource((PerunSessionImpl) sess, null, null, minGID, minGID));
}
Also used : Group(cz.metacentrum.perun.core.api.Group) Attribute(cz.metacentrum.perun.core.api.Attribute) ArrayList(java.util.ArrayList) Resource(cz.metacentrum.perun.core.api.Resource) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Aggregations

PerunSessionImpl (cz.metacentrum.perun.core.impl.PerunSessionImpl)10 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)7 Test (org.junit.Test)7 Attribute (cz.metacentrum.perun.core.api.Attribute)6 ArrayList (java.util.ArrayList)5 Group (cz.metacentrum.perun.core.api.Group)3 Resource (cz.metacentrum.perun.core.api.Resource)3 ExtSource (cz.metacentrum.perun.core.api.ExtSource)1 PerunClient (cz.metacentrum.perun.core.api.PerunClient)1 PerunPrincipal (cz.metacentrum.perun.core.api.PerunPrincipal)1 UserExtSource (cz.metacentrum.perun.core.api.UserExtSource)1 ExtSourceNotExistsException (cz.metacentrum.perun.core.api.exceptions.ExtSourceNotExistsException)1 UserExtSourceNotExistsException (cz.metacentrum.perun.core.api.exceptions.UserExtSourceNotExistsException)1 UserNotExistsException (cz.metacentrum.perun.core.api.exceptions.UserNotExistsException)1 Before (org.junit.Before)1