Ejemplo n.º 1
0
 def __init__(self):
     # subscription request type
     # (based on authentication method used)
     self._type = DEFAULT_SUBSCRIPTION_REQUEST_TYPE
     # user identification
     # - in case an account is member
     #   of multiple organizations, both
     #   organization and account username
     #   need to be set
     self._organization = ""
     self._redhat_account_username = ""
     # Candlepin instance
     self._server_hostname = ""
     # CDN base url
     self._rhsm_baseurl = ""
     # RHSM HTTP proxy
     self._server_proxy_hostname = ""
     self._server_proxy_port = -1
     self._server_proxy_user = ""
     # private data
     # - we are using SecretData & SecretDataList
     #   nested DBus structures to protect this
     #   sensitive data
     # - this way they can be set-only & easily
     #   removed from SubscriptionRequest on
     #   output from the Subscription module
     # - they also support a robust way of clearing
     #   previously set sensitive data if required
     self._redhat_account_password = SecretData()
     self._activation_keys = SecretDataList()
     self._server_proxy_password = SecretData()
Ejemplo n.º 2
0
    def test_get_structure(self):
        """Test the DBus structure with SecretData."""
        data = SecretData()

        self.assertEqual(
            SecretData.to_structure(data), {
                'type': get_variant(Str, SECRET_TYPE_NONE),
                'value': get_variant(Str, "")
            })

        data = SecretData.from_structure({
            'type':
            get_variant(Str, SECRET_TYPE_TEXT),
            'value':
            get_variant(Str, "secret")
        })

        self.assertEqual(data.type, SECRET_TYPE_TEXT)
        self.assertEqual(data.value, "secret")
Ejemplo n.º 3
0
    def test_get_structure(self):
        """Test the DBus structure with SecretData."""
        data = SecretData()

        assert SecretData.to_structure(data) == \
            {
                'type': get_variant(Str, SECRET_TYPE_NONE),
                'value': get_variant(Str, "")
            }

        data = SecretData.from_structure({
            'type':
            get_variant(Str, SECRET_TYPE_TEXT),
            'value':
            get_variant(Str, "secret")
        })

        assert data.type == SECRET_TYPE_TEXT
        assert data.value == "secret"
Ejemplo n.º 4
0
    def test_set_secret(self):
        """Test the set_secret method of SecretData."""
        data = SecretData()
        data.set_secret("secret")
        self.assertEqual(data.type, SECRET_TYPE_TEXT)
        self.assertEqual(data.value, "secret")

        data.set_secret(None)
        self.assertEqual(data.type, SECRET_TYPE_NONE)
        self.assertEqual(data.value, "")
Ejemplo n.º 5
0
    def test_set_secret(self):
        """Test the set_secret method of SecretData."""
        data = SecretData()
        data.set_secret("secret")
        assert data.type == SECRET_TYPE_TEXT
        assert data.value == "secret"

        data.set_secret(None)
        assert data.type == SECRET_TYPE_NONE
        assert data.value == ""
Ejemplo n.º 6
0
    def test_get_string(self):
        """Test the string representation of SecretData."""
        data = SecretData()
        expected = "SecretData(type='NONE', value_set=False)"
        self.assertEqual(str(data), expected)
        self.assertEqual(repr(data), expected)

        data.set_secret("secret")
        expected = "SecretData(type='TEXT', value_set=True)"
        self.assertEqual(str(data), expected)
        self.assertEqual(repr(data), expected)

        data.hide_secret()
        expected = "SecretData(type='HIDDEN', value_set=False)"
        self.assertEqual(str(data), expected)
        self.assertEqual(repr(data), expected)
Ejemplo n.º 7
0
    def test_hide_secret(self):
        """Test the hide_secret method of SecretData."""
        data = SecretData()
        data.hide_secret()
        self.assertEqual(data.type, SECRET_TYPE_NONE)
        self.assertEqual(data.value, "")

        data.type = SECRET_TYPE_TEXT
        data.value = "secret"
        data.hide_secret()
        self.assertEqual(data.type, SECRET_TYPE_HIDDEN)
        self.assertEqual(data.value, "")

        data.type = SECRET_TYPE_HIDDEN
        data.value = "secret"
        data.hide_secret()
        self.assertEqual(data.type, SECRET_TYPE_HIDDEN)
        self.assertEqual(data.value, "")
Ejemplo n.º 8
0
 def __init__(self):
     self._a = ""
     self._b = SecretData()
     self._c = SecretDataList()
Ejemplo n.º 9
0
    def test_hide_secret(self):
        """Test the hide_secret method of SecretData."""
        data = SecretData()
        data.hide_secret()
        assert data.type == SECRET_TYPE_NONE
        assert data.value == ""

        data.type = SECRET_TYPE_TEXT
        data.value = "secret"
        data.hide_secret()
        assert data.type == SECRET_TYPE_HIDDEN
        assert data.value == ""

        data.type = SECRET_TYPE_HIDDEN
        data.value = "secret"
        data.hide_secret()
        assert data.type == SECRET_TYPE_HIDDEN
        assert data.value == ""