@@ -46,6 +46,7 @@ def test_application_registration_user(self):
46
46
"client_secret" : "client_secret" ,
47
47
"client_type" : Application .CLIENT_CONFIDENTIAL ,
48
48
"redirect_uris" : "http://example.com" ,
49
+ "post_logout_redirect_uris" : "http://other_example.com" ,
49
50
"authorization_grant_type" : Application .GRANT_AUTHORIZATION_CODE ,
50
51
"algorithm" : "" ,
51
52
}
@@ -55,13 +56,22 @@ def test_application_registration_user(self):
55
56
56
57
app = get_application_model ().objects .get (name = "Foo app" )
57
58
self .assertEqual (app .user .username , "foo_user" )
59
+ app = Application .objects .get ()
60
+ self .assertEquals (app .name , form_data ["name" ])
61
+ self .assertEquals (app .client_id , form_data ["client_id" ])
62
+ self .assertEquals (app .redirect_uris , form_data ["redirect_uris" ])
63
+ self .assertEquals (app .post_logout_redirect_uris , form_data ["post_logout_redirect_uris" ])
64
+ self .assertEquals (app .client_type , form_data ["client_type" ])
65
+ self .assertEquals (app .authorization_grant_type , form_data ["authorization_grant_type" ])
66
+ self .assertEquals (app .algorithm , form_data ["algorithm" ])
58
67
59
68
60
69
class TestApplicationViews (BaseTest ):
61
70
def _create_application (self , name , user ):
62
71
app = Application .objects .create (
63
72
name = name ,
64
73
redirect_uris = "http://example.com" ,
74
+ post_logout_redirect_uris = "http://other_example.com" ,
65
75
client_type = Application .CLIENT_CONFIDENTIAL ,
66
76
authorization_grant_type = Application .GRANT_AUTHORIZATION_CODE ,
67
77
user = user ,
@@ -93,9 +103,37 @@ def test_application_detail_owner(self):
93
103
94
104
response = self .client .get (reverse ("oauth2_provider:detail" , args = (self .app_foo_1 .pk ,)))
95
105
self .assertEqual (response .status_code , 200 )
106
+ self .assertContains (response , self .app_foo_1 .name )
107
+ self .assertContains (response , self .app_foo_1 .redirect_uris )
108
+ self .assertContains (response , self .app_foo_1 .post_logout_redirect_uris )
109
+ self .assertContains (response , self .app_foo_1 .client_type )
110
+ self .assertContains (response , self .app_foo_1 .authorization_grant_type )
96
111
97
112
def test_application_detail_not_owner (self ):
98
113
self .client .login (username = "foo_user" , password = "123456" )
99
114
100
115
response = self .client .get (reverse ("oauth2_provider:detail" , args = (self .app_bar_1 .pk ,)))
101
116
self .assertEqual (response .status_code , 404 )
117
+
118
+ def test_application_udpate (self ):
119
+ self .client .login (username = "foo_user" , password = "123456" )
120
+
121
+ form_data = {
122
+ "client_id" : "new_client_id" ,
123
+ "redirect_uris" : "http://new_example.com" ,
124
+ "post_logout_redirect_uris" : "http://new_other_example.com" ,
125
+ "client_type" : Application .CLIENT_PUBLIC ,
126
+ "authorization_grant_type" : Application .GRANT_OPENID_HYBRID ,
127
+ }
128
+ response = self .client .post (
129
+ reverse ("oauth2_provider:update" , args = (self .app_foo_1 .pk ,)),
130
+ data = form_data ,
131
+ )
132
+ self .assertRedirects (response , reverse ("oauth2_provider:detail" , args = (self .app_foo_1 .pk ,)))
133
+
134
+ self .app_foo_1 .refresh_from_db ()
135
+ self .assertEquals (self .app_foo_1 .client_id , form_data ["client_id" ])
136
+ self .assertEquals (self .app_foo_1 .redirect_uris , form_data ["redirect_uris" ])
137
+ self .assertEquals (self .app_foo_1 .post_logout_redirect_uris , form_data ["post_logout_redirect_uris" ])
138
+ self .assertEquals (self .app_foo_1 .client_type , form_data ["client_type" ])
139
+ self .assertEquals (self .app_foo_1 .authorization_grant_type , form_data ["authorization_grant_type" ])
0 commit comments