Esempio n. 1
0
 def testNonExistingMethodSignedRequestCall(self):
     playerId = "test"
     createPlayer(playerId, "test")
     session = createPlayerSession(playerId, 'signedRequest')
     signedRequest = createSignedRequest(playerId, session.secret, 'nonExisitingMehtod')
     response = signedRequestCall(signedRequest)
     self.assertTrue('error' in response and response['error']['code'] == UNKNOW_SERVICE_CALL_ERROR['code'])
Esempio n. 2
0
 def testWrongSessionSignedRequestForPlayer(self):
     playerId = "test"
     createPlayer(playerId, "test")
     createPlayerSession(playerId, 'signedRequest')
     signedRequest = createSignedRequest(playerId, "wrong secret", 'score.service.echo', 'hello')
     response = signedRequestCall(signedRequest)
     self.assertTrue('error' in response and response['error']['code'] == INVALID_SIGNATURE_ERROR['code'])
Esempio n. 3
0
 def testWrongSessionMethod(self):
     playerId = "test"
     createPlayer(playerId, "test")
     createPlayerSession(playerId, 'token')
     signedRequest = createSignedRequest(playerId, "wrong secret", 'score.service.echo', 'hello')
     response = signedRequestCall(signedRequest)
     self.assertTrue('error' in response and response['error']['code'] == SIGNED_REQUEST_METHOD_ERROR['code'])
Esempio n. 4
0
    def testExpiredSessionSignedRequestCall(self):
        playerId = "test"
        createPlayer(playerId, "test")
        session = createPlayerSession(playerId, 'signedRequest', datetime=datetime.datetime.now() - DEFAULT_MAX_SESSION_LIFE_TIME)

        signedRequest = createSignedRequest(playerId, session.secret, 'score.service.echo', 'hello')
        response = signedRequestCall(signedRequest)
        self.assertTrue('error' in response and response['error']['code'] == SESSION_EXPIRED_ERROR['code'])
Esempio n. 5
0
 def testWrongSessionMethod(self):
     playerId = "test"
     createPlayer(playerId, "test")
     createPlayerSession(playerId, 'token')
     signedRequest = createSignedRequest(playerId, "wrong secret",
                                         'score.service.echo', 'hello')
     response = signedRequestCall(signedRequest)
     self.assertTrue('error' in response and response['error']['code']
                     == SIGNED_REQUEST_METHOD_ERROR['code'])
Esempio n. 6
0
 def testNonExistingMethodSignedRequestCall(self):
     playerId = "test"
     createPlayer(playerId, "test")
     session = createPlayerSession(playerId, 'signedRequest')
     signedRequest = createSignedRequest(playerId, session.secret,
                                         'nonExisitingMehtod')
     response = signedRequestCall(signedRequest)
     self.assertTrue(
         'error' in response
         and response['error']['code'] == UNKNOW_SERVICE_CALL_ERROR['code'])
Esempio n. 7
0
 def testWrongSessionSignedRequestForPlayer(self):
     playerId = "test"
     createPlayer(playerId, "test")
     createPlayerSession(playerId, 'signedRequest')
     signedRequest = createSignedRequest(playerId, "wrong secret",
                                         'score.service.echo', 'hello')
     response = signedRequestCall(signedRequest)
     self.assertTrue(
         'error' in response
         and response['error']['code'] == INVALID_SIGNATURE_ERROR['code'])
Esempio n. 8
0
    def testCorrectSessionSignedRequestCall(self):
        playerId = "test"
        createPlayer(playerId, "test")
        session = createPlayerSession(playerId, 'signedRequest')

        message = 'hello'
        signedRequest = createSignedRequest(playerId, session.secret, 'score.service.echo', message)
        answer = signedRequestCall(signedRequest)

        self.assertEqual(answer['result'], str(playerId) + ':' + message)
Esempio n. 9
0
    def testCorrectSessionSignedRequestCall(self):
        playerId = "test"
        createPlayer(playerId, "test")
        session = createPlayerSession(playerId, 'signedRequest')

        message = 'hello'
        signedRequest = createSignedRequest(playerId, session.secret,
                                            'score.service.echo', message)
        answer = signedRequestCall(signedRequest)

        self.assertEqual(answer['result'], str(playerId) + ':' + message)
Esempio n. 10
0
    def testExpiredSessionSignedRequestCall(self):
        playerId = "test"
        createPlayer(playerId, "test")
        session = createPlayerSession(playerId,
                                      'signedRequest',
                                      datetime=datetime.datetime.now() -
                                      DEFAULT_MAX_SESSION_LIFE_TIME)

        signedRequest = createSignedRequest(playerId, session.secret,
                                            'score.service.echo', 'hello')
        response = signedRequestCall(signedRequest)
        self.assertTrue(
            'error' in response
            and response['error']['code'] == SESSION_EXPIRED_ERROR['code'])
Esempio n. 11
0
File: json.py Progetto: wighawag/ubh
class JsonRequestHandler(webapp.RequestHandler):

    # only post for now
    def post(self):
        try:
            #self.request.
            data = json.loads(self.request.body)
        except Exception, e:
            output = json.dumps({'id' : 'unknown', 'error' : {'code' : 35, 'message' : 'cannot parse the request' + e}})
            self.response.out.write(output)
            return;
        requestId = data['id']
        methodName = data['method']
        params = data['params']

        if methodName == "signedRequestCall":
            result = signedRequestCall(params[0])
            result['id'] = requestId
            output =json.dumps(result)
        else:
            output = json.dumps({'id' : requestId, 'error' : {'code' : 34, 'message' : 'method not supported'}})

        self.response.out.write(output)
Esempio n. 12
0
File: amf.py Progetto: wighawag/ubh
def amfSignedRequestCall(requestId, signedRequest):
    result = signedRequestCall(signedRequest)
    result['id'] = requestId
    return result
Esempio n. 13
0
File: amf.py Progetto: wighawag/ubh
def amfSignedRequestCall(requestId, signedRequest):
    result = signedRequestCall(signedRequest)
    result['id'] = requestId;
    return result