aboutsummaryrefslogtreecommitdiffstats
path: root/models/oauth2_application_test.go
diff options
context:
space:
mode:
authorJonas Franz <info@jonasfranz.software>2019-04-17 10:18:16 +0200
committerLunny Xiao <xiaolunwen@gmail.com>2019-04-17 16:18:16 +0800
commit7a4c29c739fa9b08f901220ebcb2948daf491692 (patch)
tree73e44404a6c13061b832624582e230eedb801c3c /models/oauth2_application_test.go
parent34548369e1d78eb1141aecd4ab02acf59f2949ae (diff)
downloadgitea-7a4c29c739fa9b08f901220ebcb2948daf491692.tar.gz
gitea-7a4c29c739fa9b08f901220ebcb2948daf491692.zip
OAuth2 Grant UI (#6625)
* Add oauth2 grants ui Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add delete functionality Add translations Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit tests Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit tests Signed-off-by: Jonas Franz <info@jonasfranz.software> * Refactor DeleteOAuth2Grant Use results.Close() Signed-off-by: Jonas Franz <info@jonasfranz.software> * Refactor DeleteOAuth2Grant (again) Signed-off-by: Jonas Franz <info@jonasfranz.software> * Check if user ID is zero Signed-off-by: Jonas Franz <info@jonasfranz.software> * Check if grant ID is zero Signed-off-by: Jonas Franz <info@jonasfranz.software>
Diffstat (limited to 'models/oauth2_application_test.go')
-rw-r--r--models/oauth2_application_test.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/models/oauth2_application_test.go b/models/oauth2_application_test.go
index b06d9356c0..3afdf50f53 100644
--- a/models/oauth2_application_test.go
+++ b/models/oauth2_application_test.go
@@ -135,6 +135,25 @@ func TestOAuth2Grant_TableName(t *testing.T) {
assert.Equal(t, "oauth2_grant", new(OAuth2Grant).TableName())
}
+func TestGetOAuth2GrantsByUserID(t *testing.T) {
+ assert.NoError(t, PrepareTestDatabase())
+ result, err := GetOAuth2GrantsByUserID(1)
+ assert.NoError(t, err)
+ assert.Len(t, result, 1)
+ assert.Equal(t, int64(1), result[0].ID)
+ assert.Equal(t, result[0].ApplicationID, result[0].Application.ID)
+
+ result, err = GetOAuth2GrantsByUserID(34134)
+ assert.NoError(t, err)
+ assert.Empty(t, result)
+}
+
+func TestRevokeOAuth2Grant(t *testing.T) {
+ assert.NoError(t, PrepareTestDatabase())
+ assert.NoError(t, RevokeOAuth2Grant(1, 1))
+ AssertNotExistsBean(t, &OAuth2Grant{ID: 1, UserID: 1})
+}
+
//////////////////// Authorization Code
func TestGetOAuth2AuthorizationByCode(t *testing.T) {