Пример #1
0
    def receiveResults(self, token):

        username = jwt.decode(token, 'secret', algorithms='HS256').get('username')
        claims = jwt.decode(token, 'secret', algorithms='HS256').get('claim')

        if constantsclass.WEB_SERVICE in claims:

            try:
                messageQueue = ''
                messageQueue = clientRabbitMqPickupMessage.messageReceive()
                results = messageQueue.getMessage(username)
                jishinLogging.logger.info('Results Returned To %s' % username)

                return results

            except Exception as e:
                jishinLogging.logger.error('Error Recieving Results: %s' % e)

        else:
            invalidUser = ['You are not authorized to use this service']
            return invalidUser
Пример #2
0
    def receiveResults(self, token):

        username = jwt.decode(token, 'secret',
                              algorithms='HS256').get('username')
        claims = jwt.decode(token, 'secret', algorithms='HS256').get('claim')

        if constantsclass.WEB_SERVICE in claims:

            try:
                messageQueue = ''
                messageQueue = clientRabbitMqPickupMessage.messageReceive()
                results = messageQueue.getMessage(username)
                jishinLogging.logger.info('Results Returned To %s' % username)

                return results

            except Exception as e:
                jishinLogging.logger.error('Error Recieving Results: %s' % e)

        else:
            invalidUser = ['You are not authorized to use this service']
            return invalidUser
Пример #3
0
# Edited: 11/18/15
# Course: IST 440w
# Instructor: Professor Oakes

import sys

sys.path.append('..')
from messageQueuing import ceRabbitMqPushMessage
from messageQueuing import clientRabbitMqPickupMessage
import unittest
from pika.exceptions import *
from Errors import ValidationErrors
import datetime

testQueue = ceRabbitMqPushMessage.messageQueue()
testReceive = clientRabbitMqPickupMessage.messageReceive()
username = "******"
results = 'It Works'
nonexistQueue = 'bob'
date = str(datetime.datetime.now().date() + datetime.timedelta(days=3))
region = 'US'
predicitonType = 'WEEKLY'


class messageQueue_tests(unittest.TestCase):
    def test_message_send_receive_ok(self):
        send = results
        received = results
        sendResponse = testQueue.sendMessage(username, results, date, region, predicitonType)
        receiveResponse = testReceive.getMessage(username)
        self.assertEqual(sendResponse, send)