'Test the SAML generator produces a SAML object.
Test the SAML generator directly by passing known arguments, the result
should be a SAML object that consistently includes attributes based on
the known arguments that were passed in.'

def test_samlize_token_values(self):

    with mock.patch.object(keystone_idp, '_sign_assertion', return_value=self.signed_assertion):
        generator = keystone_idp.SAMLGenerator()
        response = generator.samlize_token(self.ISSUER, self.RECIPIENT, self.SUBJECT, self.SUBJECT_DOMAIN, self.ROLES, self.PROJECT, self.PROJECT_DOMAIN)
    assertion = response.assertion
    self.assertIsNotNone(assertion)
    self.assertIsInstance(assertion, saml.Assertion)
    issuer = response.issuer
    self.assertEqual(self.RECIPIENT, response.destination)
    self.assertEqual(self.ISSUER, issuer.text)
    user_attribute = assertion.attribute_statement[0].attribute[0]
    self.assertEqual(self.SUBJECT, user_attribute.attribute_value[0].text)
    user_domain_attribute = assertion.attribute_statement[0].attribute[1]
    self.assertEqual(self.SUBJECT_DOMAIN, user_domain_attribute.attribute_value[0].text)
    role_attribute = assertion.attribute_statement[0].attribute[2]
    for attribute_value in role_attribute.attribute_value:
        self.assertIn(attribute_value.text, self.ROLES)
    project_attribute = assertion.attribute_statement[0].attribute[3]
    self.assertEqual(self.PROJECT, project_attribute.attribute_value[0].text)
    project_domain_attribute = assertion.attribute_statement[0].attribute[4]
    self.assertEqual(self.PROJECT_DOMAIN, project_domain_attribute.attribute_value[0].text)
