Esempio n. 1
0
 def setUp(self):
     op = sc_messages.QuotaOperation(
         consumerId=_TEST_CONSUMER_ID,
         methodName=_TEST_OP_NAME
     )
     self.test_quota_request = sc_messages.AllocateQuotaRequest(allocateOperation=op)
     self.test_op = op
Esempio n. 2
0
def _make_test_request(service_name, operation_id=None, importance=None):
    if importance is None:
        importance = sc_messages.Operation.ImportanceValueValuesEnum.LOW
    op = sc_messages.QuotaOperation(
        consumerId=_TEST_CONSUMER_ID,
        methodName=_TEST_OP_NAME,
        operationId=operation_id,
    )
    quota_request = sc_messages.AllocateQuotaRequest(allocateOperation=op)
    return sc_messages.ServicecontrolServicesAllocateQuotaRequest(
        serviceName=service_name,
        allocateQuotaRequest=quota_request)
Esempio n. 3
0
 def test_should_fail_if_operation_has_no_consumer_id(self):
     op = sc_messages.QuotaOperation(methodName=_TEST_OP_NAME)
     testf = lambda: quota_request.sign(
         sc_messages.AllocateQuotaRequest(allocateOperation=op))
     expect(testf).to(raise_error(ValueError))
Esempio n. 4
0
 def test_should_fail_if_operation_has_no_method_name(self):
     op = sc_messages.QuotaOperation(consumerId=_TEST_CONSUMER_ID)
     testf = lambda: quota_request.sign(
         sc_messages.AllocateQuotaRequest(allocateOperation=op))
     expect(testf).to(raise_error(ValueError))
Esempio n. 5
0

_WANTED_USER_AGENT = label_descriptor.USER_AGENT
_WANTED_SERVICE_AGENT = label_descriptor.SERVICE_AGENT
_START_OF_EPOCH = timestamp.to_rfc3339(datetime.datetime(1970, 1, 1, 0, 0, 0))
_TEST_SERVICE_NAME = u'a_service_name'
_INFO_TESTS = [
    (quota_request.Info(
        operation_id=u'an_op_id',
        operation_name=u'an_op_name',
        referer=u'a_referer',
        service_name=_TEST_SERVICE_NAME),
     sc_messages.QuotaOperation(
         labels = encoding.PyValueToMessage(
             sc_messages.QuotaOperation.LabelsValue, {
                 u'servicecontrol.googleapis.com/referer': u'a_referer',
             }),
         operationId=u'an_op_id',
         methodName=u'an_op_name',
         quotaMode=sc_messages.QuotaOperation.QuotaModeValueValuesEnum.BEST_EFFORT)),
    (quota_request.Info(
        android_cert_fingerprint=u'an_android_cert_fingerprint',
        android_package_name=u'an_android_package_name',
        api_key=u'an_api_key',
        api_key_valid=True,
        ios_bundle_id=u'an_ios_bundle_id',
        operation_id=u'an_op_id',
        operation_name=u'an_op_name',
        referer=u'a_referer',
        service_name=_TEST_SERVICE_NAME),
     sc_messages.QuotaOperation(
         consumerId=u'api_key:an_api_key',