00001
00002
00003
00004
00005
00006
00007 #include "rodsClient.h"
00008 #include "parseCommandLine.h"
00009 #include "readServerConfig.h"
00010
00011 #include "rodsUser.h"
00012
00013 #include "icatHighLevelRoutines.h"
00014 #include "icatMidLevelRoutines.h"
00015
00016 #include <string.h>
00017
00018 extern icatSessionStruct *chlGetRcs();
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 rodsEnv myEnv;
00029
00030 int testRegUser(rsComm_t *rsComm, char *name,
00031 char *zone, char *userType, char *dn) {
00032 userInfo_t userInfo;
00033
00034 strncpy(userInfo.userName, name, sizeof userInfo.userName);
00035 strncpy(userInfo.rodsZone, zone, sizeof userInfo.rodsZone);
00036 strncpy(userInfo.userType, userType, sizeof userInfo.userType);
00037 strncpy(userInfo.authInfo.authStr, dn, sizeof userInfo.authInfo.authStr);
00038
00039
00040 return(0);
00041 }
00042
00043 int testRegRule(rsComm_t *rsComm, char *name) {
00044 ruleExecSubmitInp_t ruleInfo;
00045
00046 memset(&ruleInfo,0,sizeof(ruleInfo));
00047
00048 strncpy(ruleInfo.ruleName, name, sizeof ruleInfo.ruleName);
00049
00050 strncpy(ruleInfo.reiFilePath,"../config/packedRei/rei.file1",
00051 sizeof ruleInfo.reiFilePath);
00052 strncpy(ruleInfo.userName,"Wayne", sizeof ruleInfo.userName);
00053 strncpy(ruleInfo.exeAddress, "Bermuda", sizeof ruleInfo.exeAddress);
00054 strncpy(ruleInfo.exeTime,"whenEver", sizeof ruleInfo.exeTime);
00055 strncpy(ruleInfo.exeFrequency,"every 2 days", sizeof ruleInfo.exeFrequency);
00056 strncpy(ruleInfo.priority,"high", sizeof ruleInfo.priority);
00057 strncpy(ruleInfo.estimateExeTime,"2 hours", sizeof ruleInfo.estimateExeTime);
00058 strncpy(ruleInfo.notificationAddr,"noone@nowhere.com",
00059 sizeof ruleInfo.notificationAddr);
00060 return(chlRegRuleExec(rsComm, &ruleInfo));
00061 }
00062
00063 int testRename(rsComm_t *rsComm, char *id, char *newName) {
00064 rodsLong_t intId;
00065 int status;
00066 rsComm->clientUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00067 rsComm->proxyUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00068 intId = strtoll(id, 0, 0);
00069 status = chlRenameObject(rsComm, intId, newName);
00070 if (status) return(status);
00071 return(chlCommit(rsComm));
00072 }
00073
00074 int testLogin(rsComm_t *rsComm, char *User, char *pw, char *pw1) {
00075 int status, stat2;
00076 rcComm_t *Conn;
00077 rErrMsg_t errMsg;
00078
00079 Conn = rcConnect (myEnv.rodsHost, myEnv.rodsPort, myEnv.rodsUserName,
00080 myEnv.rodsZone, 0, &errMsg);
00081 if (Conn == NULL) {
00082 printf("rcConnect failure");
00083 return -1;
00084 }
00085
00086 #if 0
00087 Conn->clientUser.authInfo.authFlag = 0;
00088 Conn->proxyUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00089 rstrcpy (Conn->clientUser.userName, privUser, NAME_LEN);
00090 #endif
00091
00092 status = clientLoginWithPassword(Conn, pw1);
00093 if (status ==0) {
00094 rstrcpy (Conn->clientUser.userName, User,
00095 sizeof Conn->clientUser.userName);
00096 rstrcpy (Conn->clientUser.rodsZone, myEnv.rodsZone,
00097 sizeof Conn->clientUser.rodsZone);
00098 status = clientLoginWithPassword(Conn, pw);
00099 }
00100
00101 stat2 = rcDisconnect(Conn);
00102
00103 return(status);
00104 }
00105
00106 int testMove(rsComm_t *rsComm, char *id, char *destId) {
00107 rodsLong_t intId, intDestId;
00108 int status;
00109 rsComm->clientUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00110 rsComm->proxyUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00111 intId = strtoll(id, 0, 0);
00112 intDestId = strtoll(destId, 0, 0);
00113 status = chlMoveObject(rsComm, intId, intDestId);
00114 if (status) return(status);
00115 return(chlCommit(rsComm));
00116 }
00117
00118 int testTempPw(rsComm_t *rsComm) {
00119 int status;
00120 char pwValueToHash[500];
00121 status = chlMakeTempPw(rsComm, pwValueToHash);
00122 printf("pwValueToHash: %s\n", pwValueToHash);
00123
00124 return(status);
00125 }
00126
00127 int testTempPwConvert(char *s1, char *s2) {
00128 char md5Buf[100];
00129 unsigned char digest[RESPONSE_LEN+2];
00130 char digestStr[100];
00131 MD5_CTX context;
00132
00133
00134
00135
00136
00137
00138 memset(md5Buf, 0, sizeof(md5Buf));
00139 strncpy(md5Buf, s2, sizeof md5Buf);
00140 strncat(md5Buf, s1, sizeof md5Buf);
00141
00142 MD5Init (&context);
00143 MD5Update (&context, (unsigned char*)md5Buf, sizeof md5Buf);
00144 MD5Final (digest, &context);
00145
00146 md5ToStr(digest, digestStr);
00147 printf("digestStr (derived temp pw)=%s\n", digestStr);
00148
00149 return(0);
00150 }
00151
00152
00153 int testTempPwCombined(rsComm_t *rsComm, char *s1) {
00154 int status;
00155 char pwValueToHash[500];
00156 char md5Buf[100];
00157 unsigned char digest[RESPONSE_LEN+2];
00158 char digestStr[100];
00159 MD5_CTX context;
00160
00161 status = chlMakeTempPw(rsComm, pwValueToHash);
00162 if (status) return(status);
00163
00164 printf("pwValueToHash: %s\n", pwValueToHash);
00165
00166
00167
00168
00169
00170
00171 memset(md5Buf, 0, sizeof(md5Buf));
00172 strncpy(md5Buf, pwValueToHash, sizeof md5Buf);
00173 strncat(md5Buf, s1, sizeof md5Buf);
00174
00175 MD5Init (&context);
00176 MD5Update (&context, (unsigned char*)md5Buf, sizeof md5Buf);
00177 MD5Final (digest, &context);
00178
00179 md5ToStr(digest, digestStr);
00180 printf("digestStr (derived temp pw)=%s\n", digestStr);
00181
00182 return(0);
00183 }
00184 int testCheckAuth(rsComm_t *rsComm, char *testAdminUser, char *testUser,
00185 char *testUserZone) {
00186
00187
00188 char response[RESPONSE_LEN+2];
00189 char challenge[CHALLENGE_LEN+2];
00190 int userPrivLevel;
00191 int clientPrivLevel;
00192 int status, i;
00193 char userNameAndZone[NAME_LEN*2];
00194
00195 strncpy(rsComm->clientUser.userName, testUser,
00196 sizeof rsComm->clientUser.userName);
00197 strncpy(rsComm->clientUser.rodsZone, testUserZone,
00198 sizeof rsComm->clientUser.rodsZone);
00199
00200 for (i=0;i<CHALLENGE_LEN+2;i++) challenge[i]=' ';
00201
00202 i=0;
00203 response[i++]=0xd6;
00204 response[i++]=0x8a;
00205 response[i++]=0xaf;
00206 response[i++]=0xc4;
00207 response[i++]=0x83;
00208 response[i++]=0x46;
00209 response[i++]=0x1b;
00210 response[i++]=0xa2;
00211 response[i++]=0x5c;
00212 response[i++]=0x8c;
00213 response[i++]=0x6d;
00214 response[i++]=0xc5;
00215 response[i++]=0xb1;
00216 response[i++]=0x41;
00217 response[i++]=0x84;
00218 response[i++]=0xeb;
00219 response[i++]=0x00;
00220
00221 strncpy(userNameAndZone, testAdminUser, sizeof userNameAndZone);
00222 userNameAndZone[ sizeof( userNameAndZone ) - 1 ] = '\0';
00223 strncat(userNameAndZone, "#", sizeof userNameAndZone);
00224 strncat(userNameAndZone, testUserZone, sizeof userNameAndZone);
00225
00226 status = chlCheckAuth(rsComm, challenge, response,
00227 userNameAndZone,
00228 &userPrivLevel, &clientPrivLevel);
00229
00230 if (status == 0) {
00231 printf("clientPrivLevel=%d\n",clientPrivLevel);
00232 }
00233 return(status);
00234
00235 }
00236
00237 int testDelUser(rsComm_t *rsComm, char *name, char *zone) {
00238 userInfo_t userInfo;
00239
00240 strncpy(userInfo.userName, name, sizeof userInfo.userName);
00241 strncpy(userInfo.rodsZone, zone, sizeof userInfo.rodsZone);
00242
00243
00244 return(0);
00245 }
00246
00247 int testDelFile(rsComm_t *rsComm, char *name, char *replica) {
00248 dataObjInfo_t dataObjInfo;
00249 keyValPair_t *condInput;
00250
00251 memset(&dataObjInfo, 0, sizeof(dataObjInfo));
00252 if (replica != NULL && *replica != 0) {
00253 int ireplica;
00254 ireplica = atoi(replica);
00255 if (ireplica >= 0) {
00256 dataObjInfo.replNum = ireplica;
00257 }
00258 if (ireplica == 999999) {
00259 dataObjInfo.replNum = -1;
00260 }
00261 }
00262 strncpy(dataObjInfo.objPath, name, sizeof dataObjInfo.objPath);
00263
00264 memset (&condInput, 0, sizeof (condInput));
00265
00266 return(chlUnregDataObj(rsComm, &dataObjInfo, condInput));
00267 }
00268
00269 int testDelFilePriv(rsComm_t *rsComm, char *name, char *dataId,
00270 char *replica) {
00271 dataObjInfo_t dataObjInfo;
00272 keyValPair_t condInput;
00273
00274 rsComm->clientUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00275 memset (&condInput, 0, sizeof (condInput));
00276 addKeyVal(&condInput, IRODS_ADMIN_KW, " ");
00277
00278 memset(&dataObjInfo, 0, sizeof(dataObjInfo));
00279
00280 if (dataId != NULL && *dataId != 0) {
00281 rodsLong_t idataId;
00282 idataId = strtoll(dataId, NULL, 0);
00283 if (idataId >= 0) {
00284 dataObjInfo.dataId = idataId;
00285 }
00286 }
00287 dataObjInfo.replNum = -1;
00288 if (replica != NULL && *replica != 0) {
00289 int ireplica;
00290 ireplica = atoi(replica);
00291 if (ireplica >= 0) {
00292 dataObjInfo.replNum = ireplica;
00293 }
00294 }
00295 strncpy(dataObjInfo.objPath, name, sizeof dataObjInfo.objPath);
00296
00297 return(chlUnregDataObj(rsComm, &dataObjInfo, &condInput));
00298 }
00299
00300 int testDelFileTrash(rsComm_t *rsComm, char *name, char *dataId) {
00301 dataObjInfo_t dataObjInfo;
00302 keyValPair_t condInput;
00303
00304 char *replica=0;
00305
00306 rsComm->clientUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00307 memset (&condInput, 0, sizeof (condInput));
00308 addKeyVal(&condInput, IRODS_ADMIN_RMTRASH_KW, " ");
00309
00310 memset(&dataObjInfo, 0, sizeof(dataObjInfo));
00311
00312 if (dataId != NULL && *dataId != 0) {
00313 rodsLong_t idataId;
00314 idataId = strtoll(dataId, NULL, 0);
00315 if (idataId >= 0) {
00316 dataObjInfo.dataId = idataId;
00317 }
00318 }
00319 dataObjInfo.replNum = -1;
00320 if (replica != NULL && *replica != 0) {
00321 int ireplica;
00322 ireplica = atoi(replica);
00323 if (ireplica >= 0) {
00324 dataObjInfo.replNum = ireplica;
00325 }
00326 }
00327 strncpy(dataObjInfo.objPath, name, sizeof dataObjInfo.objPath);
00328
00329 return(chlUnregDataObj(rsComm, &dataObjInfo, &condInput));
00330 }
00331
00332 int testRegColl(rsComm_t *rsComm, char *name) {
00333
00334 collInfo_t collInp;
00335
00336 strncpy(collInp.collName, name, sizeof collInp.collName);
00337
00338 return(chlRegColl(rsComm, &collInp));
00339 }
00340
00341 int testDelColl(rsComm_t *rsComm, char *name) {
00342
00343 collInfo_t collInp;
00344
00345 strncpy(collInp.collName, name, sizeof collInp.collName);
00346
00347 return(chlDelColl(rsComm, &collInp));
00348 }
00349
00350 int testDelRule(rsComm_t *rsComm, char *ruleName, char *userName) {
00351 if (userName!=NULL && strlen(userName)>0) {
00352 rsComm->clientUser.authInfo.authFlag = LOCAL_USER_AUTH;
00353 rsComm->proxyUser.authInfo.authFlag = LOCAL_USER_AUTH;
00354 strncpy(rsComm->clientUser.userName, userName,
00355 sizeof rsComm->clientUser.userName);
00356 }
00357 else {
00358 rsComm->clientUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00359 rsComm->proxyUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00360 }
00361 return(chlDelRuleExec(rsComm, ruleName));
00362 }
00363
00364 int testRegDataObj(rsComm_t *rsComm, char *name,
00365 char *dataType, char *filePath) {
00366 dataObjInfo_t dataObjInfo;
00367 memset(&dataObjInfo,0,sizeof(dataObjInfo_t));
00368
00369 strcpy(dataObjInfo.objPath, name);
00370 dataObjInfo.replNum=1;
00371 strcpy(dataObjInfo.version, "12");
00372 strcpy(dataObjInfo.dataType, dataType);
00373 dataObjInfo.dataSize=42;
00374
00375 strcpy(dataObjInfo.rescName, "demoResc");
00376 strcpy(dataObjInfo.filePath, filePath);
00377
00378 dataObjInfo.replStatus=5;
00379
00380 return (chlRegDataObj(rsComm, &dataObjInfo));
00381 }
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400 int testRegDataMulti(rsComm_t *rsComm, char *count,
00401 char *nameBase, char *dataType, char *filePath) {
00402 int status;
00403 int myCount=100;
00404 int i;
00405 char myName[MAX_NAME_LEN];
00406
00407 myCount = atoi(count);
00408 if (myCount <=0) {
00409 printf("Invalid input: count\n");
00410 return(USER_INPUT_OPTION_ERR);
00411 }
00412
00413 for (i=0;i<myCount;i++) {
00414 snprintf (myName, sizeof myName, "%s.%d", nameBase, i);
00415 status = testRegDataObj(rsComm, myName, dataType, filePath);
00416 if (status) return(status);
00417 }
00418
00419 status = chlCommit(rsComm);
00420 return(status);
00421 }
00422
00423 int testModDataObjMeta(rsComm_t *rsComm, char *name,
00424 char *dataType, char *filePath) {
00425 dataObjInfo_t dataObjInfo;
00426 int status;
00427 keyValPair_t regParam;
00428 char tmpStr[LONG_NAME_LEN], tmpStr2[LONG_NAME_LEN];
00429
00430
00431 memset(&dataObjInfo,0,sizeof(dataObjInfo_t));
00432
00433 memset (®Param, 0, sizeof (regParam));
00434
00435
00436
00437
00438
00439
00440 snprintf (tmpStr, sizeof tmpStr, "'now'");
00441 addKeyVal (®Param, "dataCreate", tmpStr);
00442
00443 snprintf (tmpStr2, sizeof tmpStr2, "'test comment'");
00444 addKeyVal (®Param, "dataComments", tmpStr2);
00445
00446 strcpy(dataObjInfo.objPath, name);
00447
00448 dataObjInfo.replNum=0;
00449
00450 strcpy(dataObjInfo.version, "12");
00451 strcpy(dataObjInfo.dataType, dataType);
00452 dataObjInfo.dataSize=42;
00453
00454 strcpy(dataObjInfo.rescName, "resc A");
00455
00456 strcpy(dataObjInfo.filePath, filePath);
00457
00458 dataObjInfo.replStatus=5;
00459
00460 status = chlModDataObjMeta(rsComm, &dataObjInfo, ®Param);
00461
00462
00463 return(status);
00464 }
00465
00466 int testModDataObjMeta2(rsComm_t *rsComm, char *name,
00467 char *dataType, char *filePath) {
00468 dataObjInfo_t dataObjInfo;
00469 int status;
00470 keyValPair_t regParam;
00471 char tmpStr[LONG_NAME_LEN], tmpStr2[LONG_NAME_LEN];
00472
00473 memset(&dataObjInfo,0,sizeof(dataObjInfo_t));
00474
00475 memset (®Param, 0, sizeof (regParam));
00476
00477 snprintf (tmpStr, sizeof tmpStr, "whatever");
00478 addKeyVal (®Param, "all", tmpStr);
00479
00480 snprintf (tmpStr2, sizeof tmpStr2, "42");
00481 addKeyVal (®Param, "dataSize", tmpStr2);
00482
00483 strcpy(dataObjInfo.objPath, name);
00484 dataObjInfo.replNum=0;
00485 strcpy(dataObjInfo.version, "12");
00486 strcpy(dataObjInfo.dataType, dataType);
00487 dataObjInfo.dataSize=42;
00488
00489 strcpy(dataObjInfo.rescName, "resc A");
00490
00491 strcpy(dataObjInfo.filePath, filePath);
00492
00493 dataObjInfo.replStatus=5;
00494
00495 status = chlModDataObjMeta(rsComm, &dataObjInfo, ®Param);
00496
00497
00498 return(status);
00499 }
00500
00501 int testModColl(rsComm_t *rsComm, char *name, char *type,
00502 char *info1, char *info2) {
00503 int status;
00504 collInfo_t collInp;
00505
00506 rsComm->clientUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00507 rsComm->proxyUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00508
00509 memset(&collInp,0,sizeof(collInp));
00510
00511 if (name!=NULL && strlen(name)>0) {
00512 strncpy(collInp.collName, name, sizeof collInp.collName);
00513 }
00514 if (type!=NULL && strlen(type)>0) {
00515 strncpy(collInp.collType, type, sizeof collInp.collType);
00516 }
00517 if (info1!=NULL && strlen(info1)>0) {
00518 strncpy(collInp.collInfo1, info1, sizeof collInp.collInfo1);
00519 }
00520 if (info2!=NULL && strlen(info2)>0) {
00521 strncpy(collInp.collInfo2, info2, sizeof collInp.collInfo2);
00522 }
00523
00524 status = chlModColl(rsComm, &collInp);
00525
00526 if (status != 0) return(status);
00527
00528 status = chlCommit(rsComm);
00529 return(status);
00530 }
00531
00532 int testModRuleMeta(rsComm_t *rsComm, char *id,
00533 char *attrName, char *attrValue) {
00534
00535 char ruleId[100];
00536 int status;
00537 keyValPair_t regParam;
00538 char tmpStr[LONG_NAME_LEN];
00539
00540
00541
00542 memset (®Param, 0, sizeof (regParam));
00543
00544 rstrcpy (tmpStr, attrValue, sizeof tmpStr);
00545
00546 addKeyVal (®Param, attrName, tmpStr);
00547
00548 strcpy(ruleId, id);
00549
00550 status = chlModRuleExec(rsComm, ruleId, ®Param);
00551
00552 return(status);
00553 }
00554
00555 int testModResourceFreeSpace(rsComm_t *rsComm, char *rescName,
00556 char *numberString, char *option) {
00557 int number, status;
00558 if (*numberString=='\\') numberString++;
00559 number = atoi(numberString);
00560 rsComm->clientUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00561 rsComm->proxyUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00562 status = chlModRescFreeSpace(rsComm, rescName, number);
00563 if (status != 0) return(status);
00564 if (option != NULL && strcmp(option, "rollback")==0 ) {
00565 status = chlRollback(rsComm);
00566 }
00567 if (option != NULL && strcmp(option, "close")==0 ) {
00568 status = chlClose();
00569 return(status);
00570 }
00571 status = chlCommit(rsComm);
00572 return(status);
00573 }
00574
00575 int testRegReplica(rsComm_t *rsComm, char *srcPath, char *srcDataId,
00576 char *srcReplNum, char *dstPath) {
00577 dataObjInfo_t srcDataObjInfo;
00578 dataObjInfo_t dstDataObjInfo;
00579 keyValPair_t condInput;
00580 int status;
00581
00582 memset(&srcDataObjInfo,0,sizeof(dataObjInfo_t));
00583 memset(&dstDataObjInfo,0,sizeof(dataObjInfo_t));
00584 memset(&condInput,0,sizeof(condInput));
00585
00586 strcpy(srcDataObjInfo.objPath, srcPath);
00587 srcDataObjInfo.dataId=atoi(srcDataId);
00588 srcDataObjInfo.replNum=atoi(srcReplNum);
00589
00590
00591 strcpy(dstDataObjInfo.rescName, "resc A");
00592 strcpy(dstDataObjInfo.rescGroupName, "resc A");
00593 strcpy(dstDataObjInfo.filePath, dstPath);
00594
00595 dstDataObjInfo.replStatus=5;
00596
00597 status = chlRegReplica(rsComm, &srcDataObjInfo, &dstDataObjInfo,
00598 &condInput);
00599 return(status);
00600 }
00601
00602 int testSimpleQ(rsComm_t *rsComm, char *sql, char *arg1, char *format) {
00603 char bigBuf[1000];
00604 int status;
00605 int control;
00606 int form;
00607
00608 rsComm->clientUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00609 rsComm->proxyUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00610
00611 control=0;
00612 form = 1;
00613 if (format != NULL) form = atoi(format);
00614
00615 status = chlSimpleQuery(rsComm, sql, arg1, 0, 0, 0,
00616 form, &control, bigBuf, 1000);
00617 if (status==0) printf("%s",bigBuf);
00618
00619 while (control && (status==0) ) {
00620 status = chlSimpleQuery(rsComm, sql, 0, 0, 0, 0,
00621 form, &control, bigBuf, 1000);
00622 if (status==0) printf("%s",bigBuf);
00623 }
00624 return(status);
00625 }
00626
00627 int testChmod(rsComm_t *rsComm, char *user, char *zone,
00628 char *access, char *path) {
00629 int status;
00630 status = chlModAccessControl(rsComm, 0, user, zone, access, path);
00631
00632 return(status);
00633 }
00634
00635 int testServerLoad(rsComm_t *rsComm, char *option) {
00636 int status;
00637
00638 rsComm->clientUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00639
00640 status = chlRegServerLoad(rsComm, "host", "resc", option, "2", "3",
00641 "4", "5", "6", "7");
00642 return(status);
00643 }
00644
00645 int testPurgeServerLoad(rsComm_t *rsComm, char *option) {
00646 int status;
00647
00648 rsComm->clientUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00649
00650 if (option == NULL) {
00651 status = chlPurgeServerLoad(rsComm, "2000");
00652 }
00653 else {
00654 status = chlPurgeServerLoad(rsComm, option);
00655 }
00656
00657 return(status);
00658 }
00659
00660 int testServerLoadDigest(rsComm_t *rsComm, char *option) {
00661 int status;
00662
00663 rsComm->clientUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00664
00665 status = chlRegServerLoadDigest(rsComm, "resc", option);
00666 return(status);
00667 }
00668
00669 int testPurgeServerLoadDigest(rsComm_t *rsComm, char *option) {
00670 int status;
00671
00672 rsComm->clientUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00673
00674 if (option == NULL) {
00675 status = chlPurgeServerLoadDigest(rsComm, "2000");
00676 }
00677 else {
00678 status = chlPurgeServerLoadDigest(rsComm, option);
00679 }
00680
00681 return(status);
00682 }
00683
00684 int testCheckQuota(rsComm_t *rsComm, char *userName, char *rescName,
00685 char *expectedQuota, char *expectedStatus) {
00686 int status;
00687 int quotaStatus;
00688 rodsLong_t userQuota;
00689
00690 rsComm->clientUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00691
00692 status = chlCheckQuota(rsComm, userName, rescName,
00693 &userQuota, "aStatus);
00694
00695 rodsLog (LOG_SQL,
00696 "chlCheckQuota status: userName:%s rescName:%s userQuota:%lld quotaStatus:%d\n",
00697 userName, rescName, userQuota, quotaStatus);
00698
00699 if (status==0) {
00700 int iExpectedStatus;
00701 rodsLong_t iExpectedQuota;
00702 if (expectedQuota != NULL && strlen(expectedQuota)>0 ) {
00703 rodsLong_t i;
00704 iExpectedQuota = atoll(expectedQuota);
00705 if (expectedQuota[0]=='m') {
00706 i = atoll((char *)&expectedQuota[1]);
00707 iExpectedQuota = -i;
00708 }
00709 if (iExpectedQuota != userQuota) status = -1;
00710 }
00711 if (expectedStatus != NULL && strlen(expectedStatus)>0 ) {
00712 iExpectedStatus = atoi(expectedStatus);
00713 if (iExpectedStatus != quotaStatus) status = -2;
00714 }
00715 }
00716 return(status);
00717 }
00718
00719 rodsLong_t
00720 testCurrent(rsComm_t *rsComm) {
00721 rodsLong_t status;
00722 icatSessionStruct *icss;
00723
00724 icss = chlGetRcs();
00725
00726 status = cmlGetCurrentSeqVal(icss);
00727 return(status);
00728 }
00729
00730 int
00731 testAddRule(rsComm_t *rsComm, char *baseName, char *ruleName,
00732 char *ruleHead, char *ruleCondition, char *ruleAction,
00733 char *ruleRecovery) {
00734 int status;
00735 char ruleIdStr[200];
00736 char myTime[]="01277237323";
00737 char priority[] ="1";
00738 rsComm->clientUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00739
00740 status = chlInsRuleTable(rsComm, baseName, priority, ruleName,
00741 ruleHead, ruleCondition, ruleAction,
00742 ruleRecovery, (char *)&ruleIdStr, (char *)&myTime);
00743
00744 if (status == 0) {
00745 printf("ruleIdStr: %s\n",ruleIdStr);
00746 }
00747 return(status);
00748 }
00749
00750 int
00751 testVersionRuleBase(rsComm_t *rsComm, char *baseName) {
00752 int status;
00753 char myTime[]="01277237323";
00754 rsComm->clientUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00755
00756 status = chlVersionRuleBase(rsComm, baseName, (char *)&myTime);
00757
00758 return(status);
00759 }
00760
00761 int
00762 testVersionDvmBase(rsComm_t *rsComm, char *baseName) {
00763 int status;
00764 char myTime[]="01277237323";
00765 rsComm->clientUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00766
00767 status = chlVersionDvmBase(rsComm, baseName, (char *)&myTime);
00768
00769 return(status);
00770 }
00771
00772 int
00773 testInsFnmTable(rsComm_t *rsComm, char *arg1, char *arg2, char *arg3,
00774 char *arg4) {
00775 int status;
00776 rsComm->clientUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00777
00778 status = chlInsFnmTable(rsComm, arg1, arg2, arg3, arg4);
00779
00780 return(status);
00781 }
00782
00783 int
00784 testInsMsrvcTable(rsComm_t *rsComm, char *arg1, char *arg2, char *arg3,
00785 char *arg4, char *arg5, char *arg6, char *arg7, char *arg8,
00786 char *arg9) {
00787 int status;
00788 rsComm->clientUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00789
00790 status = chlInsMsrvcTable(rsComm, arg1, arg2, arg3, arg4,
00791 arg5, arg6, arg7, arg8, arg9,"0");
00792
00793 return(status);
00794 }
00795
00796 int
00797 testInsDvmTable(rsComm_t *rsComm, char *arg1, char *arg2, char *arg3,
00798 char *arg4) {
00799 int status;
00800 char myTime[]="01277237323";
00801 rsComm->clientUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00802
00803 status = chlInsDvmTable(rsComm, arg1, arg2, arg3, arg4, myTime);
00804 return(status);
00805 }
00806
00807 int
00808 testVersionFnmBase(rsComm_t *rsComm, char *arg1) {
00809 int status;
00810 char myTime[]="01277237323";
00811 rsComm->clientUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
00812
00813 status = chlVersionFnmBase(rsComm, arg1, myTime);
00814
00815 return(status);
00816 }
00817
00818
00819 int
00820 main(int argc, char **argv) {
00821 int status;
00822 rsComm_t *Comm;
00823
00824 rodsArguments_t myRodsArgs;
00825 char *mySubName;
00826 char *myName;
00827 int didOne;
00828 rodsServerConfig_t serverConfig;
00829
00830 Comm = (rsComm_t*)malloc (sizeof (rsComm_t));
00831 memset (Comm, 0, sizeof (rsComm_t));
00832
00833 parseCmdLineOpt(argc, argv, "", 0, &myRodsArgs);
00834
00835 rodsLogLevel(LOG_NOTICE);
00836
00837 rodsLogSqlReq(1);
00838
00839 if (argc < 2) {
00840 printf("Usage: test_chl testName [args...]\n");
00841 exit(3);
00842 }
00843
00844 status = getRodsEnv (&myEnv);
00845 if (status < 0) {
00846 rodsLog (LOG_ERROR, "main: getRodsEnv error. status = %d",
00847 status);
00848 exit (1);
00849 }
00850
00851 if (strstr(myEnv.rodsDebug, "CAT") != NULL) {
00852 chlDebug(myEnv.rodsDebug);
00853 }
00854
00855 memset(&serverConfig, 0, sizeof(serverConfig));
00856 status = readServerConfig(&serverConfig);
00857
00858 strncpy(Comm->clientUser.userName, myEnv.rodsUserName,
00859 sizeof Comm->clientUser.userName);
00860
00861 strncpy(Comm->clientUser.rodsZone, myEnv.rodsZone,
00862 sizeof Comm->clientUser.rodsZone);
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872 if ((status = chlOpen(serverConfig.DBUsername,
00873 serverConfig.DBPassword)) != 0) {
00874 rodsLog (LOG_SYS_FATAL,
00875 "initInfoWithRcat: chlopen Error. Status = %d",
00876 status);
00877 free( Comm );
00878 return (status);
00879 }
00880
00881 didOne=0;
00882 if (strcmp(argv[1],"reg")==0) {
00883 status = testRegDataObj(Comm, argv[2], argv[3], argv[4]);
00884 didOne=1;
00885 }
00886 if (strcmp(argv[1],"regmulti")==0) {
00887 status = testRegDataMulti(Comm, argv[2], argv[3], argv[4], argv[5]);
00888 didOne=1;
00889 }
00890
00891 if (strcmp(argv[1],"mod")==0) {
00892 status = testModDataObjMeta(Comm, argv[2], argv[3], argv[4]);
00893 didOne=1;
00894 }
00895
00896 if (strcmp(argv[1],"mod2")==0) {
00897 status = testModDataObjMeta2(Comm, argv[2], argv[3], argv[4]);
00898 didOne=1;
00899 }
00900
00901 if (strcmp(argv[1],"modr")==0) {
00902 status = testModRuleMeta(Comm, argv[2], argv[3], argv[4]);
00903 didOne=1;
00904 }
00905
00906 if (strcmp(argv[1],"modc")==0) {
00907 status = testModColl(Comm, argv[2], argv[3], argv[4], argv[5]);
00908 didOne=1;
00909 }
00910
00911 if (strcmp(argv[1],"rmrule")==0) {
00912 status = testDelRule(Comm, argv[2], argv[3]);
00913 didOne=1;
00914 }
00915
00916 if (strcmp(argv[1],"modrfs")==0) {
00917 status = testModResourceFreeSpace(Comm, argv[2], argv[3], argv[4]);
00918 didOne=1;
00919 }
00920
00921 if (strcmp(argv[1],"rep")==0) {
00922 if (argc < 6) {
00923 printf("too few arguments\n");
00924 exit(1);
00925 }
00926 status = testRegReplica(Comm, argv[2], argv[3], argv[4], argv[5]);
00927 didOne=1;
00928 }
00929
00930
00931
00932
00933
00934
00935
00936
00937 if (strcmp(argv[1],"rmuser")==0) {
00938 status = testDelUser(Comm, argv[2], argv[3]);
00939 didOne=1;
00940 }
00941
00942 if (strcmp(argv[1],"mkdir")==0) {
00943 status = testRegColl(Comm, argv[2]);
00944 didOne=1;
00945 }
00946
00947 if (strcmp(argv[1],"rmdir")==0) {
00948 status = testDelColl(Comm, argv[2]);
00949 didOne=1;
00950 }
00951
00952 if (strcmp(argv[1],"sql")==0) {
00953 status = testSimpleQ(Comm, argv[2], argv[3], argv[4]);
00954 didOne=1;
00955 }
00956
00957 if (strcmp(argv[1],"rm")==0) {
00958 status = testDelFile(Comm, argv[2], argv[3]);
00959 didOne=1;
00960 }
00961
00962 if (strcmp(argv[1],"rmtrash")==0) {
00963 status = testDelFileTrash(Comm, argv[2], argv[3]);
00964 didOne=1;
00965 }
00966
00967 if (strcmp(argv[1],"rmpriv")==0) {
00968 status = testDelFilePriv(Comm, argv[2], argv[3], argv[4]);
00969 didOne=1;
00970 }
00971
00972 if (strcmp(argv[1],"chmod")==0) {
00973 status = testChmod(Comm, argv[2], argv[3], argv[4], argv[5]);
00974 didOne=1;
00975 }
00976
00977 if (strcmp(argv[1],"regrule")==0) {
00978 status = testRegRule(Comm, argv[2]);
00979 didOne=1;
00980 }
00981
00982 if (strcmp(argv[1],"rename")==0) {
00983 status = testRename(Comm, argv[2], argv[3]);
00984 testCurrent(Comm);
00985
00986 didOne=1;
00987 }
00988
00989 if (strcmp(argv[1],"login")==0) {
00990 status = testLogin(Comm, argv[2], argv[3], argv[4]);
00991 didOne=1;
00992 }
00993
00994 if (strcmp(argv[1],"move")==0) {
00995 status = testMove(Comm, argv[2], argv[3]);
00996 didOne=1;
00997 }
00998
00999 if (strcmp(argv[1],"checkauth")==0) {
01000 status = testCheckAuth(Comm, argv[2], argv[3], argv[4]);
01001 didOne=1;
01002 }
01003
01004 if (strcmp(argv[1],"temppw")==0) {
01005 status = testTempPw(Comm);
01006 didOne=1;
01007 }
01008
01009 if (strcmp(argv[1],"tpc")==0) {
01010 status = testTempPwConvert(argv[2], argv[3]);
01011 didOne=1;
01012 }
01013
01014 if (strcmp(argv[1],"tpw")==0) {
01015 status = testTempPwCombined(Comm, argv[2]);
01016 didOne=1;
01017 }
01018
01019 if (strcmp(argv[1],"serverload")==0) {
01020 status = testServerLoad(Comm, argv[2]);
01021 didOne=1;
01022 }
01023
01024 if (strcmp(argv[1],"purgeload")==0) {
01025 status = testPurgeServerLoad(Comm, argv[2]);
01026 didOne=1;
01027 }
01028
01029 if (strcmp(argv[1],"serverdigest")==0) {
01030 status = testServerLoadDigest(Comm, argv[2]);
01031 didOne=1;
01032 }
01033
01034 if (strcmp(argv[1],"purgedigest")==0) {
01035 status = testPurgeServerLoadDigest(Comm, argv[2]);
01036 didOne=1;
01037 }
01038
01039 if (strcmp(argv[1],"checkquota")==0) {
01040 if (argc < 5) {
01041 status = testCheckQuota(Comm, argv[2], argv[3],
01042 NULL, NULL);
01043 }
01044 else {
01045 status = testCheckQuota(Comm, argv[2], argv[3],
01046 argv[4], argv[5]);
01047 }
01048 didOne=1;
01049 }
01050
01051 if (strcmp(argv[1],"open")==0) {
01052 int i;
01053 for (i=0;i<3;i++) {
01054 status = chlClose();
01055 if (status) {
01056 printf ("close %d error", i);
01057 }
01058
01059 if ((status = chlOpen(serverConfig.DBUsername,
01060 serverConfig.DBPassword)) != 0) {
01061 rodsLog (LOG_SYS_FATAL,
01062 "initInfoWithRcat: chlopen %d Error. Status = %d",
01063 i, status);
01064 return (status);
01065 }
01066 }
01067 didOne=1;
01068 }
01069
01070 if (strcmp(argv[1],"addrule")==0) {
01071 status = testAddRule(Comm, argv[2], argv[3],
01072 argv[4], argv[5],
01073 argv[6], argv[7]);
01074 didOne=1;
01075 }
01076
01077 if (strcmp(argv[1],"versionrulebase")==0) {
01078 status = testVersionRuleBase(Comm, argv[2]);
01079 didOne=1;
01080 }
01081
01082 if (strcmp(argv[1],"versiondvmbase")==0) {
01083 status = testVersionDvmBase(Comm, argv[2]);
01084 didOne=1;
01085 }
01086
01087 if (strcmp(argv[1],"versionfnmbase")==0) {
01088 status = testVersionFnmBase(Comm, argv[2]);
01089 didOne=1;
01090 }
01091
01092 if (strcmp(argv[1],"insfnmtable")==0) {
01093 status = testInsFnmTable(Comm, argv[2], argv[3], argv[4], argv[5] );
01094 didOne=1;
01095 }
01096
01097 if (strcmp(argv[1],"insdvmtable")==0) {
01098 status = testInsDvmTable(Comm, argv[2], argv[3], argv[4], argv[5] );
01099 didOne=1;
01100 }
01101
01102 if (strcmp(argv[1],"insmsrvctable")==0) {
01103 status = testInsMsrvcTable(Comm, argv[2], argv[3], argv[4], argv[5],
01104 argv[6], argv[7], argv[8], argv[9], argv[10]);
01105 if (status==0) {
01106
01107
01108
01109
01110 status = testInsMsrvcTable(Comm, argv[2], argv[3], argv[4], argv[5],
01111 argv[6], argv[7], argv[8], argv[9], argv[10]);
01112 }
01113 didOne=1;
01114 }
01115
01116 if (status != 0) {
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126
01127
01128
01129
01130 myName = rodsErrorName(status, &mySubName);
01131 rodsLog (LOG_ERROR, "%s failed with error %d %s %s", argv[1],
01132 status, myName, mySubName);
01133 }
01134 else {
01135 if (didOne) printf("Completed successfully\n");
01136 }
01137
01138 if (didOne==0) {
01139 printf("Unknown test type: %s\n", argv[1]);
01140 }
01141
01142 exit(status);
01143 }