Project

General

Profile

« Previous | Next » 

Revision 6577

MN.setAccessPolicy() is deprecated, commenting out the test.

View differences:

test/edu/ucsb/nceas/metacat/dataone/MNodeServiceTest.java
815 815
  public void testSetAccessPolicy() {
816 816
    printTestHeader("testSetAccess");
817 817
    
818
    boolean accessWasSet = false;
819
    
820
    try {
821
      // create an object to set access on
822
      Session session = getTestSession();
823
      Identifier guid = new Identifier();
824
      guid.setValue("testSetAccess." + System.currentTimeMillis());
825
      InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
826
      SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
827
      Identifier pid = 
828
        MNodeService.getInstance(request).create(session, guid, object, sysmeta);
829
      // set the access
830
      AccessPolicy accessPolicy = new AccessPolicy();
831
      AccessRule allow = new AccessRule();
832
      allow.addPermission(Permission.WRITE);
833
      Subject publicSubject = new Subject();
834
      publicSubject.setValue(Constants.SUBJECT_PUBLIC);
835
      allow.addSubject(publicSubject);
836
      accessPolicy.addAllow(allow);
818
    //boolean accessWasSet = false;
819
    //
820
    //try {
821
    //  // create an object to set access on
822
    //  Session session = getTestSession();
823
    //  Identifier guid = new Identifier();
824
    //  guid.setValue("testSetAccess." + System.currentTimeMillis());
825
    //  InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
826
    //  SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
827
    //  Identifier pid = 
828
    //    MNodeService.getInstance(request).create(session, guid, object, sysmeta);
829
    //  // set the access
830
    //  AccessPolicy accessPolicy = new AccessPolicy();
831
    //  AccessRule allow = new AccessRule();
832
    //  allow.addPermission(Permission.WRITE);
833
    //  Subject publicSubject = new Subject();
834
    //  publicSubject.setValue(Constants.SUBJECT_PUBLIC);
835
    //  allow.addSubject(publicSubject);
836
    //  accessPolicy.addAllow(allow);
837
    //  
838
    //  accessWasSet = 
839
    //    MNodeService.getInstance(request).setAccessPolicy(session, pid, accessPolicy);
840
    //  assertTrue(accessWasSet);
841
    //  // test that it is enforced
842
    //  session.setSubject(publicSubject);
843
    //  boolean isAuthorized = MNodeService.getInstance(request).isAuthorized(session, pid, Permission.WRITE);
844
    //  assertTrue(isAuthorized);
845
    //
846
    //} catch (UnsupportedEncodingException e) {
847
    //  e.printStackTrace();
848
    //  
849
    //} catch (InvalidToken e) {
850
    //  e.printStackTrace();
851
    //  fail("Unexpected error: " + e.getMessage());
852
    //  
853
    //} catch (ServiceFailure e) {
854
    //  e.printStackTrace();
855
    //  fail("Unexpected error: " + e.getMessage());
856
    //  
857
    //} catch (NotAuthorized e) {
858
    //  e.printStackTrace();
859
    //  fail("Unexpected error: " + e.getMessage());
860
    //  
861
    //} catch (IdentifierNotUnique e) {
862
    //  e.printStackTrace();
863
    //  fail("Unexpected error: " + e.getMessage());
864
    //  
865
    //} catch (UnsupportedType e) {
866
    //  e.printStackTrace();
867
    //  fail("Unexpected error: " + e.getMessage());
868
    //  
869
    //} catch (InsufficientResources e) {
870
    //  e.printStackTrace();
871
    //  fail("Unexpected error: " + e.getMessage());
872
    //  
873
    //} catch (InvalidSystemMetadata e) {
874
    //  e.printStackTrace();
875
    //  fail("Unexpected error: " + e.getMessage());
876
    //  
877
    //} catch (NotImplemented e) {
878
    //  e.printStackTrace();
879
    //  fail("Unexpected error: " + e.getMessage());
880
    //  
881
    //} catch (InvalidRequest e) {
882
    //  e.printStackTrace();
883
    //  fail("Unexpected error: " + e.getMessage());
884
    //  
885
    //} catch (NotFound e) {
886
    //  e.printStackTrace();
887
    //  fail("Unexpected error: " + e.getMessage());
888
    //  
889
    //} catch (Exception e) {
890
    //  e.printStackTrace();
891
    //  fail("Unexpected error: " + e.getMessage());
892
    //  
893
    //}
837 894
      
838
      accessWasSet = 
839
        MNodeService.getInstance(request).setAccessPolicy(session, pid, accessPolicy);
840
      assertTrue(accessWasSet);
841
      // test that it is enforced
842
      session.setSubject(publicSubject);
843
      boolean isAuthorized = MNodeService.getInstance(request).isAuthorized(session, pid, Permission.WRITE);
844
      assertTrue(isAuthorized);
845

  
846
    } catch (UnsupportedEncodingException e) {
847
      e.printStackTrace();
848
      
849
    } catch (InvalidToken e) {
850
      e.printStackTrace();
851
      fail("Unexpected error: " + e.getMessage());
852
      
853
    } catch (ServiceFailure e) {
854
      e.printStackTrace();
855
      fail("Unexpected error: " + e.getMessage());
856
      
857
    } catch (NotAuthorized e) {
858
      e.printStackTrace();
859
      fail("Unexpected error: " + e.getMessage());
860
      
861
    } catch (IdentifierNotUnique e) {
862
      e.printStackTrace();
863
      fail("Unexpected error: " + e.getMessage());
864
      
865
    } catch (UnsupportedType e) {
866
      e.printStackTrace();
867
      fail("Unexpected error: " + e.getMessage());
868
      
869
    } catch (InsufficientResources e) {
870
      e.printStackTrace();
871
      fail("Unexpected error: " + e.getMessage());
872
      
873
    } catch (InvalidSystemMetadata e) {
874
      e.printStackTrace();
875
      fail("Unexpected error: " + e.getMessage());
876
      
877
    } catch (NotImplemented e) {
878
      e.printStackTrace();
879
      fail("Unexpected error: " + e.getMessage());
880
      
881
    } catch (InvalidRequest e) {
882
      e.printStackTrace();
883
      fail("Unexpected error: " + e.getMessage());
884
      
885
    } catch (NotFound e) {
886
      e.printStackTrace();
887
      fail("Unexpected error: " + e.getMessage());
888
      
889
    } catch (Exception e) {
890
      e.printStackTrace();
891
      fail("Unexpected error: " + e.getMessage());
892
      
893
    }
894
      
895 895
  }
896 896

  
897 897
  /**

Also available in: Unified diff