def test01_empty_auth_defined(self):
     """Test empty auth."""
     info = IIIFInfo(identifier="http://example.com/i1", api_version='2.1')
     auth = IIIFAuth()
     auth.add_services(info)
     self.assertJSONEqual(info.as_json(
         validate=False), '{\n  "@context": "http://iiif.io/api/image/2/context.json", \n  "@id": "http://example.com/i1", \n  "profile": [\n    "http://iiif.io/api/image/2/level1.json"\n  ], \n  "protocol": "http://iiif.io/api/image"\n}')
     self.assertEqual(info.service, None)
Exemple #2
0
 def test01_empty_auth_defined(self):
     """Test empty auth."""
     info = IIIFInfo(identifier="http://example.com/i1", api_version='2.1')
     auth = IIIFAuth()
     auth.add_services(info)
     self.assertJSONEqual(info.as_json(
         validate=False), '{\n  "@context": "http://iiif.io/api/image/2/context.json", \n  "@id": "http://example.com/i1", \n  "profile": [\n    "http://iiif.io/api/image/2/level1.json"\n  ], \n  "protocol": "http://iiif.io/api/image"\n}')
     self.assertEqual(info.service, None)
 def test02_just_login(self):
     info = IIIFInfo(identifier="http://example.com/i1", api_version='2.1')
     auth = IIIFAuth()
     auth.login_uri = 'http://example.com/login'
     auth.add_services(info) 
     self.assertEqual( info.service['@id'], "http://example.com/login" )
     self.assertEqual( info.service['label'], "Login to image server" )
     self.assertEqual( info.service['profile'], "http://iiif.io/api/auth/0/login" )
Exemple #4
0
 def test02_just_login(self):
     """Test just login."""
     info = IIIFInfo(identifier="http://example.com/i1", api_version='2.1')
     auth = IIIFAuth()
     auth.login_uri = 'http://example.com/login'
     auth.add_services(info)
     self.assertEqual(info.service['@id'], "http://example.com/login")
     self.assertEqual(info.service['label'], "Login to image server")
     self.assertEqual(info.service['profile'],
                      "http://iiif.io/api/auth/1/login")
 def test04_login_and_client_id(self):
     info = IIIFInfo(identifier="http://example.com/i1", api_version='2.1')
     auth = IIIFAuth()
     auth.login_uri = 'http://example.com/login'
     auth.client_id_uri = 'http://example.com/client_id'
     auth.add_services(info) 
     self.assertEqual( info.service['@id'], "http://example.com/login" )
     self.assertEqual( info.service['label'], "Login to image server" )
     self.assertEqual( info.service['profile'], "http://iiif.io/api/auth/0/login" )
     svcs = info.service['service']
     self.assertEqual( svcs['@id'], "http://example.com/client_id" )
     self.assertEqual( svcs['profile'], "http://iiif.io/api/auth/0/clientId" )
 def test05_login_and_access_token(self):
     """Test login and access token."""
     info = IIIFInfo(identifier="http://example.com/i1", api_version='2.1')
     auth = IIIFAuth()
     auth.login_uri = 'http://example.com/login'
     auth.access_token_uri = 'http://example.com/token'
     auth.add_services(info)
     self.assertEqual(info.service['@id'], "http://example.com/login")
     self.assertEqual(info.service['label'], "Login to image server")
     self.assertEqual(info.service['profile'],
                      "http://iiif.io/api/auth/1/login")
     svcs = info.service['service']
     self.assertEqual(svcs['@id'], "http://example.com/token")
     self.assertEqual(svcs['profile'], "http://iiif.io/api/auth/1/token")
Exemple #7
0
 def test03_add_services(self):
     info = IIIFInfo()
     auth = IIIFAuth()
     self.assertEqual( info.service, None )
     # first just login
     auth.add_services(info)
     self.assertEqual( info.service, None )
     auth.login_uri = 'Xlogin'
     auth.add_services(info)
     self.assertEqual( info.service['@id'], 'Xlogin' )
     # then login and logout
     info = IIIFInfo()
     auth = IIIFAuth()
     auth.login_uri = 'Xlogin'
     auth.logout_uri = 'Ylogout'
     auth.add_services(info)
     self.assertEqual( info.service['service']['@id'], 'Ylogout' )
     # now add all, check we have all @ids in service description
     info = IIIFInfo()
     auth = IIIFAuth()
     auth.login_uri = 'Zlogin'
     auth.logout_uri = 'Zlogout'
     auth.client_id_uri = 'Zclient'
     auth.access_token_uri = 'Ztoken'
     auth.add_services(info)
     self.assertEqual( info.service['@id'], 'Zlogin' )
     self.assertEqual( len(info.service['service']), 3 )
     ids = set([ e['@id'] for e in info.service['service'] ])
     self.assertEqual( ids, set([auth.logout_uri,auth.client_id_uri,auth.access_token_uri]) )
Exemple #8
0
 def test03_add_services(self):
     """Test add_services."""
     info = IIIFInfo()
     auth = IIIFAuth()
     self.assertEqual(info.service, None)
     # first just login
     auth.add_services(info)
     self.assertEqual(info.service, None)
     auth.login_uri = 'Xlogin'
     auth.add_services(info)
     self.assertEqual(info.service['@id'], 'Xlogin')
     # then login and logout
     info = IIIFInfo()
     auth = IIIFAuth()
     auth.login_uri = 'Xlogin'
     auth.logout_uri = 'Ylogout'
     auth.add_services(info)
     self.assertEqual(info.service['service']['@id'], 'Ylogout')
     # now add all, check we have all @ids in service description
     info = IIIFInfo()
     auth = IIIFAuth()
     auth.login_uri = 'Zlogin'
     auth.logout_uri = 'Zlogout'
     auth.client_id_uri = 'Zclient'
     auth.access_token_uri = 'Ztoken'
     auth.add_services(info)
     self.assertEqual(info.service['@id'], 'Zlogin')
     self.assertEqual(len(info.service['service']), 3)
     ids = set([e['@id'] for e in info.service['service']])
     self.assertEqual(
         ids,
         set([auth.logout_uri, auth.client_id_uri, auth.access_token_uri]))
Exemple #9
0
 def test05_login_and_access_token(self):
     """Test login and access token."""
     info = IIIFInfo(identifier="http://example.com/i1", api_version='2.1')
     auth = IIIFAuth()
     auth.login_uri = 'http://example.com/login'
     auth.access_token_uri = 'http://example.com/token'
     auth.add_services(info)
     self.assertEqual(info.service['@id'], "http://example.com/login")
     self.assertEqual(info.service['label'], "Login to image server")
     self.assertEqual(info.service['profile'],
                      "http://iiif.io/api/auth/1/login")
     svcs = info.service['service']
     self.assertEqual(svcs['@id'], "http://example.com/token")
     self.assertEqual(svcs['profile'], "http://iiif.io/api/auth/1/token")
Exemple #10
0
 def test04_login_and_client_id(self):
     """Test login and client id."""
     info = IIIFInfo(identifier="http://example.com/i1", api_version='2.1')
     auth = IIIFAuth()
     auth.login_uri = 'http://example.com/login'
     auth.client_id_uri = 'http://example.com/client_id'
     auth.add_services(info)
     self.assertEqual(info.service['@id'], "http://example.com/login")
     self.assertEqual(info.service['label'], "Login to image server")
     self.assertEqual(info.service['profile'],
                      "http://iiif.io/api/auth/1/login")
     svcs = info.service['service']
     self.assertEqual(svcs['@id'], "http://example.com/client_id")
     self.assertEqual(svcs['profile'], "http://iiif.io/api/auth/1/clientId")
Exemple #11
0
 def test03_login_and_logout(self):
     """Test login and logout."""
     info = IIIFInfo(identifier="http://example.com/i1", api_version='2.1')
     auth = IIIFAuth()
     auth.login_uri = 'http://example.com/login'
     auth.logout_uri = 'http://example.com/logout'
     auth.add_services(info)
     self.assertEqual(info.service['@id'], "http://example.com/login")
     self.assertEqual(info.service['label'], "Login to image server")
     self.assertEqual(info.service['profile'],
                      "http://iiif.io/api/auth/0/login")
     svcs = info.service['service']
     self.assertEqual(svcs['@id'], "http://example.com/logout")
     self.assertEqual(svcs['label'], "Logout from image server")
     self.assertEqual(svcs['profile'], "http://iiif.io/api/auth/0/logout")
 def test06_full_set(self):
     info = IIIFInfo(identifier="http://example.com/i1", api_version='2.1')
     auth = IIIFAuth()
     auth.name = "Whizzo!"
     auth.logout_uri = 'http://example.com/logout'
     auth.access_token_uri = 'http://example.com/token'
     auth.client_id_uri = 'http://example.com/clientId'
     auth.login_uri = 'http://example.com/login'
     auth.add_services(info) 
     self.assertEqual( info.service['@id'], "http://example.com/login" )
     self.assertEqual( info.service['label'], "Login to Whizzo!" )
     svcs = info.service['service']
     self.assertEqual( svcs[0]['@id'], "http://example.com/logout" )
     self.assertEqual( svcs[1]['@id'], "http://example.com/clientId" )
     self.assertEqual( svcs[2]['@id'], "http://example.com/token" )
Exemple #13
0
 def test06_full_set(self):
     """Test full set of auth services."""
     info = IIIFInfo(identifier="http://example.com/i1", api_version='2.1')
     auth = IIIFAuth()
     auth.name = "Whizzo!"
     auth.logout_uri = 'http://example.com/logout'
     auth.access_token_uri = 'http://example.com/token'
     auth.client_id_uri = 'http://example.com/clientId'
     auth.login_uri = 'http://example.com/login'
     auth.add_services(info)
     self.assertEqual(info.service['@id'], "http://example.com/login")
     self.assertEqual(info.service['label'], "Login to Whizzo!")
     svcs = info.service['service']
     self.assertEqual(svcs[0]['@id'], "http://example.com/logout")
     self.assertEqual(svcs[1]['@id'], "http://example.com/clientId")
     self.assertEqual(svcs[2]['@id'], "http://example.com/token")