def setUp(self):
     self.validator = mock.MagicMock(spec=RequestValidator)
     self.validator.get_default_redirect_uri.return_value = None
     self.web = WebApplicationServer(self.validator)
     self.mobile = MobileApplicationServer(self.validator)
     self.legacy = LegacyApplicationServer(self.validator)
     self.backend = BackendApplicationServer(self.validator)
Exemple #2
0
 def setUp(self):
     self.validator = mock.MagicMock(spec=RequestValidator)
     self.validator.get_default_redirect_uri.return_value = TestScopeHandling.DEFAULT_REDIRECT_URI
     self.validator.authenticate_client.side_effect = self.set_client
     self.web = WebApplicationServer(self.validator)
     self.mobile = MobileApplicationServer(self.validator)
     self.legacy = LegacyApplicationServer(self.validator)
     self.backend = BackendApplicationServer(self.validator)
Exemple #3
0
 def setUp(self):
     self.validator = mock.MagicMock(spec=RequestValidator)
     self.validator.get_default_redirect_uri.return_value = 'http://i.b./path'
     self.web = WebApplicationServer(self.validator,
                                     token_generator=self.inspect_client)
     self.mobile = MobileApplicationServer(
         self.validator, token_generator=self.inspect_client)
     self.legacy = LegacyApplicationServer(
         self.validator, token_generator=self.inspect_client)
     self.backend = BackendApplicationServer(
         self.validator, token_generator=self.inspect_client)
Exemple #4
0
    def setUp(self):
        super().setUp()
        self.oauth = BottleOAuth2(self.app)
        self.validator = mock.MagicMock()
        self.server = LegacyApplicationServer(self.validator)
        self.metadata_endpoint = MetadataEndpoint([self.server], claims={
            "issuer": "https://xx",
            "token_endpoint": "https://xx/token",
            "revocation_endpoint": "https://xx/revoke",
            "introspection_endpoint": "https://xx/tokeninfo"
        })

        self.oauth.initialize(self.metadata_endpoint)

        self.fake_response = ({}, "", "200 fooOK")
 def setUp(self):
     self.validator = mock.MagicMock(spec=RequestValidator)
     self.validator.is_pkce_required.return_value = False
     self.validator.get_code_challenge.return_value = None
     self.validator.get_default_redirect_uri.return_value = 'http://i.b./path'
     self.web = WebApplicationServer(self.validator,
             token_generator=self.inspect_client)
     self.mobile = MobileApplicationServer(self.validator,
             token_generator=self.inspect_client)
     self.legacy = LegacyApplicationServer(self.validator,
             token_generator=self.inspect_client)
     self.backend = BackendApplicationServer(self.validator,
             token_generator=self.inspect_client)
     self.token_uri = 'http://example.com/path'
     self.auth_uri = 'http://example.com/path?client_id=abc&response_type=token'
     # should be base64 but no added value in this unittest
     self.basicauth_client_creds = {"Authorization": "john:doe"}
     self.basicauth_client_id = {"Authorization": "john:"}
Exemple #6
0
                'expiration'] > datetime.now().timestamp()

        def validate_refresh_token(self, refresh_token, client, request, *args,
                                   **kwargs):
            """Ensure the Bearer token is valid and authorized access to scopes."""
            for t in _tokens.values():
                if t['refresh_token'] == refresh_token:
                    return True
            return False

        def get_original_scopes(self, refresh_token, request, *args, **kwargs):
            """Get the list of scopes associated with the refresh token."""
            return []

    validator = SimpleValidator()
    oauth_server = LegacyApplicationServer(
        validator, token_expires_in=QGIS_SERVER_OAUTH2_TOKEN_EXPIRES_IN)

    class OAuth2Filter(QgsServerFilter):
        """This filter provides testing endpoint for OAuth2 Resource Owner Grant Flow

        Available endpoints:
        - /token (returns a new access_token),
                 optionally specify an expiration time in seconds with ?ttl=<int>
        - /refresh (returns a new access_token from a refresh token),
                 optionally specify an expiration time in seconds with ?ttl=<int>
        - /result (check the Bearer token and returns a short sentence if it validates)
        """
        def responseComplete(self):

            handler = self.serverInterface().requestHandler()