Ejemplo n.º 1
0
static int move(void)
{
    char *src2;

    src = ne_concat(i_path, "move", NULL);
    src2 = ne_concat(i_path, "move2", NULL);
    dest = ne_concat(i_path, "movedest", NULL);
    coll = ne_concat(i_path, "movecoll/", NULL);
    ncoll = ne_concat(i_path, "movecoll", NULL);

    /* Upload it twice. */
    CALL(upload_foo("move"));
    CALL(upload_foo("move2"));
    ONMREQ("MKCOL", coll, ne_mkcol(i_session, coll));

    /* Now move it */
    ONM2REQ("MOVE", src, dest, ne_move(i_session, 0, src, dest));

    if (STATUS(201)) {
	t_warning("MOVE to new resource didn't give 201");
    }

    /* Try a move with Overwrite: F to check that fails. */
    ONM2REQ("MOVE on existing resource with Overwrite: F succeeded",
	    src2, dest, 
	    ne_move(i_session, 0, src2, dest) != NE_ERROR);

    if (STATUS(412)) {
	t_warning("MOVE-on-existing should fail with 412");
    }

    ONM2REQ("MOVE onto existing resource with Overwrite: T",
	    src2, dest,
	    ne_move(i_session, 1, src2, dest));

    ONM2REQ("MOVE overwrites collection", coll, dest,
	    ne_move(i_session, 1, dest, coll));
    
    if (STATUS(204)) {
	t_warning("MOVE to existing collection resource didn't give 204");
    }
		  
    if (ne_delete(i_session, ncoll)) {
	t_warning("Could not clean up `%s'", ncoll);
    }

    return OK;
}
Ejemplo n.º 2
0
static int owncloud_rename(const char *olduri, const char *newuri) {
    char *src = NULL;
    char *target = NULL;
    int rc = NE_OK;


    rc = dav_connect(olduri);
    if (rc < 0) {
        errno = EINVAL;
    }

    src    = _cleanPath( olduri );
    target = _cleanPath( newuri );

    if( rc >= 0 ) {
        DEBUG_WEBDAV("MOVE: %s => %s: %d", src, target, rc );
        rc = ne_move(dav_session.ctx, 1, src, target );

        if (rc != NE_OK ) {
          set_errno_from_session();
        }
    }
    SAFE_FREE( src );
    SAFE_FREE( target );

    if( rc != NE_OK )
        return -1;
    return 0;
}
Ejemplo n.º 3
0
static int notowner_modify(void)
{
    char *tmp;
    ne_propname pname = { "http://webdav.org/neon/litmus/", "random" };
    ne_proppatch_operation pops[] = { 
	{ NULL, ne_propset, "foobar" },
	{ NULL }
    };

    PRECOND(gotlock);

    pops[0].name = &pname;

    ONN("DELETE of locked resource should fail", 
	ne_delete(i_session2, res) != NE_ERROR);

    if (STATUS2(423)) 
	t_warning("DELETE failed with %d not 423", GETSTATUS2);

    tmp = ne_concat(i_path, "whocares", NULL);
    ONN("MOVE of locked resource should fail", 
	ne_move(i_session2, 0, res, tmp) != NE_ERROR);
    free(tmp);
    
    if (STATUS2(423))
	t_warning("MOVE failed with %d not 423", GETSTATUS2);
    
    ONN("COPY onto locked resource should fail",
	ne_copy(i_session2, 1, NE_DEPTH_ZERO, res2, res) != NE_ERROR);

    if (STATUS2(423))
	t_warning("COPY failed with %d not 423", GETSTATUS2);

    ONN("PROPPATCH of locked resource should fail",
	ne_proppatch(i_session2, res, pops) != NE_ERROR);
    
    if (STATUS2(423))
	t_warning("PROPPATCH failed with %d not 423", GETSTATUS2);

    ONN("PUT on locked resource should fail",
	ne_put(i_session2, res, i_foo_fd) != NE_ERROR);

    if (STATUS2(423))
	t_warning("PUT failed with %d not 423", GETSTATUS2);

    return OK;    
}
Ejemplo n.º 4
0
static int move_coll(void)
{
    int n;
    char *rsrc, *rdest, *subsrc, *subdest;
    char res[512];

    msrc = ne_concat(i_path, "mvsrc/", NULL);
    mdest = ne_concat(i_path, "mvdest/", NULL);
    mdest2 = ne_concat(i_path, "mvdest2/", NULL);
    rsrc = ne_concat(i_path, "mvsrc/foo", NULL);
    rdest = ne_concat(i_path, "mvdest/foo", NULL); 
    subsrc = ne_concat(i_path, "mvsrc/subcoll/", NULL);
    subdest = ne_concat(i_path, "mvdest/subcoll/", NULL);
    mnoncoll = ne_concat(i_path, "mvnoncoll", NULL);

    /* Set up the mvsrc collection. */
    ONMREQ("MKCOL", msrc, ne_mkcol(i_session, msrc));
    for (n = 0; n < 10; n++) {
	sprintf(res, "mvsrc/foo.%d", n);
	CALL(upload_foo(res));
    }
    CALL(upload_foo("mvnoncoll"));

    ONV(ne_mkcol(i_session, subsrc),
	("MKCOL of `%s' failed: %s\n", subsrc, SERR));
    
    /* Now make a copy of the collection */
    ONV(ne_copy(i_session, 0, NE_DEPTH_INFINITE, msrc, mdest2),
	("collection COPY `%s' to `%s', depth infinity: %s",
	 msrc, mdest2, SERR));

    ONV(ne_move(i_session, 0, msrc, mdest),
	("collection MOVE `%s' to `%s': %s", msrc, mdest, SERR));

    ONN("MOVE-on-existing-coll should fail",
	ne_move(i_session, 0, mdest, mdest2) != NE_ERROR);
    
    ONN("MOVE-on-existing-coll with overwrite",
	ne_move(i_session, 1, mdest2, mdest));

    /* Take another copy. */
    ONV(ne_copy(i_session, 0, NE_DEPTH_INFINITE, mdest, mdest2),
	("collection COPY `%s' to `%s', depth infinity: %s",
	 mdest, mdest2, ne_get_error(i_session)));

    /* Now delete things out of the destination collection to check if
     * they are there. */
    for (n = 0; n < 10; n++) {
	sprintf(res, "%s%s.%d", i_path, "mvdest/foo", n);
	ONV(ne_delete(i_session, res),
	    ("DELETE from copied collection failed for `%s': %s",
	     res, SERR));
    }

    ONV(ne_delete(i_session, subdest),
	("DELETE from copied collection failed for `%s': %s",
	 subdest, SERR));

    /* And move the spare collection over a non-coll. */
    ONV(ne_move(i_session, 1, mdest2, mnoncoll),
	("MOVE collection `%s' over non-collection `%s' with overwrite: %s",
	 mdest2, mnoncoll, ne_get_error(i_session)));

    return OK;
}
Ejemplo n.º 5
0
static int lock_on_no_file(void)
{
    char *tmp;
    res = ne_concat(i_path, "locknullfile", NULL);
    tmp = ne_concat(i_path, "whocares", NULL);
		
    getlock(ne_lockscope_exclusive, NE_DEPTH_ZERO);
	
	if (STATUS(200)) 
		t_warning("Lock Null failed with %d not 200", GETSTATUS);

    //FIXME: After Lock Null is created, Do Unlock it to maintain integrity of tests
    //ONNREQ2("unlock of second shared lock",ne_unlock(i_session, &gotlock));
    
   
    // Copy of nulllock resource
    ONN("COPY null locked resource should ",
	ne_copy(i_session, 1, NE_DEPTH_ZERO, res, tmp) == NE_ERROR);
     
    // Delete of nulllockresource
    ONN("DELETE of locknull resource by owner", 
	ne_delete(i_session, tmp) == NE_ERROR);
    free(tmp);

    // Move of nulllockresource
    tmp = ne_concat(i_path, "who-cares", NULL);
    ONN("MOVE of null-locked resource", 
	ne_move(i_session, 0, res, tmp) == NE_ERROR);
    ONN("DELETE of locknull resource by owner after a MOVE with overwrite (F)", 
	ne_delete(i_session, tmp) == NE_ERROR);
   
    /* Delete the locktoken from store */ 	
    ne_lockstore_remove(store, gotlock);
    getlock(ne_lockscope_exclusive, NE_DEPTH_ZERO);
	if (STATUS(200)) 
		t_warning("Lock Null failed with %d not 200", GETSTATUS);

     /* Lot of code duplication, but want to test each case individually.
      * Locknull resource. How it behaves when it is copied 
      * moved (with overwrite T/F)
      * PUT request on locknullresource should succeed. 
      */
     

    /*MOVE of null-locked resource with overwrite=T */
    ONN("MOVE of null-locked resource with overwrite=T (1)", 
	ne_move(i_session, 1, res, tmp) == NE_ERROR);
    ne_lockstore_remove(store, gotlock);
    getlock(ne_lockscope_exclusive, NE_DEPTH_ZERO);
	if (STATUS(200)) 
		t_warning("Lock Null failed with %d not 200", GETSTATUS);
    ONN("MOVE of null-locked resource with overwrite=T (2)", 
	ne_move(i_session, 1, res, tmp) == NE_ERROR);
	
    ne_lockstore_remove(store, gotlock);
    getlock(ne_lockscope_shared, NE_DEPTH_ZERO);
	if (STATUS(200)) 
		t_warning("Lock Null failed with %d not 200", GETSTATUS);
    
    ONN("COPY on null-locked resource with overwrite=T", 
	ne_copy(i_session, 1, NE_DEPTH_ZERO, tmp, res) == NE_ERROR);

   ONN("DELETE of locknull resource by owner after a MOVE (T) ", 
	ne_delete(i_session, tmp) == NE_ERROR);
    free(tmp);

    // Put on nulllockresource
    ONV(ne_put(i_session,res, i_foo_fd),
	 ("PUT on locknullfile resource failed: %s", ne_get_error(i_session)));
	
	return OK;
}