示例#1
0
    def test_keystone_fid_service_provider_empty(self, mock_relation_ids):
        os.environ['JUJU_UNIT_NAME'] = 'keystone'

        def relation_ids_side_effect(rname):
            return {'keystone-fid-service-provider': {}}[rname]

        mock_relation_ids.side_effect = relation_ids_side_effect
        ctxt = context.KeystoneFIDServiceProviderContext()

        self.maxDiff = None
        self.assertCountEqual(ctxt(), {})
示例#2
0
    def test_keystone_fid_service_provider_no_relations(
            self, mock_relation_ids):
        os.environ['JUJU_UNIT_NAME'] = 'keystone'

        def relation_ids_side_effect(rname):
            return {'keystone-fid-service-provider': {}}[rname]

        mock_relation_ids.side_effect = relation_ids_side_effect
        ctxt = context.KeystoneFIDServiceProviderContext()

        self.maxDiff = None
        self.assertCountEqual(ctxt(), {})

        auth_ctxt = context.AuthMethods()
        self.assertCountEqual(
            auth_ctxt(), {
                'auth_methods':
                'external,password,token,oauth1,openid'
                ',totp,application_credential'
            })
示例#3
0
    def test_keystone_fid_service_provider_rdata(
            self, mock_relation_get, mock_related_units,
            mock_relation_ids):
        os.environ['JUJU_UNIT_NAME'] = 'keystone'

        def relation_ids_side_effect(rname):
            return {
                'keystone-fid-service-provider': {
                    'keystone-fid-service-provider:0',
                    'keystone-fid-service-provider:1',
                    'keystone-fid-service-provider:2'
                }
            }[rname]

        mock_relation_ids.side_effect = relation_ids_side_effect

        def related_units_side_effect(rid):
            return {
                'keystone-fid-service-provider:0': ['sp-mellon/0'],
                'keystone-fid-service-provider:1': ['sp-shib/0'],
                'keystone-fid-service-provider:2': ['sp-oidc/0'],
            }[rid]
        mock_related_units.side_effect = related_units_side_effect

        def relation_get_side_effect(unit, rid):
            # one unit only as the relation is container-scoped
            return {
                "keystone-fid-service-provider:0": {
                    "sp-mellon/0": {
                        "ingress-address": '10.0.0.10',
                        "protocol-name": '"saml2"',
                        "remote-id-attribute": '"MELLON_IDP"',
                    },
                },
                "keystone-fid-service-provider:1": {
                    "sp-shib/0": {
                        "ingress-address": '10.0.0.10',
                        "protocol-name": '"mapped"',
                        "remote-id-attribute": '"Shib-Identity-Provider"',
                    },
                },
                "keystone-fid-service-provider:2": {
                    "sp-oidc/0": {
                        "ingress-address": '10.0.0.10',
                        "protocol-name": '"oidc"',
                        "remote-id-attribute": '"HTTP_OIDC_ISS"',
                    },
                },
            }[rid][unit]

        mock_relation_get.side_effect = relation_get_side_effect
        ctxt = context.KeystoneFIDServiceProviderContext()

        self.maxDiff = None
        self.assertCountEqual(
            ctxt(),
            {
                "fid_sps": [
                    {
                        "protocol-name": "saml2",
                        "remote-id-attribute": "MELLON_IDP",
                    },
                    {
                        "protocol-name": "mapped",
                        "remote-id-attribute": "Shib-Identity-Provider",
                    },
                    {
                        "protocol-name": "oidc",
                        "remote-id-attribute": "HTTP_OIDC_ISS",
                    },
                ]
            }
        )