Example #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()
Example #2
0
    def test_get_structure(self):
        """Test the DBus structure with SecretDataList."""
        data = SecretDataList()

        self.assertEqual(
            SecretDataList.to_structure(data), {
                'type': get_variant(Str, SECRET_TYPE_NONE),
                'value': get_variant(List[Str], [])
            })

        data = SecretDataList.from_structure({
            'type':
            get_variant(Str, SECRET_TYPE_TEXT),
            'value':
            get_variant(List[Str], ["s1", "s2", "s3"])
        })

        self.assertEqual(data.type, SECRET_TYPE_TEXT)
        self.assertEqual(data.value, ["s1", "s2", "s3"])
    def test_get_structure(self):
        """Test the DBus structure with SecretDataList."""
        data = SecretDataList()

        assert SecretDataList.to_structure(data) == \
            {
                'type': get_variant(Str, SECRET_TYPE_NONE),
                'value': get_variant(List[Str], [])
            }

        data = SecretDataList.from_structure({
            'type':
            get_variant(Str, SECRET_TYPE_TEXT),
            'value':
            get_variant(List[Str], ["s1", "s2", "s3"])
        })

        assert data.type == SECRET_TYPE_TEXT
        assert data.value == ["s1", "s2", "s3"]
Example #4
0
    def test_set_secret(self):
        """Test the set_secret method of SecretDataList."""
        data = SecretDataList()
        data.set_secret(["s1", "s2", "s3"])
        self.assertEqual(data.type, SECRET_TYPE_TEXT)
        self.assertEqual(data.value, ["s1", "s2", "s3"])

        data.set_secret(None)
        self.assertEqual(data.type, SECRET_TYPE_NONE)
        self.assertEqual(data.value, [])
    def test_set_secret(self):
        """Test the set_secret method of SecretDataList."""
        data = SecretDataList()
        data.set_secret(["s1", "s2", "s3"])
        assert data.type == SECRET_TYPE_TEXT
        assert data.value == ["s1", "s2", "s3"]

        data.set_secret(None)
        assert data.type == SECRET_TYPE_NONE
        assert data.value == []
Example #6
0
    def test_get_string(self):
        """Test the string representation of SecretDataList."""
        data = SecretDataList()
        expected = "SecretDataList(type='NONE', value_set=False)"
        self.assertEqual(str(data), expected)
        self.assertEqual(repr(data), expected)

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

        data.hide_secret()
        expected = "SecretDataList(type='HIDDEN', value_set=False)"
        self.assertEqual(str(data), expected)
        self.assertEqual(repr(data), expected)
Example #7
0
 def __init__(self):
     self._a = ""
     self._b = SecretData()
     self._c = SecretDataList()
Example #8
0
    def test_hide_secret(self):
        """Test the hide_secret method of SecretDataList."""
        data = SecretDataList()
        data.hide_secret()
        self.assertEqual(data.type, SECRET_TYPE_NONE)
        self.assertEqual(data.value, [])

        data.type = SECRET_TYPE_TEXT
        data.value = ["s1", "s2", "s3"]
        data.hide_secret()
        self.assertEqual(data.type, SECRET_TYPE_HIDDEN)
        self.assertEqual(data.value, [])

        data.type = SECRET_TYPE_HIDDEN
        data.value = ["s1", "s2", "s3"]
        data.hide_secret()
        self.assertEqual(data.type, SECRET_TYPE_HIDDEN)
        self.assertEqual(data.value, [])
    def test_hide_secret(self):
        """Test the hide_secret method of SecretDataList."""
        data = SecretDataList()
        data.hide_secret()
        assert data.type == SECRET_TYPE_NONE
        assert data.value == []

        data.type = SECRET_TYPE_TEXT
        data.value = ["s1", "s2", "s3"]
        data.hide_secret()
        assert data.type == SECRET_TYPE_HIDDEN
        assert data.value == []

        data.type = SECRET_TYPE_HIDDEN
        data.value = ["s1", "s2", "s3"]
        data.hide_secret()
        assert data.type == SECRET_TYPE_HIDDEN
        assert data.value == []