@@ -248,8 +248,12 @@ var _ = Describe("GitHub Provider", func() {
248248 Expect (err ).ToNot (HaveOccurred ())
249249 validateRepo (repo , repoRef )
250250
251- getRepo , err := c .OrgRepositories ().Get (ctx , repoRef )
252- Expect (err ).ToNot (HaveOccurred ())
251+ var getRepo gitprovider.OrgRepository
252+ Eventually (func () error {
253+ getRepo , err = c .OrgRepositories ().Get (ctx , repoRef )
254+ return err
255+ }, 3 * time .Second , 1 * time .Second ).ShouldNot (HaveOccurred ())
256+
253257 // Expect the two responses (one from POST and one from GET to have equal "spec")
254258 getSpec := newGithubRepositorySpec (getRepo .APIObject ().(* github.Repository ))
255259 postSpec := newGithubRepositorySpec (repo .APIObject ().(* github.Repository ))
@@ -292,8 +296,12 @@ var _ = Describe("GitHub Provider", func() {
292296 _ , err = anonClient .UserRepositories ().Get (ctx , userRepoRef )
293297 Expect (errors .Is (err , gitprovider .ErrNotFound )).To (BeTrue ())
294298
295- getUserRepo , err := c .UserRepositories ().Get (ctx , userRepoRef )
296- Expect (err ).ToNot (HaveOccurred ())
299+ var getUserRepo gitprovider.UserRepository
300+ Eventually (func () error {
301+ getUserRepo , err = c .UserRepositories ().Get (ctx , userRepoRef )
302+ return err
303+ }, 3 * time .Second , 1 * time .Second ).ShouldNot (HaveOccurred ())
304+
297305 // Expect the two responses (one from POST and one from GET to have equal "spec")
298306 getSpec := newGithubRepositorySpec (getUserRepo .APIObject ().(* github.Repository ))
299307 postSpec := newGithubRepositorySpec (userRepo .APIObject ().(* github.Repository ))
@@ -357,6 +365,16 @@ var _ = Describe("GitHub Provider", func() {
357365 Expect (actionTaken ).To (BeTrue ())
358366 })
359367
368+ It ("should validate that the token has the correct permissions" , func () {
369+ hasPermission , err := c .HasTokenPermission (ctx , 0 )
370+ Expect (err ).To (Equal (gitprovider .ErrNoProviderSupport ))
371+ Expect (hasPermission ).To (Equal (false ))
372+
373+ hasPermission , err = c .HasTokenPermission (ctx , gitprovider .TokenPermissionRWRepository )
374+ Expect (err ).ToNot (HaveOccurred ())
375+ Expect (hasPermission ).To (Equal (true ))
376+ })
377+
360378 AfterSuite (func () {
361379 // Don't do anything more if c wasn't created
362380 if c == nil {
0 commit comments