Ejemplo n.º 1
0
 def testApiValidJson(self):
     """Tests the RpxAuthInfo constructor.
     
     Should always be possible to create RpxAuthInfo objects. Status should
     be used by applications to decide if the response from RPX was valid.
     
     """
     testJson = '''
         {
           "profile": {
             "displayName": "brian",
             "preferredUsername": "******",
             "email": "*****@*****.**",
             "providerName": "Other",
             "identifier": "http:\/\/brian.myopenid.com\/"
           },
           "stat": "ok"
         }'''
         
     json = simplejson.loads(testJson)
     
     auth_info = RpxAuthInfo(json)
     self.assert_(auth_info)
     self.assert_(auth_info.get_status() == RpxAuthInfo.OK)
     self.assertEquals(auth_info.get_user_name(), "brian")
     self.assertEquals(auth_info.get_rpx_id(), "http://brian.myopenid.com/")
     self.assertEquals(auth_info.get_email(), "*****@*****.**")
     self.assertEquals(auth_info.get_provider(), "Other")
Ejemplo n.º 2
0
    def testApiValidJsonWithAltFields(self):
        """Tests that alternative fields for email and user name can be handled."""
        
        testJson = '''
            {
              "profile": {
                "displayName": "brian",
                "verifiedEmail": "*****@*****.**",
                "providerName": "Other",
                "identifier": "http:\/\/brian.myopenid.com\/"
              },
              "stat": "ok"
            }'''

        json = simplejson.loads(testJson)
        
        auth_info = RpxAuthInfo(json)
        self.assert_(auth_info)
        self.assertEquals(auth_info.get_user_name(), "brian")
        self.assertEquals(auth_info.get_rpx_id(), "http://brian.myopenid.com/")
        self.assertEquals(auth_info.get_email(), "*****@*****.**")
        self.assertEquals(auth_info.get_provider(), "Other")