Beispiel #1
0
    def setUp(self):
        super(CreditProviderCallbackViewTests, self).setUp()  # lint-amnesty, pylint: disable=super-with-arguments

        # Authentication should NOT be required for this endpoint.
        self.client.logout()

        self.provider = CreditProviderFactory()
        self.path = reverse('credit:provider_callback', args=[self.provider.provider_id])
        self.eligibility = CreditEligibilityFactory(username=self.user.username)
Beispiel #2
0
    def setUp(self):
        super().setUp()

        # Authentication should NOT be required for this endpoint.
        self.client.logout()

        self.provider = CreditProviderFactory()
        self.path = reverse('credit:provider_callback',
                            args=[self.provider.provider_id])
        self.eligibility = CreditEligibilityFactory(
            username=self.user.username)
Beispiel #3
0
    def test_compare_signatures_string_key(self):
        """ Verify compare_signature errors if string key does not match. """
        provider = CreditProviderFactory(
            provider_id='asu',
            active=False,
        )

        # Create a serializer that has a signature which was created with a key
        # that we do not have in our system.
        sig = signature.signature({}, 'iamthewrongkey')
        serializer = serializers.CreditProviderCallbackSerializer(
            data={'signature': sig})
        with pytest.raises(PermissionDenied):
            # The first arg here is key we have (that doesn't match the sig)
            serializer._compare_signatures('abcd1234', provider.provider_id)  # lint-amnesty, pylint: disable=protected-access
Beispiel #4
0
 def test_data(self):
     """ Verify the correct fields are serialized. """
     provider = CreditProviderFactory(active=False)
     serializer = serializers.CreditProviderSerializer(provider)
     expected = {
         'id': provider.provider_id,
         'display_name': provider.display_name,
         'url': provider.provider_url,
         'status_url': provider.provider_status_url,
         'description': provider.provider_description,
         'enable_integration': provider.enable_integration,
         'fulfillment_instructions': provider.fulfillment_instructions,
         'thumbnail_url': provider.thumbnail_url,
     }
     self.assertDictEqual(serializer.data, expected)
Beispiel #5
0
    def test_compare_signatures_list_key(self):
        """
        Verify compare_signature errors if no keys that are stored in the list
        in config match the key handed in the signature.
        """
        provider = CreditProviderFactory(
            provider_id='asu',
            active=False,
        )

        sig = signature.signature({}, 'iamthewrongkey')
        serializer = serializers.CreditProviderCallbackSerializer(
            data={'signature': sig})

        with pytest.raises(PermissionDenied):
            # The first arg here is the list of keys he have (that dont matcht the sig)
            serializer._compare_signatures(  # lint-amnesty, pylint: disable=protected-access
                ['abcd1234', 'xyz789'], provider.provider_id)
Beispiel #6
0
 def setUpClass(cls):
     super(CreditProviderRequestCreateViewTests, cls).setUpClass()
     cls.provider = CreditProviderFactory()
Beispiel #7
0
 def setUpClass(cls):
     super(CreditProviderViewSetTests, cls).setUpClass()
     cls.bayside = CreditProviderFactory(provider_id='bayside')
     cls.hogwarts = CreditProviderFactory(provider_id='hogwarts')
     cls.starfleet = CreditProviderFactory(provider_id='starfleet')
Beispiel #8
0
 def setUpClass(cls):
     super().setUpClass()
     cls.provider = CreditProviderFactory()