src-test/src/org/openbravo/test/security/StandardCrossOrganizationReference.java
changeset 35436 7d8efc4cd8e1
parent 28893 87ce51248fba
equal deleted inserted replaced
35435:e1f91029fa2b 35436:7d8efc4cd8e1
     9  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
     9  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
    10  * License for the specific  language  governing  rights  and  limitations
    10  * License for the specific  language  governing  rights  and  limitations
    11  * under the License. 
    11  * under the License. 
    12  * The Original Code is Openbravo ERP. 
    12  * The Original Code is Openbravo ERP. 
    13  * The Initial Developer of the Original Code is Openbravo SLU 
    13  * The Initial Developer of the Original Code is Openbravo SLU 
    14  * All portions are Copyright (C) 2016 Openbravo SLU 
    14  * All portions are Copyright (C) 2016-2019 Openbravo SLU 
    15  * All Rights Reserved. 
    15  * All Rights Reserved. 
    16  * Contributor(s):  ______________________________________.
    16  * Contributor(s):  ______________________________________.
    17  ************************************************************************
    17  ************************************************************************
    18  */
    18  */
    19 
    19 
    20 package org.openbravo.test.security;
    20 package org.openbravo.test.security;
    21 
    21 
       
    22 import static org.hamcrest.Matchers.is;
       
    23 import static org.junit.Assert.assertThat;
       
    24 
    22 import org.junit.Ignore;
    25 import org.junit.Ignore;
    23 import org.junit.Test;
    26 import org.junit.Test;
    24 import org.openbravo.base.exception.OBSecurityException;
    27 import org.openbravo.base.exception.OBSecurityException;
       
    28 import org.openbravo.dal.core.OBContext;
    25 import org.openbravo.dal.service.OBDal;
    29 import org.openbravo.dal.service.OBDal;
    26 import org.openbravo.model.common.enterprise.Warehouse;
    30 import org.openbravo.model.common.enterprise.Warehouse;
    27 import org.openbravo.model.common.order.Order;
    31 import org.openbravo.model.common.order.Order;
    28 
    32 
    29 /**
    33 /**
    52 
    56 
    53     exception.expect(OBSecurityException.class);
    57     exception.expect(OBSecurityException.class);
    54 
    58 
    55     OBDal.getInstance().commitAndClose();
    59     OBDal.getInstance().commitAndClose();
    56   }
    60   }
       
    61 
       
    62   @Test
       
    63   public void combinedAdminAndCrossOrgModes() {
       
    64     try {
       
    65       OBContext.setAdminMode(false);
       
    66       assertThat("Admin mode (no cross org)", OBContext.getOBContext().isInAdministratorMode(),
       
    67           is(true));
       
    68       assertThat("No cross org mode (in admin)",
       
    69           OBContext.getOBContext().isInCrossOrgAdministratorMode(), is(false));
       
    70 
       
    71       OBContext.setCrossOrgReferenceAdminMode();
       
    72       assertThat("Admin mode (with cross org)", OBContext.getOBContext().isInAdministratorMode(),
       
    73           is(true));
       
    74       assertThat("Cross org mode (in admin)",
       
    75           OBContext.getOBContext().isInCrossOrgAdministratorMode(), is(true));
       
    76     } finally {
       
    77       OBContext.restorePreviousMode();
       
    78       OBContext.restorePreviousCrossOrgReferenceMode();
       
    79     }
       
    80   }
    57 }
    81 }