def test_should_raises_401_unauthenticated(self): response = self.client.post( "api/v1/dags/TEST_DAG_ID/dagRuns", json={"dag_run_id": "TEST_DAG_RUN_ID_1", "execution_date": self.default_time,}, ) assert_401(response)
def test_should_raises_401_unauthenticated(self): response = self.client.post( "api/v1/pools", json={"name": "test_pool_a", "slots": 3} ) assert_401(response)
def test_should_raises_401_unauthenticated(self, session): session.add_all(self._create_test_dag_run()) session.commit() response = self.client.delete("api/v1/dags/TEST_DAG_ID/dagRuns/TEST_DAG_RUN_ID_1",) assert_401(response)
def test_should_raises_401_unauthenticated(self): self._create_test_dag_run() response = self.client.post("api/v1/dags/~/dagRuns/list", json={"dag_ids": ["TEST_DAG_ID"]}) assert_401(response)
def test_invalid_auth_header(self, token): with self.app.test_client() as test_client: response = test_client.get("/api/v1/pools", headers={"Authorization": token}) assert response.status_code == 401 assert response.headers["Content-Type"] == "application/problem+json" assert response.headers["WWW-Authenticate"] == "Basic" assert_401(response)
def test_should_raises_401_unauthenticated(self): response = self.client.post("/api/v1/connections", json={ "connection_id": "test-connection-id", "conn_type": 'test_type' }) assert_401(response)
def test_should_raises_401_unauthenticated(self): Variable.set("TEST_VARIABLE_KEY", '{"foo": 1}') response = self.client.get( "/api/v1/variables/TEST_VARIABLE_KEY" ) assert_401(response)
def test_should_raises_401_unauthenticated(self, session): self._create_connection(session) response = self.client.patch( "/api/v1/connections/test-connection-id", json={"connection_id": "test-connection-id", "conn_type": 'test_type', "extra": "{'key': 'var'}"}, ) assert_401(response)
def test_should_raises_401_unauthenticated(self): dag_model = self._create_dag_model() response = self.client.patch( f"/api/v1/dags/{dag_model.dag_id}", json={ "is_paused": False, }, ) assert_401(response)
def test_should_raises_401_unauthenticated(self): Variable.set("delete_var1", 1) # make sure variable is added response = self.client.delete("/api/v1/variables/delete_var1") assert_401(response) # make sure variable is not deleted response = self.client.get("/api/v1/variables/delete_var1", environ_overrides={'REMOTE_USER': "******"}) assert response.status_code == 200
def test_should_raises_401_unauthenticated(self, session): pool = Pool(pool="test_pool", slots=2) session.add(pool) session.commit() response = self.client.patch( "api/v1/pools/test_pool", json={"name": "test_pool_a", "slots": 3}, ) assert_401(response)
def test_should_raises_401_unauthenticated(self): response = self.client.post( "/api/v1/variables", json={ "key": "var_create", "value": "{}", }, ) assert_401(response)
def test_should_raises_401_unauthenticated(self): key = self.app.config["SECRET_KEY"] serializer = URLSafeSerializer(key) token = serializer.dumps({"download_logs": False}) response = self.client.get( f"api/v1/dags/{self.DAG_ID}/dagRuns/TEST_DAG_RUN_ID/" f"taskInstances/{self.TASK_ID}/logs/1?token={token}", headers={'Accept': 'application/json'}, ) assert_401(response)
def test_should_raises_401_unauthenticated(self): response = self.client.post( "/api/v1/dags/example_python_operator/clearTaskInstances", json={ "dry_run": False, "reset_dag_runs": True, "only_failed": False, "only_running": True, "include_subdags": True, }, ) assert_401(response)
def test_should_raises_401_unauthenticated(self): serializer = URLSafeSerializer(conf.get('webserver', 'SECRET_KEY')) dagbag = DagBag(dag_folder=EXAMPLE_DAG_FILE) dagbag.sync_to_db() first_dag: DAG = next(iter(dagbag.dags.values())) response = self.client.get( f"/api/v1/dagSources/{serializer.dumps(first_dag.fileloc)}", headers={"Accept": "text/plain"}, ) assert_401(response)
def test_should_raises_401_unauthenticated(self, session): import_error = ImportError( filename="Lorem_ipsum.py", stacktrace="Lorem ipsum", timestamp=timezone.parse(self.timestamp, timezone="UTC"), ) session.add(import_error) session.commit() response = self.client.get(f"/api/v1/importErrors/{import_error.id}") assert_401(response)
def test_should_raises_401_unauthenticated(self): Variable.set("var1", "foo") response = self.client.patch( "/api/v1/variables/var1", json={ "key": "var1", "value": "updated", }, ) assert_401(response)
def test_should_raises_401_unauthenticated(self, session): log_model = Log( event='TEST_EVENT', task_instance=self._create_task_instance(), ) log_model.dttm = timezone.parse(self.default_time) session.add(log_model) session.commit() event_log_id = log_model.id response = self.client.get(f"/api/v1/eventLogs/{event_log_id}") assert_401(response)
def test_should_raises_401_unauthenticated(self): dag_id = 'test-dag-id' task_id = 'test-task-id' execution_date = '2005-04-02T00:00:00+00:00' execution_date_parsed = parse_execution_date(execution_date) dag_run_id = DR.generate_run_id(DagRunType.MANUAL, execution_date_parsed) self._create_xcom_entries(dag_id, dag_run_id, execution_date_parsed, task_id) response = self.client.get( f"/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/xcomEntries" ) assert_401(response)
def test_should_raises_401_unauthenticated(self, session): pool_name = "test_pool" pool_instance = Pool(pool=pool_name, slots=3) session.add(pool_instance) session.commit() response = self.client.delete(f"api/v1/pools/{pool_name}") assert_401(response) # Should still exists response = self.client.get(f"/api/v1/pools/{pool_name}", environ_overrides={'REMOTE_USER': "******"}) assert response.status_code == 200
def test_should_raises_401_unauthenticated(self): response = self.client.post( "/api/v1/dags/example_python_operator/updateTaskInstancesState", json={ "dry_run": True, "task_id": "print_the_context", "execution_date": DEFAULT_DATETIME_1, "include_upstream": True, "include_downstream": True, "include_future": True, "include_past": True, "new_state": "failed", }, ) assert_401(response)
def test_should_raises_401_unauthenticated(self, session): dagrun_model = DagRun( dag_id="TEST_DAG_ID", run_id="TEST_DAG_RUN_ID", run_type=DagRunType.MANUAL, execution_date=timezone.parse(self.default_time), start_date=timezone.parse(self.default_time), external_trigger=True, ) session.add(dagrun_model) session.commit() response = self.client.get("api/v1/dags/TEST_DAG_ID/dagRuns/TEST_DAG_RUN_ID") assert_401(response)
def test_should_raises_401_unauthenticated(self, session): log_model_1 = Log( event='TEST_EVENT_1', task_instance=self._create_task_instance(), ) log_model_2 = Log( event='TEST_EVENT_2', task_instance=self._create_task_instance(), ) log_model_1.dttm = timezone.parse(self.default_time) log_model_2.dttm = timezone.parse(self.default_time_2) session.add_all([log_model_1, log_model_2]) session.commit() response = self.client.get("/api/v1/eventLogs") assert_401(response)
def test_should_raises_401_unauthenticated(self): response = self.client.post( "/api/v1/roles", json={ 'name': 'Test2', 'actions': [{ 'resource': { 'name': 'Connections' }, 'action': { 'name': 'can_create' } }], }, ) assert_401(response)
def test_should_raises_401_unauthenticated(self): response = self.client.patch( "/api/v1/roles/test", json={ "name": "mytest2", "actions": [{ "resource": { "name": "Connections" }, "action": { "name": "can_create" } }], }, ) assert_401(response)
def test_should_raises_401_unauthenticated(self): Variable.set("var1", 1) response = self.client.get("/api/v1/variables?limit=2&offset=0") assert_401(response)
def test_should_raises_401_unauthenticated(self): self._create_test_dag_run() response = self.client.get("api/v1/dags/TEST_DAG_ID/dagRuns") assert_401(response)
def test_should_raises_401_unauthenticated(self): response = self.client.get("api/v1/dags") assert_401(response)
def test_should_raises_401_unauthenticated(self): response = self.client.get(f"/api/v1/dags/{self.dag_id}/details") assert_401(response)
def test_should_raises_401_unauthenticated(self): self._create_dag_models(1) response = self.client.get("/api/v1/dags/TEST_DAG_1") assert_401(response)