Exemplo n.º 1
0
  def test_login_with_wrong_ggrc_user(self, bad_header):
    """Test 'X-ggrc-user' header validation"""
    ext_api = external_api_helper.ExternalApiClient()
    ext_api.user_headers = {
        "X-ggrc-user": bad_header
    }

    response = ext_api.post(
        all_models.System,
        data={"system": {
            "title": "new_system",
            "context": None,
        }}
    )
    self.assertEqual(400, response.status_code)
Exemplo n.º 2
0
  def test_login_by_sync_service_with_on_behalf(self):
    """Test login app to app login with on behalf user header"""
    ext_api = external_api_helper.ExternalApiClient()
    ext_api.user_headers = {
        "X-external-user":
        json.dumps({
            "email": "*****@*****.**",
            "user": "******",
        })
    }

    response = ext_api.post(
        all_models.System,
        data={"system": {
            "title": "new_system",
            "context": None,
        }}
    )

    self.assertEqual(201, response.status_code)
    system_id = response.json["system"]["id"]
    system = all_models.System.query.get(system_id)
    self.assertEqual(system.modified_by.email, "*****@*****.**")

    # because of INTEGRATION_SERVICE_URL=mock, we do not have real username
    self.assertEqual(system.modified_by.name, "*****@*****.**")

    service_user = all_models.Person.query.filter_by(
        email="*****@*****.**"
    ).one()
    self.assertIsNone(service_user.modified_by)

    created_person = all_models.Person.query.filter_by(
        email="*****@*****.**"
    ).one()
    self.assertEquals(service_user.id, created_person.modified_by_id)

    system_revision = all_models.Revision.query.filter_by(
        resource_type="System", resource_id=system_id
    ).one()
    self.assertEqual(system_revision.modified_by.email, "*****@*****.**")
    self.assertEqual(system_revision.modified_by.name, "*****@*****.**")
Exemplo n.º 3
0
  def test_login_by_external_app(self):
    """Test login app to app login (external app)"""
    ext_api = external_api_helper.ExternalApiClient(
        use_ggrcq_service_account=True
    )
    response = ext_api.post(
        all_models.System,
        data={"system": {
            "title": "new_system",
            "context": None,
        }}
    )

    self.assertEqual(201, response.status_code)
    system_id = response.json["system"]["id"]
    system_revision = all_models.Revision.query.filter_by(
        resource_type="System", resource_id=system_id
    ).one()
    self.assertEqual(system_revision.modified_by.email, "*****@*****.**")
    self.assertEqual(system_revision.modified_by.name, "ext_app")
Exemplo n.º 4
0
 def setUp(self):
     """Test setup method."""
     super(TestSoxSystem, self).setUp()
     self.ext_api = external_api_helper.ExternalApiClient()
Exemplo n.º 5
0
 def setUp(self):
   super(TestECADResponse, self).setUp()
   self.ext_api = external_api_helper.ExternalApiClient()
   self.client.get("/login")
Exemplo n.º 6
0
 def setUp(self):
   super(TestExtSnapshotting, self).setUp()
   self.ext_api = external_api_helper.ExternalApiClient()
   self.client.get("/login")
Exemplo n.º 7
0
 def setUpClass(cls):
   cls.api = external_api_helper.ExternalApiClient()
Exemplo n.º 8
0
 def setUp(self):
   super(TestExportRisk, self).setUp()
   self.ext_api = external_api_helper.ExternalApiClient()
   self.client.get("/login")