예제 #1
0
 def username_password_sufficient_direct_request_test(self):
     """Test the username_password_sufficient() helper method - direct request."""
     # run the function with sufficient authentication data
     request = SubscriptionRequest.from_structure(self.PASSWORD_REQUEST)
     self.assertTrue(username_password_sufficient(subscription_request=request))
     # run the function with insufficient authentication data
     request = SubscriptionRequest.from_structure(self.PASSWORD_MISSING_REQUEST)
     self.assertFalse(username_password_sufficient(subscription_request=request))
예제 #2
0
 def username_password_sufficient_not_sufficient_test(self, get_proxy):
     """Test the username_password_sufficient() helper method - not sufficient."""
     subscription_proxy = get_proxy.return_value
     # simulate subscription request
     subscription_proxy.SubscriptionRequest = self.PASSWORD_MISSING_REQUEST
     # run the function
     self.assertFalse(username_password_sufficient())
예제 #3
0
    def _update_register_button_state(self):
        """Update register button state.

        The button is only sensitive if no processing is ongoing
        and we either have enough authentication data to register
        or the system is subscribed, so we can unregister it.
        """
        button_sensitive = False
        if self._registration_controls_enabled:
            # if we are subscribed, we can always unregister
            if self.subscription_attached:
                button_sensitive = True
            # check if credentials are sufficient for registration
            elif self.authentication_method == AuthenticationMethod.USERNAME_PASSWORD:
                button_sensitive = username_password_sufficient(self.subscription_request)
            elif self.authentication_method == AuthenticationMethod.ORG_KEY:
                button_sensitive = org_keys_sufficient(self.subscription_request)
        self._register_button.set_sensitive(button_sensitive)