View Javadoc
1   /**
2    * Copyright (c) 2013-2022, jcabi.com
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met: 1) Redistributions of source code must retain the above
8    * copyright notice, this list of conditions and the following
9    * disclaimer. 2) Redistributions in binary form must reproduce the above
10   * copyright notice, this list of conditions and the following
11   * disclaimer in the documentation and/or other materials provided
12   * with the distribution. 3) Neither the name of the jcabi.com nor
13   * the names of its contributors may be used to endorse or promote
14   * products derived from this software without specific prior written
15   * permission.
16   *
17   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
19   * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20   * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21   * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28   * OF THE POSSIBILITY OF SUCH DAMAGE.
29   */
30  package com.jcabi.github;
31  
32  import java.lang.annotation.Documented;
33  import java.lang.annotation.ElementType;
34  import java.lang.annotation.Retention;
35  import java.lang.annotation.RetentionPolicy;
36  import java.lang.annotation.Target;
37  
38  /**
39   * Annotates an integration test case to indicate required OAuth scopes to run
40   * such case.
41   * @todo #975:30min Now all IT cases are annotated with OAuthScope annotation
42   *  to marked down its required scopes. A checker needs to be implemented to
43   *  check if the supplied account can fulfill the IT case requirement before
44   *  it is run and make the case fail if the required OAuth scopes is not
45   *  present.
46   * @author Jason Wong (super132j@yahoo.com)
47   * @version $Id: 59d92ce0fb2951843d7d1e4a104b800ceab1c72e $
48   * @see <a href="https://developer.github.com/v3/oauth/#scopes">Github OAuth
49   * scopes</a>
50   */
51  @Documented
52  @Retention(RetentionPolicy.RUNTIME)
53  @Target(ElementType.TYPE)
54  public @interface OAuthScope {
55      /**
56       * The Github OAuth scopes required.
57       */
58      Scope[] value();
59  
60      /**
61       * The enum represents the available OAuth scopes.
62       */
63      public enum Scope {
64          /**
65           * Represents "no scope" scope.
66           */
67          NO_SCOPE,
68          /**
69           * Represents "user" scope.
70           */
71          USER,
72          /**
73           * Represents "user:email" scope.
74           */
75          USER_EMAIL,
76          /**
77           * Represents "user:follow" scope.
78           */
79          USER_FOLLOW,
80          /**
81           * Represents "public_repo" scope.
82           */
83          PUBLIC_REPO,
84          /**
85           * Represents "repo" scope.
86           */
87          REPO,
88          /**
89           * Represents "repo_deployment" scope.
90           */
91          REPO_DEPLOYMENT,
92          /**
93           * Represents "repo_status" scope.
94           */
95          REPO_STATUS,
96          /**
97           * Represents "delete_repo" scope.
98           */
99          DELETE_REPO,
100         /**
101          * Represents "notifications" scope.
102          */
103         NOTIFICATIONS,
104         /**
105          * Represents "gist" scope.
106          */
107         GIST,
108         /**
109          * Represents "read:repo_hook" scope.
110          */
111         READ_REPO_HOOK,
112         /**
113          * Represents "write:repo_hook" scope.
114          */
115         WRITE_REPO_HOOK,
116         /**
117          * Represents "admin:repo_hook" scope.
118          */
119         ADMIN_REPO_HOOK,
120         /**
121          * Represents "admin:org_hook" scope.
122          */
123         ADMIN_ORG_HOOK,
124         /**
125          * Represents "read:org" scope.
126          */
127         READ_ORG,
128         /**
129          * Represents "write:org" scope.
130          */
131         WRITE_ORG,
132         /**
133          * Represents "admin:org" scope.
134          */
135         ADMIN_ORG,
136         /**
137          * Represents "read:public_key" scope.
138          */
139         READ_PUBLIC_KEY,
140         /**
141          * Represents "write:public_key" scope.
142          */
143         WRITE_PUBLIC_KEY,
144         /**
145          * Represents "admin:public_key" scope.
146          */
147         ADMIN_PUBLIC_KEY;
148     }
149 }