예제 #1
0
    def test_oauth_session_user_override(self):
        """OAuthClient should override user, pass and session"""
        c = OAuthClient(
            instance="test",
            client_id="test1",
            client_secret="test2",
            session="testsess",
            user="******",
            password="******",
        )

        self.assertEqual(c._user, None)
        self.assertEqual(c._password, None)
예제 #2
0
    def setUp(self):
        seconds = 3600

        in_one_hour = datetime.datetime.now() + datetime.timedelta(
            seconds=seconds)
        expires_at = int(in_one_hour.strftime("%s"))

        one_hour_ago = datetime.datetime.now() - datetime.timedelta(
            seconds=seconds)
        expired_at = int(one_hour_ago.strftime("%s"))

        self.mock_token = {
            'refresh_token': 'refresh',
            'token_type': 'Bearer',
            'access_token': 'access',
            'expires_at': expires_at,
            'scope': ['useraccount'],
            'expires_in': seconds
        }

        self.mock_token_expired = {
            'refresh_token': 'refresh',
            'token_type': 'Bearer',
            'access_token': 'access',
            'expires_at': expired_at,
            'scope': ['useraccount'],
            'expires_in': -seconds
        }

        self.incident_path = 'api/now/table/incident'
        self.mock_incident_number = 'INC012345'

        self.mock_token_url = "https://test.service-now.com/oauth_token.do"

        self.client = OAuthClient(instance="test",
                                  client_id="test1",
                                  client_secret="test2",
                                  token_updater=self.token_updater)
예제 #3
0
    def setUp(self):
        seconds = 3600

        in_one_hour = datetime.datetime.now() + datetime.timedelta(
            seconds=seconds)
        expires_at = int(in_one_hour.strftime("%s"))

        one_hour_ago = datetime.datetime.now() - datetime.timedelta(
            seconds=seconds)
        expired_at = int(one_hour_ago.strftime("%s"))

        self.mock_token = {
            "refresh_token": "refresh",
            "token_type": "Bearer",
            "access_token": "access",
            "expires_at": expires_at,
            "scope": ["useraccount"],
            "expires_in": seconds,
        }

        self.mock_token_expired = {
            "refresh_token": "refresh",
            "token_type": "Bearer",
            "access_token": "access",
            "expires_at": expired_at,
            "scope": ["useraccount"],
            "expires_in": -seconds,
        }

        self.incident_path = "api/now/table/incident"
        self.mock_incident_number = "INC012345"

        self.mock_token_url = "https://test.service-now.com/oauth_token.do"

        self.client = OAuthClient(instance="test",
                                  client_id="test1",
                                  client_secret="test2")