From nobody Fri Apr 26 15:47:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1530281205929648.5007571513372; Fri, 29 Jun 2018 07:06:45 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6ADD33082287; Fri, 29 Jun 2018 14:06:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 509D9308BDB6; Fri, 29 Jun 2018 14:06:45 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 419A74A465; Fri, 29 Jun 2018 14:06:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5TE6Zem023769 for ; Fri, 29 Jun 2018 10:06:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1689792302; Fri, 29 Jun 2018 14:06:35 +0000 (UTC) Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0670318768 for ; Fri, 29 Jun 2018 14:06:30 +0000 (UTC) Received: from mail-pl0-f54.google.com (mail-pl0-f54.google.com [209.85.160.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DBB3F30001DC for ; Fri, 29 Jun 2018 14:06:19 +0000 (UTC) Received: by mail-pl0-f54.google.com with SMTP id z9-v6so4524107plo.1 for ; Fri, 29 Jun 2018 07:06:19 -0700 (PDT) Received: from localhost.localdomain ([112.196.135.81]) by smtp.gmail.com with ESMTPSA id 14-v6sm20208806pgc.63.2018.06.29.07.06.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Jun 2018 07:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rAHfLCpvGqL4zYjWK5jVRgQcn5p4rTTtT2ZX+B8Q+Tk=; b=TPcSfZC5Wj7D8QDqVsJXdDAt+V33DWzmNql+BNclfLnaT8Ks4HuAqyHKlLt+dpacdt D9oFdryGkyGNp9StG69WR8syCCwiS/tPzaVySv3jrz1gdUybv+2/x7apMa85+gksmL0P 5jOR8sivRpBgFkmTb6D2m30rC/ejmpObIVa3lZgPwhlNuYPNY8UlacmzFrR5TfAtpYkW ye9BUvUS3SyOj4bKmXlPgYeZ887hw4F0v1VSn03o6AniS4ZV+GDLIVpyu6Kwo+XbROeH eThfSLURVArGAu9Ls11b1HxjGAZ4kJdJcKkd7uXCxRkqSq2yb9Pa9xdD8sVdHGh3P07V RVIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rAHfLCpvGqL4zYjWK5jVRgQcn5p4rTTtT2ZX+B8Q+Tk=; b=QczC7VftEnn+rOOt9qcKkH3xnSKPgWWZI94382aX0ym2dwsCACf2byOsQyBhYa1wHs cTqGW0h7NPYo6m5sVRWDayXG/aLt2iysW3NjGKcAeR/Xv99HI2WbJhrNcXjOI1k9JJC/ v0bgvNFcmmWXdMzFuu+ksoAIjoNpS8tnXRY/bOfqNBun7QjGB8iHyDi1dV4HyiPPuWie JuREUdMg6EKIt4n0k31TrVncFHXdey7J6pv509ufbTm9EiWGASGUdLd6Ljc6sXZTYnSM 1aiaA7BpxF/J6NUwRAC0F/iFN7v0mdXNPgo4ZDoJRK6hx+cis59kYAAei7m4aPHeRsBh Ne4Q== X-Gm-Message-State: APt69E1bBA8CRi68VwbqiAmJ8LmfMms7BC5w+FKjsiQR3cFqllFjDQP2 LBCQbRQU3aQApPYW0I2GkissuA== X-Google-Smtp-Source: ADUXVKK0Z8zn6IeMEnuomkpU3D9Jm0vQKeRHruDPzi0U70J5O4yD0JIPHqq9Do7HKRXjGZkiK1Mv7w== X-Received: by 2002:a17:902:9b82:: with SMTP id y2-v6mr15174513plp.69.1530281178904; Fri, 29 Jun 2018 07:06:18 -0700 (PDT) From: Shubham Jain To: patchew-devel@redhat.com Date: Fri, 29 Jun 2018 19:35:49 +0530 Message-Id: <20180629140551.99829-2-shubhamjain7495@gmail.com> In-Reply-To: <20180629140551.99829-1-shubhamjain7495@gmail.com> References: <20180629140551.99829-1-shubhamjain7495@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 29 Jun 2018 14:06:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 29 Jun 2018 14:06:20 +0000 (UTC) for IP:'209.85.160.54' DOMAIN:'mail-pl0-f54.google.com' HELO:'mail-pl0-f54.google.com' FROM:'shubhamjain7495@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.55 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.160.54 mail-pl0-f54.google.com 209.85.160.54 mail-pl0-f54.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH v2 1/3] Make Patchew cli use rest api X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 29 Jun 2018 14:06:45 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" -Make ProjectCommand use rest_api_do instead of api_do --- api/rest.py | 3 ++- patchew-cli | 34 +++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/api/rest.py b/api/rest.py index 66644ba..39bdda0 100644 --- a/api/rest.py +++ b/api/rest.py @@ -31,7 +31,7 @@ class CsrfExemptSessionAuthentication(SessionAuthenticati= on): =20 def enforce_csrf(self, request): return # To not perform the csrf check previously happening - =20 + SEARCH_PARAM =3D 'q' =20 # patchew-specific permission classes @@ -146,6 +146,7 @@ class ProjectsViewSet(viewsets.ModelViewSet): queryset =3D Project.objects.all().order_by('id') serializer_class =3D ProjectSerializer permission_classes =3D (PatchewPermission,) + authentication_classes =3D (CsrfExemptSessionAuthentication, ) =20 @action(methods=3D['post'], detail=3DTrue, permission_classes=3D[Impor= tPermission]) def update_project_head(self, request, pk=3DNone): diff --git a/patchew-cli b/patchew-cli index e510e74..8425db2 100755 --- a/patchew-cli +++ b/patchew-cli @@ -255,11 +255,11 @@ class ProjectCommand(SubCommand): parser.add_argument("--verbose", "-v", action=3D"store_true", help=3D"Show details about projects") args =3D parser.parse_args(argv) - r =3D self.api_do("get-projects") + r =3D self.rest_api_do(url_cmd=3D"projects", request_method=3D'get= ') if args.raw: print(json.dumps(r, indent=3D2, separators=3D",:")) return 0 - for p in r: + for p in r['results']: print(p["name"]) if args.verbose: for k, v in p.items(): @@ -273,8 +273,8 @@ class ProjectCommand(SubCommand): parser.add_argument("name", nargs=3D"+", help=3D"The name of project to show info") args =3D parser.parse_args(argv) - r =3D self.api_do("get-projects") - for p in r: + r =3D self.rest_api_do(url_cmd=3D"projects", request_method=3D'get= ') + for p in r['results']: if not p["name"] in args.name: continue if len(args.name) > 1: @@ -297,12 +297,15 @@ class ProjectCommand(SubCommand): parser.add_argument("--desc", "-d", default=3D"", help=3D"Project short discription") args =3D parser.parse_args(argv) - self.api_do("add-project", - name=3Dargs.name, - mailing_list=3Dargs.mailing_list, - url=3Dargs.url, - git=3Dargs.git, - description=3Dargs.desc) + data =3D {'name':args.name, + 'mailing_list':args.mailing_list, + 'url':args.url, + 'git':args.git, + 'description':args.desc} + self.rest_api_do(url_cmd=3D"projects", + request_method=3D'post', + content_type=3D'application/json', + data=3Djson.dumps(data)) =20 def update_one_project(self, wd, project): logging.info("Updating project '%s'", project["name"]) @@ -354,16 +357,17 @@ class ProjectCommand(SubCommand): except Exception as e: logging.warn("Failed to push the new head to patchew mirro= r: %s", str(e)) - self.api_do("update-project-head", project=3Dproject["name"], - old_head=3Dold_head, - new_head=3Dnew_head, - message_ids=3Dmsgids) + url =3D project['resource_uri'] + "/update_project_head/" + self.rest_api_do(url, old_head=3Dold_head, + new_head=3Dnew_head, + message_ids=3Dmsgids) =20 def update_project(self, argv): parser =3D argparse.ArgumentParser() parser.add_argument("--name", "-n", help=3D"Name of the project") args =3D parser.parse_args(argv) - projects =3D self.api_do("get-projects", name=3Dargs.name) + projects =3D self.rest_api_do("projects") + projects =3D [p for p in projects['results'] if p['name'] =3D=3D a= rgs.name] wd =3D tempfile.mkdtemp() logging.debug("TMPDIR: %s", wd) try: --=20 2.15.1 (Apple Git-101) _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Fri Apr 26 15:47:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1530281215181943.7888003397019; Fri, 29 Jun 2018 07:06:55 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8D92B3078ACA; Fri, 29 Jun 2018 14:06:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7889930012D0; Fri, 29 Jun 2018 14:06:54 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 650B118037EC; Fri, 29 Jun 2018 14:06:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5TE6ri6023782 for ; Fri, 29 Jun 2018 10:06:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9563C308BDB8; Fri, 29 Jun 2018 14:06:53 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C975308BDB6 for ; Fri, 29 Jun 2018 14:06:48 +0000 (UTC) Received: from mail-pl0-f51.google.com (mail-pl0-f51.google.com [209.85.160.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A6A56883BC for ; Fri, 29 Jun 2018 14:06:37 +0000 (UTC) Received: by mail-pl0-f51.google.com with SMTP id 6-v6so4530359plb.0 for ; Fri, 29 Jun 2018 07:06:37 -0700 (PDT) Received: from localhost.localdomain ([112.196.135.81]) by smtp.gmail.com with ESMTPSA id 14-v6sm20208806pgc.63.2018.06.29.07.06.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Jun 2018 07:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZwSbGPVvtkgF9IsZvRpH78mntKxfsMe0LGPTy9lkFiU=; b=r1q8S8wxOuwdSRu+CZj4LBMTRZJrFHg9Y4v7nf/TSkfe8fijFSYiXv8CAO1GSHafbD vkATyWRvSMaGz5fVVs6OhE9+oaWwcfM4Oka45ZEFKYMAH9wofMLLMS08Ybu1Wu5HAwid aJDk7AvN1Jgc/2nJQFst7rXrcXhwmtzmJ4Yooq+7TjkNcWOZaE7XagF4WtdSinLXvlhN rU/dLAB8H2D+MI11omEz5KuR91G3C8vIMCBUfeGluuWE0c1lxrOYeQg94GIR4iY8OujI vTUveZ6OqYQ3xNZKnXN9Twb0n82TQzv29zxXiOYlXWrjFuRA9pw94VVv1K5NYwFbz4nC hTKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZwSbGPVvtkgF9IsZvRpH78mntKxfsMe0LGPTy9lkFiU=; b=Uxo5PGMqgEyII4ijVkgFGdCjHXKt5id5BHFQhFFVDrZ1CHeTwQfNXJHbN9aj09WWB/ Iv4FuwMwSalUlmVLARjbsr8Lk2XjfxCZB7SvL4sVWOGF8aweZIwrWuQSGCI3HyP8+ydm mJwtcAwNA+isyFBmNc3dL47nHm8w5l6SgBKFRebjEvbVIUji5vt8kxRHwG8YYTLcC68U /n2rN8+qCMHtyCUu+4FyQ7G/8/HzOa/zKeUsnsPSEgC6VB8pm6CpLkFitjz7PdHh2LiD mjJgSH1SF9t8QjoOtC1Dpx/SWAFRLei4Hdn9WPvjGiH5Fm4UscRZm5qv0umcnqHECERZ jZWQ== X-Gm-Message-State: APt69E1TRjYa046IpQiB3iYIw9RFjG3BuNSRzUgaDS3ImSy87Sic9xaS ZffcYy5dGXb18p1JmuCiJy4uAw== X-Google-Smtp-Source: ADUXVKINOFUGnJbRuk6VmFe+deX5dX0jdODzIainfwtV1FG/C0S+S1j6u4Yjsk1Z3uylFz611Ho03Q== X-Received: by 2002:a17:902:2983:: with SMTP id h3-v6mr15108641plb.232.1530281196639; Fri, 29 Jun 2018 07:06:36 -0700 (PDT) From: Shubham Jain To: patchew-devel@redhat.com Date: Fri, 29 Jun 2018 19:35:50 +0530 Message-Id: <20180629140551.99829-3-shubhamjain7495@gmail.com> In-Reply-To: <20180629140551.99829-1-shubhamjain7495@gmail.com> References: <20180629140551.99829-1-shubhamjain7495@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 29 Jun 2018 14:06:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 29 Jun 2018 14:06:37 +0000 (UTC) for IP:'209.85.160.51' DOMAIN:'mail-pl0-f51.google.com' HELO:'mail-pl0-f51.google.com' FROM:'shubhamjain7495@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.531 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS, T_DKIM_INVALID) 209.85.160.51 mail-pl0-f51.google.com 209.85.160.51 mail-pl0-f51.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH v2 2/3] Make Delete Command use REST X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 29 Jun 2018 14:06:54 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Make patchew-cli's delete use REST api and added the missing test for delete --- api/rest.py | 2 ++ patchew-cli | 15 ++++++++++++++- tests/patchewtest.py | 3 +++ tests/test_message.py | 17 +++++++++++++++-- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/api/rest.py b/api/rest.py index 39bdda0..9b47f37 100644 --- a/api/rest.py +++ b/api/rest.py @@ -320,6 +320,8 @@ class SeriesViewSet(BaseMessageViewSet): =20 class ProjectSeriesViewSet(ProjectMessagesViewSetMixin, SeriesViewSet, mixins.DestroyModelMixin): + authentication_classes =3D (CsrfExemptSessionAuthentication, ) + def collect_patches(self, series): if series.is_patch: patches =3D [series] diff --git a/patchew-cli b/patchew-cli index 8425db2..f90f3c5 100755 --- a/patchew-cli +++ b/patchew-cli @@ -181,7 +181,20 @@ class DeleteCommand(SubCommand): if not argv and not args.all: print("Must specify --all to delete all patches") return 1 - self.api_do("delete", terms=3Dargv) + series_list =3D [] + if args.all:=20 + resp =3D self.rest_api_do("projects") + for project in len(resp['result']): + url =3D project['series'] + series_resp =3D self.rest_api_do(url) + series_list =3D series_list + series_resp['results'] + else: + for term in argv: + series_resp =3D self.rest_api_do("series/?q%s"%term) + series_list =3D series_list + series_resp['results'] + for series in series_list: =20 + url =3D series['resource_uri'] + self.rest_api_do(url,request_method=3D'delete') return 0 =20 class ImportCommand(SubCommand): diff --git a/tests/patchewtest.py b/tests/patchewtest.py index 5bed3b9..847b3f9 100644 --- a/tests/patchewtest.py +++ b/tests/patchewtest.py @@ -100,6 +100,9 @@ class PatchewTestCase(django.test.LiveServerTestCase): def cli_import(self, mbox, rc=3D0): self.check_cli(["import", self.get_data_path(mbox)], rc) =20 + def cli_delete(self, terms, rc=3D0): + self.check_cli(["delete", terms], rc) + def get_data_path(self, fname): r =3D tempfile.NamedTemporaryFile(dir=3DRUN_DIR, prefix=3D"test-da= ta-", delete=3DFalse) d =3D os.path.join(BASE_DIR, "tests", "data", fname) diff --git a/tests/test_message.py b/tests/test_message.py index 9448aee..0b47b37 100755 --- a/tests/test_message.py +++ b/tests/test_message.py @@ -10,7 +10,8 @@ =20 import time import datetime -from tests.patchewtest import PatchewTestCase, main +import json +from patchewtest import PatchewTestCase, main =20 class ProjectTest(PatchewTestCase): =20 @@ -54,5 +55,17 @@ class ProjectTest(PatchewTestCase): asctime =3D message.get_asctime() self.assertEqual(asctime, "Sat Oct 22 9:06:04 2016") =20 + def test_delete(self): + self.cli_login() + self.add_project("QEMU", "qemu-devel@nongnu.org") + self.cli_import("0002-unusual-cased-tags.mbox.gz") + a, b =3D self.check_cli(["search", "-r", "-o", "subject,properties= "]) + ao =3D json.loads(a)[0] + self.assertEqual(["Fam Zheng", "famz@redhat.com"], + ao["properties"]["reviewers"][0]) + self.cli_delete("from:Fam") + a, b =3D self.check_cli(["search", "-r", "-o", "subject,properties= "]) + self.assertEqual("",a) + if __name__ =3D=3D '__main__': - main() + main() \ No newline at end of file --=20 2.15.1 (Apple Git-101) _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Fri Apr 26 15:47:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1530281233090747.1796792573122; Fri, 29 Jun 2018 07:07:13 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 92C3C30001E9; Fri, 29 Jun 2018 14:07:12 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7ED5317111; Fri, 29 Jun 2018 14:07:12 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6AAF118037F0; Fri, 29 Jun 2018 14:07:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5TE6w2a023794 for ; Fri, 29 Jun 2018 10:06:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4896D18362; Fri, 29 Jun 2018 14:06:58 +0000 (UTC) Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3F2CF17111 for ; Fri, 29 Jun 2018 14:06:54 +0000 (UTC) Received: from mail-pg0-f41.google.com (mail-pg0-f41.google.com [74.125.83.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 34953300197B for ; Fri, 29 Jun 2018 14:06:43 +0000 (UTC) Received: by mail-pg0-f41.google.com with SMTP id c9-v6so4056745pgf.5 for ; Fri, 29 Jun 2018 07:06:43 -0700 (PDT) Received: from localhost.localdomain ([112.196.135.81]) by smtp.gmail.com with ESMTPSA id 14-v6sm20208806pgc.63.2018.06.29.07.06.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Jun 2018 07:06:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tR7zFyrnt9dYnjSZfpnAD+75u2XA94fntjGcyxqdN50=; b=TuO2bmRQcAvAag3VPZr/0zLy6fy/tn/l5ItCikaJ64NBm7WtVOosJ+QsRlmMbaSJOD xMndxBYMw19OYDDgivrjDAWAx0C6Cy+DwtORFSREkLyFJB1elNtSsHPynahI+ggpsXtV 8Zc8ZJyejbejJrY7OsIDgtGFBs0yW3F0oAhwrEGHjvzSCfpVzgZZgJlxnboDkA3wRtME k7H1uxQ9WiqZntUMz3H1WSNELzpbDTrPRk8nnTAaNo02czUh5+iY4bhT2JbMq+Yofu0x qBcPHkstFJeLTn1UGtYh3r6+2EVlgton5U89XlhBXdCc9ChoaRo9yAb89vaz7UGtG+08 Yagg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tR7zFyrnt9dYnjSZfpnAD+75u2XA94fntjGcyxqdN50=; b=Bm/W4d3qrNzo0I6vvFD2R+945/c1jzYlFjuDl4zKWGkkcERXU3Rt6vyyHIpuw6q9t4 672N6CISSDp2Af6KpN+vYx2AU0YLLdNW4OFpUbKydA/XWyMAcDi7VZ4W9ytgrV/PXxhe 5G2ADHbrVfQt0wUYZ4cffuiTjZOjh/7Kzyw2U6wUxaNekFI9lrdOipJSwlRbMTDDZiqZ UEBaYOT0BYmjnP06IXDRHAVTAcQ0ffGXO5ks89oM8r+zeUE6m22RBhFKlouiKNXqyk8q dgJZwi5av86HKHeWKaoulA5vkP88i78FKvW4IgOGRjG/Sxy+t/+J2JlpkRonhEFZZWjf /6fg== X-Gm-Message-State: APt69E3hRiQRKznxo4WZt36bSPq0SJHzRHeN/O3PZL9tpAahSH2NsKGh O14st7uqlX1DdoeEauVsHvKysA== X-Google-Smtp-Source: ADUXVKKOQ+4HVlRGC5fOtwwuBkmOaKruX7mupkejxZ3A0iLjjIB83+n2lY05GigpRh1Z7G3WVNaGcg== X-Received: by 2002:a63:b812:: with SMTP id p18-v6mr13115381pge.11.1530281202170; Fri, 29 Jun 2018 07:06:42 -0700 (PDT) From: Shubham Jain To: patchew-devel@redhat.com Date: Fri, 29 Jun 2018 19:35:51 +0530 Message-Id: <20180629140551.99829-4-shubhamjain7495@gmail.com> In-Reply-To: <20180629140551.99829-1-shubhamjain7495@gmail.com> References: <20180629140551.99829-1-shubhamjain7495@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 29 Jun 2018 14:06:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 29 Jun 2018 14:06:43 +0000 (UTC) for IP:'74.125.83.41' DOMAIN:'mail-pg0-f41.google.com' HELO:'mail-pg0-f41.google.com' FROM:'shubhamjain7495@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.551 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 74.125.83.41 mail-pg0-f41.google.com 74.125.83.41 mail-pg0-f41.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH v2 3/3] Make Import Command use Rest X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 29 Jun 2018 14:07:12 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Make patchew-cli's Import user REST apis. Changed the exit status of authen= ticated user from cli test while importing since in REST every authenticate= d user can access the import api but messages would be imported only to the= projects recognised ie whether it imported by maintainer or importer. Also= added warning if message is not imported to any project. --- api/rest.py | 3 ++- patchew-cli | 18 +++++++++++++----- tests/test_import.py | 8 ++++---- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/api/rest.py b/api/rest.py index 9b47f37..876be75 100644 --- a/api/rest.py +++ b/api/rest.py @@ -423,7 +423,8 @@ class MessagesViewSet(BaseMessageViewSet): serializer_class =3D MessageSerializer permission_classes =3D (permissions.IsAuthenticatedOrReadOnly,) parser_classes =3D (JSONParser, MessagePlainTextParser, ) - =20 + authentication_classes =3D (CsrfExemptSessionAuthentication, ) + def create(self, request, *args, **kwargs): m =3D MboxMessage(request.data['mbox']) projects =3D [p for p in Project.objects.all() if p.recognizes(m)] diff --git a/patchew-cli b/patchew-cli index f90f3c5..3796caf 100755 --- a/patchew-cli +++ b/patchew-cli @@ -220,11 +220,18 @@ class ImportCommand(SubCommand): print("[OLD] " + mo["Subject"]) return print("[NEW] " + mo["Subject"]) - r =3D self.api_do("import", mboxes=3D[mo.as_string()]) - for p in r: - if p not in projects: - projects.add(p) - print(p) + for mbox in [mo.as_string()]: + r =3D self.rest_api_do(url_cmd=3D"messages", + request_method=3D'post', + content_type=3D'message/rfc822', + data=3Dmbox) + projects_list =3D [x['resource_uri'].split("messages")[0] = for x in r['results']] + for p in projects_list: + if p not in projects: + projects.add(p) + print(p) + if len(projects_list)=3D=3D0: + print("The message was not imported to any project. Pe= rhaps you're not logged in as an importer or maintainer") if ff: open(ff, "wb").close() =20 @@ -251,6 +258,7 @@ class ImportCommand(SubCommand): try: import_one(f) except: + raise print("Error in importing:", f) traceback.print_exc() r =3D 1 diff --git a/tests/test_import.py b/tests/test_import.py index 5693d7e..250f391 100755 --- a/tests/test_import.py +++ b/tests/test_import.py @@ -107,21 +107,21 @@ class UnprivilegedImportTest(ImportTest): =20 test_import_belong_to_multiple_projects =3D None =20 - def check_import_should_fail(self): - self.cli_import("0001-simple-patch.mbox.gz", 1) + def check_import_status(self, exit_status): + self.cli_import("0001-simple-patch.mbox.gz", exit_status) a, b =3D self.check_cli(["search"]) self.assertNotIn('[Qemu-devel] [PATCH] quorum: Only compile when s= upported', a.splitlines()) =20 def test_anonymous_import(self): self.cli_logout() - self.check_import_should_fail() + self.check_import_status(exit_status=3D1) =20 def test_normal_user_import(self): self.cli_logout() self.create_user("someuser", "somepass") self.cli_login("someuser", "somepass") - self.check_import_should_fail() + self.check_import_status(exit_status=3D0) =20 def test_project_update(self): p =3D Project.objects.all()[0] --=20 2.15.1 (Apple Git-101) _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel