Skip to content

Commit f1f8293

Browse files
josephabrahamsn2ygk
authored andcommitted
Test swapped migrations
1 parent d2c13f0 commit f1f8293

File tree

5 files changed

+377
-89
lines changed

5 files changed

+377
-89
lines changed

tests/migrations/0001_initial.py

+14-88
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,48 @@
1-
# Generated by Django 2.2.6 on 2019-10-24 20:21
1+
# Generated by Django 4.0.4 on 2022-05-27 21:07
22

3-
from django.conf import settings
43
from django.db import migrations, models
5-
import django.db.models.deletion
6-
import oauth2_provider.generators
74

85

96
class Migration(migrations.Migration):
107

118
initial = True
129

1310
dependencies = [
14-
migrations.swappable_dependency(settings.OAUTH2_PROVIDER_APPLICATION_MODEL),
15-
migrations.swappable_dependency(settings.OAUTH2_PROVIDER_ACCESS_TOKEN_MODEL),
16-
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
17-
migrations.swappable_dependency(settings.OAUTH2_PROVIDER_REFRESH_TOKEN_MODEL),
11+
]
12+
13+
run_before = [
14+
('oauth2_provider', '0001_initial'),
1815
]
1916

2017
operations = [
2118
migrations.CreateModel(
22-
name='SampleGrant',
19+
name='BaseTestApplication',
2320
fields=[
24-
('id', models.BigAutoField(primary_key=True, serialize=False)),
25-
('code', models.CharField(max_length=255, unique=True)),
26-
('expires', models.DateTimeField()),
27-
('redirect_uri', models.CharField(max_length=255)),
28-
('scope', models.TextField(blank=True)),
29-
('created', models.DateTimeField(auto_now_add=True)),
30-
('updated', models.DateTimeField(auto_now=True)),
31-
('code_challenge', models.CharField(blank=True, default='', max_length=128)),
32-
('code_challenge_method', models.CharField(blank=True, choices=[('plain', 'plain'), ('S256', 'S256')], default='', max_length=10)),
33-
('custom_field', models.CharField(max_length=255)),
34-
('application', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.OAUTH2_PROVIDER_APPLICATION_MODEL)),
35-
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='tests_samplegrant', to=settings.AUTH_USER_MODEL)),
36-
("nonce", models.CharField(blank=True, max_length=255, default="")),
37-
("claims", models.TextField(blank=True)),
21+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
3822
],
39-
options={
40-
'abstract': False,
41-
},
4223
),
4324
migrations.CreateModel(
44-
name='SampleApplication',
25+
name='SampleAccessToken',
4526
fields=[
46-
('id', models.BigAutoField(primary_key=True, serialize=False)),
47-
('client_id', models.CharField(db_index=True, default=oauth2_provider.generators.generate_client_id, max_length=100, unique=True)),
48-
('redirect_uris', models.TextField(blank=True, help_text='Allowed URIs list, space separated')),
49-
('client_type', models.CharField(choices=[('confidential', 'Confidential'), ('public', 'Public')], max_length=32)),
50-
('authorization_grant_type', models.CharField(choices=[('authorization-code', 'Authorization code'), ('implicit', 'Implicit'), ('password', 'Resource owner password-based'), ('client-credentials', 'Client credentials'), ('openid-hybrid', 'OpenID connect hybrid')], max_length=32)),
51-
('client_secret', models.CharField(blank=True, db_index=True, default=oauth2_provider.generators.generate_client_secret, max_length=255)),
52-
('name', models.CharField(blank=True, max_length=255)),
53-
('skip_authorization', models.BooleanField(default=False)),
54-
('created', models.DateTimeField(auto_now_add=True)),
55-
('updated', models.DateTimeField(auto_now=True)),
56-
('custom_field', models.CharField(max_length=255)),
57-
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='tests_sampleapplication', to=settings.AUTH_USER_MODEL)),
58-
('algorithm', models.CharField(max_length=5, choices=[('RS256', 'RSA with SHA-2 256'), ('HS256', 'HMAC with SHA-2 256')], default='RS256')),
27+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
5928
],
60-
options={
61-
'abstract': False,
62-
},
6329
),
6430
migrations.CreateModel(
65-
name='SampleAccessToken',
31+
name='SampleApplication',
6632
fields=[
67-
('id', models.BigAutoField(primary_key=True, serialize=False)),
68-
('token', models.CharField(max_length=255, unique=True)),
69-
('expires', models.DateTimeField()),
70-
('scope', models.TextField(blank=True)),
71-
('created', models.DateTimeField(auto_now_add=True)),
72-
('updated', models.DateTimeField(auto_now=True)),
73-
('custom_field', models.CharField(max_length=255)),
74-
('application', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.OAUTH2_PROVIDER_APPLICATION_MODEL)),
75-
('source_refresh_token', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='s_refreshed_access_token', to=settings.OAUTH2_PROVIDER_REFRESH_TOKEN_MODEL)),
76-
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='tests_sampleaccesstoken', to=settings.AUTH_USER_MODEL)),
77-
('id_token', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='access_token', to=settings.OAUTH2_PROVIDER_ID_TOKEN_MODEL)),
33+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
7834
],
79-
options={
80-
'abstract': False,
81-
},
8235
),
8336
migrations.CreateModel(
84-
name='BaseTestApplication',
37+
name='SampleGrant',
8538
fields=[
86-
('id', models.BigAutoField(primary_key=True, serialize=False)),
87-
('client_id', models.CharField(db_index=True, default=oauth2_provider.generators.generate_client_id, max_length=100, unique=True)),
88-
('redirect_uris', models.TextField(blank=True, help_text='Allowed URIs list, space separated')),
89-
('client_type', models.CharField(choices=[('confidential', 'Confidential'), ('public', 'Public')], max_length=32)),
90-
('authorization_grant_type', models.CharField(choices=[('authorization-code', 'Authorization code'), ('implicit', 'Implicit'), ('password', 'Resource owner password-based'), ('client-credentials', 'Client credentials'), ('openid-hybrid', 'OpenID connect hybrid')], max_length=32)),
91-
('client_secret', models.CharField(blank=True, db_index=True, default=oauth2_provider.generators.generate_client_secret, max_length=255)),
92-
('name', models.CharField(blank=True, max_length=255)),
93-
('skip_authorization', models.BooleanField(default=False)),
94-
('created', models.DateTimeField(auto_now_add=True)),
95-
('updated', models.DateTimeField(auto_now=True)),
96-
('allowed_schemes', models.TextField(blank=True)),
97-
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='tests_basetestapplication', to=settings.AUTH_USER_MODEL)),
98-
('algorithm', models.CharField(max_length=5, choices=[('RS256', 'RSA with SHA-2 256'), ('HS256', 'HMAC with SHA-2 256')], default='RS256')),
39+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
9940
],
100-
options={
101-
'abstract': False,
102-
},
10341
),
10442
migrations.CreateModel(
10543
name='SampleRefreshToken',
10644
fields=[
107-
('id', models.BigAutoField(primary_key=True, serialize=False)),
108-
('token', models.CharField(max_length=255)),
109-
('created', models.DateTimeField(auto_now_add=True)),
110-
('updated', models.DateTimeField(auto_now=True)),
111-
('revoked', models.DateTimeField(null=True)),
112-
('custom_field', models.CharField(max_length=255)),
113-
('access_token', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='s_refresh_token', to=settings.OAUTH2_PROVIDER_ACCESS_TOKEN_MODEL)),
114-
('application', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.OAUTH2_PROVIDER_APPLICATION_MODEL)),
115-
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='tests_samplerefreshtoken', to=settings.AUTH_USER_MODEL)),
45+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
11646
],
117-
options={
118-
'abstract': False,
119-
'unique_together': {('token', 'revoked')},
120-
},
12147
),
12248
]

0 commit comments

Comments
 (0)