# Path: tokenserver/verifiers.py
# DEFAULT_OAUTH_SCOPE = 'https://identity.mozilla.com/apps/oldsync'
# def get_browserid_verifier(registry=None):
# def get_oauth_verifier(registry=None):
#     def __init__(self, trusted_issuers=None, allowed_issuers=None, **kwargs):
#     def _emit_warning():
#     def verify(self, assertion, audience=None):
#     def __init__(self, audiences=None, trusted_issuers=None,
#                  allowed_issuers=None, verifier_url=None, timeout=None):
#     def verify(self, assertion, audience=None):
#     def __init__(self, server_url=None, default_issuer=None, timeout=30,
#                  scope=DEFAULT_OAUTH_SCOPE, jwks=None):
#     def server_url(self):
#     def timeout(self):
#     def verify(self, token):
# class IBrowserIdVerifier(Interface):
# class IOAuthVerifier(Interface):
# class LocalBrowserIdVerifier(browserid.verifiers.local.LocalVerifier):
# class RemoteBrowserIdVerifier(object):
# class RemoteOAuthVerifier(object):


import socket
import unittest
import responses
import contextlib
import fxa.errors
from pyramid.config import Configurator
from tokenserver.verifiers import (
    IOAuthVerifier,
    ConnectionError,
    RemoteOAuthVerifier,
)
    def test_verifier_config_loading_defaults(self):
        config = self._make_config()
        verifier = config.registry.getUtility(IOAuthVerifier)
        self.assertTrue(isinstance(verifier, RemoteOAuthVerifier))
        self.assertEquals(verifier.server_url,
                          "https://oauth.accounts.firefox.com/v1")
        self.assertEquals(verifier.default_issuer,
                          "api.accounts.firefox.com")
        self.assertEquals(verifier.scope,
                          "https://identity.mozilla.com/apps/oldsync")
        self.assertEquals(verifier.timeout, 30)

    def test_verifier_config_loading_values(self):
        config = self._make_config({  # noqa; indentation below is non-standard
            "oauth.server_url":
                "https://oauth-test1.dev.lcip.org/",
            "oauth.default_issuer":
                "myissuer.com",
            "oauth.scope":
                "some.custom.scope",
            "oauth.timeout": 500
        })
        verifier = config.registry.getUtility(IOAuthVerifier)
        self.assertTrue(isinstance(verifier, RemoteOAuthVerifier))
        self.assertEquals(verifier.server_url,
                          "https://oauth-test1.dev.lcip.org/v1")
        self.assertEquals(verifier.default_issuer, "myissuer.com")
        self.assertEquals(verifier.scope, "some.custom.scope")
        self.assertEquals(verifier.timeout, 500)


# Path: tokenserver/verifiers.py
# DEFAULT_OAUTH_SCOPE = 'https://identity.mozilla.com/apps/oldsync'
# def get_browserid_verifier(registry=None):
# def get_oauth_verifier(registry=None):
#     def __init__(self, trusted_issuers=None, allowed_issuers=None, **kwargs):
#     def _emit_warning():
#     def verify(self, assertion, audience=None):
#     def __init__(self, audiences=None, trusted_issuers=None,
#                  allowed_issuers=None, verifier_url=None, timeout=None):
#     def verify(self, assertion, audience=None):
#     def __init__(self, server_url=None, default_issuer=None, timeout=30,
#                  scope=DEFAULT_OAUTH_SCOPE, jwks=None):
#     def server_url(self):
#     def timeout(self):
#     def verify(self, token):
# class IBrowserIdVerifier(Interface):
# class IOAuthVerifier(Interface):
# class LocalBrowserIdVerifier(browserid.verifiers.local.LocalVerifier):
# class RemoteBrowserIdVerifier(object):
# class RemoteOAuthVerifier(object):


# Path: tokenserver/tests/test_oauth_verifier.py
import socket
import unittest
import responses
import contextlib
import fxa.errors
from pyramid.config import Configurator
from tokenserver.verifiers import (
    IOAuthVerifier,
    ConnectionError,
    RemoteOAuthVerifier,
)

    def test_verifier_config_loading_defaults(self):
        config = self._make_config()
        verifier = config.registry.getUtility(IOAuthVerifier)
        self.assertTrue(isinstance(verifier, RemoteOAuthVerifier))
        self.assertEquals(verifier.server_url,
                          "https://oauth.accounts.firefox.com/v1")
        self.assertEquals(verifier.default_issuer,
                          "api.accounts.firefox.com")
        self.assertEquals(verifier.scope,
                          "https://identity.mozilla.com/apps/oldsync")
        self.assertEquals(verifier.timeout, 30)

    def test_verifier_config_loading_values(self):
        config = self._make_config({  # noqa; indentation below is non-standard
            "oauth.server_url":
                "https://oauth-test1.dev.lcip.org/",
            "oauth.default_issuer":
                "myissuer.com",
            "oauth.scope":
                "some.custom.scope",
            "oauth.timeout": 500
        })
        verifier = config.registry.getUtility(IOAuthVerifier)
        self.assertTrue(isinstance(verifier, RemoteOAuthVerifier))
        self.assertEquals(verifier.server_url,
                          "https://oauth-test1.dev.lcip.org/v1")
        self.assertEquals(verifier.default_issuer, "myissuer.com")
        self.assertEquals(verifier.scope, "some.custom.scope")
        self.assertEquals(verifier.timeout, 500)


    @responses.activate