Пример #1
0
        def test_friend_blob_get_no_zauth_header(self):
                zauth = AuthSystem.getUntrustedToken(Constants.ZID)

		ACL_arr=ACL.getGraphTypes('friend.blob.get', Constants.USER_BLOB)
                for element in ACL_arr:
                        if (element == 'any') or (element == 'self') or (element == 'none'):
                                ret , result = self.check_pass(friend_blob_get_no_Zauth_head , [ Constants.ZID, Constants.USER_BLOB],[403])
                                self.assertTrue(ret, msg = result)
                        else:
                                "In this case it is a graphlist"
                                ret =   get_friend_nofriend_id(zauth, element )
                                fid_list = ret['result']['data'][element]
                                fid = random.choice(fid_list)
                                """If  friend blob is empty, update some value and then fetch the blob, through friend.blob.get api"""
                                fzauth=AuthSystem.getUntrustedToken(fid)
                                result = user_blob_get( fzauth )
                                if "'CAS': None" in str(result):
                                        cas= " "
                                        data = data_to_post()
                                        result = user_blob_set( fzauth, Constants.USER_BLOB, data, cas)
                                else:
                                        cas = result[ Constants.BLOBS ][ Constants.USER_BLOB ][ Constants.GH_CAS ]
                                """Checking for friend"""
                                ret , result = self.check_pass(friend_blob_get_no_Zauth_head , [ fid, Constants.USER_BLOB],[403])
                                self.assertTrue(ret, msg = result)
                                """cheking for non-friend"""
                                nfid=nfzid(zauth)
                                ret , result = self.check_pass(friend_blob_get_no_Zauth_head , [ nfid, Constants.USER_BLOB],[403])
                                self.assertTrue(ret, msg = result)
Пример #2
0
        def test_friend_blob_queryDeltas_empty_token(self):
                zauth=None
		user_query = {Constants.USER_QUERY: Constants.F_QUERY, "params":[] }
		ACL_arr=ACL.getGraphTypes('friend.blob.queryDeltas',Constants.DELTATYPE)
		delta="some delta"
                for element in ACL_arr:
                        if (element == 'any'):
				self.test_friend_blob_addDelta()
                                ret , result = self.check_pass(friend_blob_queryDeltas , [zauth , Constants.ZID+1,user_query] ,[403])
				self.assertTrue(ret, msg=result)
                        elif (element == 'self'):
				self.test_friend_blob_addDelta()
                                ret , result = self.check_pass(friend_blob_queryDeltas , [zauth ,Constants.ZID, user_query] ,[403])
				self.assertTrue(ret, msg=result)
                        elif (element == 'none'):
                                ret , result = self.check_pass(friend_blob_queryDeltas , [zauth ,Constants.ZID, user_query] ,[403])
				self.assertTrue(ret, msg=result)
                        else:
                                """graph-list"""
                                ret =   get_friend_nofriend_id(AuthSystem.getUntrustedToken(Constants.ZID), element )
                                fid_list=ret['result']['data'][element]
                                fid = random.choice(fid_list)
				self.test_friend_blob_addDelta()
                                ret , result = self.check_pass(friend_blob_queryDeltas , [zauth ,fid,user_query] ,[403])
				self.assertTrue(ret, msg=result)
                                """for non-friends"""
                                nfid=nfzid(AuthSystem.getUntrustedToken(Constants.ZID))
                                ret , result = self.check_pass(friend_blob_queryDeltas , [zauth ,nfid,user_query] ,[403])
				self.assertTrue(ret, msg=result)
Пример #3
0
	def test_friend_blob_addDelta_expired_token(self):
		zauth = AuthSystem.getExpiredToken(Constants.ZID)
		delta = "sample delta value"
		ACL_arr=ACL.getGraphTypes('friend.blob.addDelta',Constants.DELTATYPE)
		for element in ACL_arr:
			if (element == 'any'):
				delete_prev_deltas(Constants.ZID)
				ret , result = self.check_pass(friend_blob_addDelta , [ zauth , Constants.ZID+1,Constants.DELTATYPE,delta ] ,[403])
				self.assertTrue(ret, msg=result)
			elif (element == 'self'):
				delete_prev_deltas(Constants.ZID)
				ret , result = self.check_pass(friend_blob_addDelta , [ zauth , Constants.ZID,Constants.DELTATYPE,delta ] ,[403])
				self.assertTrue(ret, msg=result)
			elif (element == 'none'):
				delete_prev_deltas(Constants.ZID)
                                ret , result = self.check_pass(friend_blob_addDelta , [ zauth , Constants.ZID,Constants.DELTATYPE,delta ] ,[403])	
				self.assertTrue(ret, msg=result)
			else:
				delete_prev_deltas(Constants.ZID)
				ret =   get_friend_nofriend_id(AuthSystem.getUntrustedToken(Constants.ZID),element)
                                fid_list=ret['result']['data'][element]
                                fid = random.choice(fid_list)
                                res=delete_prev_deltas(fid)
                                ret , result = self.check_pass(friend_blob_addDelta , [ zauth , Constants.ZID,Constants.DELTATYPE,delta ] ,[403])
				self.assertTrue(ret, msg=result)

                                """for non-friend, 403 should be returned as err code"""
                                nfid=nfzid(AuthSystem.getUntrustedToken(Constants.ZID))
                                ret , result = self.check_pass(friend_blob_addDelta , [ zauth , nfid , Constants.DELTATYPE , delta ] ,[403])
				self.assertTrue(ret, msg=result)
Пример #4
0
	def test_friend_blob_addDelta(self):
        	zauth = AuthSystem.getUntrustedToken(Constants.ZID)
		ACL_arr=ACL.getGraphTypes('friend.blob.addDelta',Constants.DELTATYPE)
		delta = "sample delta value"
		for element in ACL_arr:
			if (element == 'any'):
				ret , result = self.check_pass(friend_blob_addDelta , [ zauth , Constants.ZID, Constants.DELTATYPE , delta ] ,[0])
				self.assertTrue(ret, msg=result)
			elif (element == 'self'):
				ret,result = self.check_pass(friend_blob_addDelta , [ zauth , Constants.ZID, Constants.DELTATYPE , delta ] ,[0])
				self.assertTrue(ret, msg=result)
			elif (element == 'none'):
				ret,result = self.check_pass(friend_blob_addDelta , [ zauth , Constants.ZID, Constants.DELTATYPE , delta ] ,[403])
				self.assertTrue(ret, msg=result)
			else:
				"""graph-list """
				ret =   get_friend_nofriend_id(AuthSystem.getUntrustedToken(Constants.ZID),element)
				fid_list=ret['result']['data'][element]
				fid = random.choice(fid_list)
				res=delete_prev_deltas(fid)
				ret , result = self.check_pass(friend_blob_addDelta , [ zauth , fid , Constants.DELTATYPE , delta ] ,[0])
				self.assertTrue(ret, msg=result)
			
				"""check for failure when non friend tries to add delta"""
				nfid=nfzid(AuthSystem.getUntrustedToken(Constants.ZID))
				ret , result = self.check_pass(friend_blob_addDelta , [ zauth , nfid , Constants.DELTATYPE , delta ] ,[403])
				self.assertTrue(ret, msg=result)	
Пример #5
0
	def test_user_blob_queryDeltas_Mixed_case_char(self):
		zauth = AuthSystem.getUntrustedToken(Constants.ZID)
		user_query = {Constants.USER_QUERY: "select * from DeLTAs"  , "params": {"type": Constants.DELTATYPE}}
		ACL_arr = ACL.getGraphTypes('user.blob.queryDeltas',Constants.DELTATYPE)
		for element in ACL_arr:
			if (element == 'any' or element == 'self' or element == 'none'):
				ret,result = self.check_pass(user_blob_queryDeltas , [zauth , user_query],[403])
				self.assertTrue(ret, msg=result)
			else:
				self.fail(msg="invalid ACL rule for the api")
Пример #6
0
	def test_user_blob_queryDeltas_noquery(self):
		zauth = AuthSystem.getUntrustedToken(Constants.ZID)
		user_query=None
		ACL_arr = ACL.getGraphTypes('user.blob.queryDeltas',Constants.DELTATYPE)
		for element in ACL_arr:
			if (element == 'any' or element == 'self' or element == 'none'):
				ret,result = self.check_pass(user_blob_queryDeltas , [zauth , user_query],[403])
				self.assertTrue(ret, msg=result)
			else:
				self.fail(msg="invalid ACL rule for the api")
Пример #7
0
        def test_friend_blob_addDelta_Max_delta_count(self):
                zauth = AuthSystem.getUntrustedToken(Constants.ZID)
		delta="some delta"
		limit=ConfigService.getDeltaLimits(Constants.DELTATYPE)
		maxcount=limit['maxcount']
		keep=limit['keep']
		if (keep is False):
	                self.assertTrue(False,msg="Check for keep variable in storage.yaml file for the delta type") 
		

		ACL_arr=ACL.getGraphTypes('friend.blob.addDelta',Constants.DELTATYPE)
		for element in ACL_arr:
		  if (element == 'any'):
			delete_prev_deltas(Constants.ZID)
			delta_max=delta_max_count(zauth , Constants.ZID+1 , Constants.DELTATYPE,maxcount,delta)
			ret , result = self.check_pass(friend_blob_addDelta , [ zauth , Constants.ZID+1, Constants.DELTATYPE , delta ] ,[413])
			self.assertTrue(ret, msg=result)
		  elif (element == 'self'):
			delete_prev_deltas(Constants.ZID)
			delta_max=delta_max_count(zauth , Constants.ZID , Constants.DELTATYPE,maxcount,delta)
                        ret , result = self.check_pass(friend_blob_addDelta , [ zauth ,Constants.ZID , Constants.DELTATYPE , delta ] ,[413])
			self.assertTrue(ret, msg=result)
		  elif (element == 'none'):
			delete_prev_deltas(Constants.ZID)
			delta_max=delta_max_count(zauth ,Constants.ZID , Constants.DELTATYPE,maxcount,delta)
			ret , result = self.check_pass(friend_blob_addDelta , [ zauth ,Constants.ZID,Constants.DELTATYPE , delta ] ,[403])
			self.assertTrue(ret, msg=result)
		  else:
			"""This is graph-list """
                        delete_prev_deltas(Constants.ZID)
			ret =   get_friend_nofriend_id(zauth, element )
                        fid_list=ret['result']['data'][element]
                        fid = random.choice(fid_list)
			delta_max=delta_max_count(zauth , fid , Constants.DELTATYPE,maxcount,delta)
                        ret , result = self.check_pass(friend_blob_addDelta , [ zauth ,fid, Constants.DELTATYPE , delta ] ,[413])
			self.assertTrue(ret, msg=result)

                        """for non-friends"""
                        delete_prev_deltas(Constants.ZID)
			nfid=nfzid(zauth)
			delta_max=delta_max_count(zauth , fid , Constants.DELTATYPE,maxcount,delta)
                        ret , result = self.check_pass(friend_blob_addDelta , [ zauth ,nfid, Constants.DELTATYPE , delta ] ,[403])
			self.assertTrue(ret, msg=result)
Пример #8
0
	def test_friend_blob_addDelta_Exceed_content_Limit(self):
                zauth = AuthSystem.getUntrustedToken(Constants.ZID)
		limit=ConfigService.getDeltaLimits(Constants.DELTATYPE)
		ACL_arr=ACL.getGraphTypes('friend.blob.addDelta',Constants.DELTATYPE)
                for element in ACL_arr:
                        if (element == 'any'):
				#delete_prev_deltas(fid)
				delete_prev_deltas(Constants.ZID)
				delta=delta_max_size(limit['maxsize']+1024,Constants.DELTATYPE)
				ret , result = self.check_pass(friend_blob_addDelta , [ zauth , Constants.ZID, Constants.DELTATYPE , delta ] ,[413])
				self.assertTrue(ret, msg=result)
			elif (element == 'self'):
				delete_prev_deltas(Constants.ZID)
				delta=delta_max_size(limit['maxsize']+1024,Constants.DELTATYPE)
				ret , result = self.check_pass(friend_blob_addDelta , [ zauth , Constants.ZID, Constants.DELTATYPE , delta ] ,[413])
				self.assertTrue(ret, msg=result)
			elif (element == 'none'):
				delete_prev_deltas(Constants.ZID)
                                delta=delta_max_size(limit['maxsize']+1024,Constants.DELTATYPE)
				ret , result = self.check_pass(friend_blob_addDelta , [ zauth , Constants.ZID, Constants.DELTATYPE , delta ] ,[403])
				self.assertTrue(ret, msg=result)
			else:
				"""This is graph-list """
				delete_prev_deltas(Constants.ZID)
				ret =   get_friend_nofriend_id(AuthSystem.getUntrustedToken(Constants.ZID), element )
				fid_list=ret['result']['data'][element]
				fid = random.choice(fid_list)
				delta=delta_max_size(limit['maxsize']+1024,Constants.DELTATYPE)
                                ret , result = self.check_pass(friend_blob_addDelta , [ zauth , fid , Constants.DELTATYPE , delta ] ,[413]) 
				self.assertTrue(ret, msg=result)	
				"""for non-friends"""
				delete_prev_deltas(Constants.ZID)
				nfid=nfzid(AuthSystem.getUntrustedToken(Constants.ZID))
                                delta=delta_max_size(limit['maxsize']+1024,Constants.DELTATYPE)
				ret , result = self.check_pass(friend_blob_addDelta , [ zauth , nfid, Constants.DELTATYPE , delta ] ,[403])
				self.assertTrue(ret, msg=result)