def test_invalid_site(self): """Verify that the view returns a 404 if user_credentials are displayed on a site they are not associated with. """ domain = "unused.testsite" site_configuration = SiteConfigurationFactory( site__domain=domain, ) test_site = site_configuration.site test_program_certificate = factories.ProgramCertificateFactory(site=test_site) test_signatory_1 = factories.SignatoryFactory() test_signatory_2 = factories.SignatoryFactory() test_program_certificate.signatories.add(test_signatory_1, test_signatory_2) test_user_credential = factories.UserCredentialFactory( username=self.MOCK_USER_DATA["username"], credential=test_program_certificate ) response = self.client.get(test_user_credential.get_absolute_url()) self.assertEqual(response.status_code, 404) # Change the program certificate site to the client's site and check that the # response returns the user's certificate. test_program_certificate.site = self.site test_program_certificate.save() response = self._render_user_credential( user_credential=test_user_credential, program_certificate=test_program_certificate ) self.assertEqual(response.status_code, 200)
def setUp(self): super(RenderCredentialPageTests, self).setUp() self.program_certificate = factories.ProgramCertificateFactory(site=self.site) self.signatory_1 = factories.SignatoryFactory() self.signatory_2 = factories.SignatoryFactory() self.program_certificate.signatories.add(self.signatory_1, self.signatory_2) self.user_credential = factories.UserCredentialFactory(credential=self.program_certificate)
def setUp(self): super().setUp() self.program_certificate = factories.ProgramCertificateFactory( site=self.site) self.signatory_1 = factories.SignatoryFactory() self.signatory_2 = factories.SignatoryFactory() self.program_certificate.signatories.add(self.signatory_1, self.signatory_2) self.user_credential = factories.UserCredentialFactory( credential=self.program_certificate) self.platform_name = self.site.siteconfiguration.platform_name
def setUp(self): super().setUp() self.program_certificate = factories.ProgramCertificateFactory(site=self.site) self.signatory_1 = factories.SignatoryFactory() self.signatory_2 = factories.SignatoryFactory() self.program_certificate.signatories.add(self.signatory_1, self.signatory_2) self.user_credential = factories.UserCredentialFactory( username=self.MOCK_USER_DATA['username'], credential=self.program_certificate ) self.platform_name = self.site.siteconfiguration.platform_name user = UserFactory(username=self.MOCK_USER_DATA['username']) self.client.login(username=user.username, password=USER_PASSWORD)
def setUp(self): super().setUp() self.program_certificate = factories.ProgramCertificateFactory(site=self.site) self.signatory_1 = factories.SignatoryFactory() self.signatory_2 = factories.SignatoryFactory() self.program_certificate.signatories.add(self.signatory_1, self.signatory_2) self.user_credential = factories.UserCredentialFactory( username=self.MOCK_USER_DATA["username"], credential=self.program_certificate ) self.visible_date_attr = factories.UserCredentialAttributeFactory( user_credential=self.user_credential, name="visible_date", value="1970-01-01T01:01:01Z", ) self.platform_name = self.site.siteconfiguration.platform_name user = UserFactory(username=self.MOCK_USER_DATA["username"]) self.client.login(username=user.username, password=USER_PASSWORD)