Exemplo n.º 1
0
 def testParseWithSubject(self):
     parser = xrd.Parser()
     description = parser.parse(
         '''<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
          <Subject>acct://[email protected]</Subject>
        </XRD>''')
     self.assertEquals('acct://[email protected]', description.subject)
Exemplo n.º 2
0
 def testParseWithExpires(self):
     parser = xrd.Parser()
     description = parser.parse(
         '''<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
          <Expires>1970-01-01T00:00:00Z</Expires>
        </XRD>''')
     self.assertEquals('1970-01-01T00:00:00Z', description.expires)
Exemplo n.º 3
0
 def testParseEmptyString(self):
     parser = xrd.Parser()
     try:
         parser.parse('')
         self.fail('ParseError expected.')
     except xrd.ParseError:
         pass  # expected
Exemplo n.º 4
0
 def testParseWithAliases(self):
     parser = xrd.Parser()
     description = parser.parse(
         '''<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
          <Alias>http://www.google.com/profiles/bradfitz</Alias>
          <Alias>http://www.google.com/profiles/brad.fitz</Alias>
        </XRD>''')
     self.assertEquals(2, len(description.aliases))
     self.assertEquals('http://www.google.com/profiles/bradfitz',
                       description.aliases[0])
     self.assertEquals('http://www.google.com/profiles/brad.fitz',
                       description.aliases[1])
Exemplo n.º 5
0
    def __init__(self, http_client=None, xrd_parser=None):
        """Construct a new WebFinger client.

    Args:
      http_client: A httplib2-like instance [optional]
      xrd_parser: An XRD parser [optional]
    """
        if http_client:
            self._http_client = http_client
        else:
            self._http_client = httplib2.Http()
        if xrd_parser:
            self._xrd_parser = xrd_parser
        else:
            self._xrd_parser = xrd.Parser()
Exemplo n.º 6
0
 def testParseAll(self):
     parser = xrd.Parser()
     description = parser.parse(
         '''<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xml:id="foo">
          <Expires>1970-01-01T00:00:00Z</Expires>
          <Subject>http://example.com/gpburdell</Subject>
          <Property type="http://spec.example.net/type/person"
              xsi:nil="true" />
          <Alias>http://people.example.com/gpburdell</Alias>
          <Alias>acct:[email protected]</Alias>
          <Link rel="http://spec.example.net/auth/1.0"
              href="http://services.example.com/auth" />
          <Link rel="http://spec.example.net/photo/1.0" type="image/jpeg"
              href="http://photos.example.com/gpburdell.jpg">
            <Title xml:lang="en">User Photo</Title>
          </Link>
        </XRD>''')
     self.assertEquals('foo', description.id)
     self.assertEquals('1970-01-01T00:00:00Z', description.expires)
     self.assertEquals('http://example.com/gpburdell', description.subject)
     self.assertEquals('http://spec.example.net/type/person',
                       description.properties[0].type)
     self.assertEquals(True, description.properties[0].nil)
     self.assertEquals(2, len(description.aliases))
     self.assertEquals('http://people.example.com/gpburdell',
                       description.aliases[0])
     self.assertEquals('acct:[email protected]', description.aliases[1])
     self.assertEquals(2, len(description.links))
     self.assertEquals('http://spec.example.net/auth/1.0',
                       description.links[0].rel)
     self.assertEquals('http://services.example.com/auth',
                       description.links[0].href)
     self.assertEquals('http://spec.example.net/photo/1.0',
                       description.links[1].rel)
     self.assertEquals('image/jpeg', description.links[1].type)
     self.assertEquals('http://photos.example.com/gpburdell.jpg',
                       description.links[1].href)
     self.assertEquals(1, len(description.links[1].titles))
     self.assertEquals('User Photo', description.links[1].titles[0].value)
     self.assertEquals('en', description.links[1].titles[0].lang)
Exemplo n.º 7
0
 def testParseWithId(self):
     parser = xrd.Parser()
     description = parser.parse(
         '<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0" xml:id="foo"/>'
     )
     self.assertEquals('foo', description.id)
Exemplo n.º 8
0
 def testParse(self):
     parser = xrd.Parser()
     description = parser.parse(
         '<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"/>')