From 21cdd867bbd82d0bdbf42c00fa5447dd4fb5eb52 Mon Sep 17 00:00:00 2001
From: "alexander.pace@ligo.org" <alexander.pace@ligo.org>
Date: Thu, 24 Oct 2019 15:02:59 -0500
Subject: [PATCH] updating virgo_detchar's cert

---
 .../0053_update_virgodetchar_cert.py          | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 gracedb/ligoauth/migrations/0053_update_virgodetchar_cert.py

diff --git a/gracedb/ligoauth/migrations/0053_update_virgodetchar_cert.py b/gracedb/ligoauth/migrations/0053_update_virgodetchar_cert.py
new file mode 100644
index 000000000..6766b1514
--- /dev/null
+++ b/gracedb/ligoauth/migrations/0053_update_virgodetchar_cert.py
@@ -0,0 +1,46 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.20 on 2019-06-03 20:10
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+# The new cert and subject line came as a result of virgo detchar's
+# cert expiring. I (Alex) was contained by Nicolas Arnaud on 10/24/2019
+# via email.
+
+ACCOUNT = {
+    'name': 'virgo_detchar',
+    'new_cert': 'DC=org/DC=cilogon/C=US/O=LIGO/OU=Robots/CN=lscgw.virgo.infn.it/CN=Virgodetchar/CN=Nicolas Arnaud/CN=UID:nicolas.arnaud.robot',
+}
+
+
+def add_cert(apps, schema_editor):
+    RobotUser = apps.get_model('auth', 'User')
+
+    # Get user
+    user = RobotUser.objects.get(username=ACCOUNT['name'])
+
+    # Create new certificate
+    user.x509cert_set.create(subject=ACCOUNT['new_cert'])
+
+
+def delete_cert(apps, schema_editor):
+    RobotUser = apps.get_model('ligoauth', 'RobotUser')
+
+    # Get user
+    user = RobotUser.objects.get(username=ACCOUNT['name'])
+
+    # Delete new certificate
+    cert = user.x509cert_set.get(subject=ACCOUNT['new_cert'])
+    cert.delete()
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('ligoauth', '0052_update_gstlalcbc_O3b_cert'),
+    ]
+
+    operations = [
+        migrations.RunPython(add_cert, delete_cert),
+    ]
-- 
GitLab