diff --git a/gracedb/ligoauth/migrations/0035_add_mbta_cert.py b/gracedb/ligoauth/migrations/0035_add_mbta_cert.py new file mode 100644 index 0000000000000000000000000000000000000000..9c338f01528af6d5913bc72ceb979b6d9a977ba4 --- /dev/null +++ b/gracedb/ligoauth/migrations/0035_add_mbta_cert.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.20 on 2019-06-20 02:59 +from __future__ import unicode_literals + +from django.db import migrations + +ACCOUNT = { + 'name': 'MbtaAlert', + 'new_cert': '/DC=org/DC=cilogon/C=US/O=LIGO/OU=Robots/CN=lscgw.virgo.infn.it/CN=MbtaAlert/CN=Antonella Bozzi/CN=UID:antonella.bozzi.robot', +} + + +def add_cert(apps, schema_editor): + RobotUser = apps.get_model('ligoauth', 'RobotUser') + + # 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', '0034_add_gstlal_cert'), + ] + + operations = [ + migrations.RunPython(add_cert, delete_cert), + ]