|
1 | 1 | package net.leanix.githubagent.services |
2 | 2 |
|
3 | 3 | import com.ninjasquad.springmockk.MockkBean |
4 | | -import com.ninjasquad.springmockk.SpykBean |
5 | 4 | import io.mockk.every |
6 | 5 | import io.mockk.just |
7 | 6 | import io.mockk.runs |
8 | 7 | import io.mockk.verify |
9 | 8 | import net.leanix.githubagent.client.GitHubClient |
10 | 9 | import net.leanix.githubagent.dto.Account |
11 | | -import net.leanix.githubagent.dto.GitHubSearchResponse |
12 | 10 | import net.leanix.githubagent.dto.Installation |
13 | 11 | import net.leanix.githubagent.dto.ItemResponse |
14 | 12 | import net.leanix.githubagent.dto.ManifestFileAction |
15 | 13 | import net.leanix.githubagent.dto.ManifestFileUpdateDto |
16 | 14 | import net.leanix.githubagent.dto.Organization |
17 | | -import net.leanix.githubagent.dto.RepositoryDto |
18 | 15 | import net.leanix.githubagent.dto.RepositoryItemResponse |
19 | | -import net.leanix.githubagent.graphql.data.enums.RepositoryVisibility |
20 | | -import net.leanix.githubagent.shared.INSTALLATION_REPOSITORIES |
21 | 16 | import net.leanix.githubagent.shared.MANIFEST_FILE_NAME |
22 | 17 | import org.junit.jupiter.api.BeforeEach |
23 | 18 | import org.junit.jupiter.api.Test |
@@ -53,9 +48,6 @@ class WebhookEventServiceTest { |
53 | 48 | @MockkBean |
54 | 49 | private lateinit var gitHubAPIService: GitHubAPIService |
55 | 50 |
|
56 | | - @SpykBean |
57 | | - private lateinit var syncLogService: SyncLogService |
58 | | - |
59 | 51 | private val permissions = mapOf("administration" to "read", "contents" to "read", "metadata" to "read") |
60 | 52 | private val events = listOf("label", "public", "repository", "push") |
61 | 53 |
|
@@ -495,107 +487,6 @@ class WebhookEventServiceTest { |
495 | 487 | } |
496 | 488 | } |
497 | 489 |
|
498 | | - @Test |
499 | | - fun `should handle installation repositories event`() { |
500 | | - every { syncLogService.sendSyncLog(any(), any(), any(), any()) } just runs |
501 | | - every { gitHubGraphQLService.getRepository(any(), any(), any()) } returns RepositoryDto( |
502 | | - id = "1", |
503 | | - name = "repo", |
504 | | - organizationName = "owner/repo", |
505 | | - description = "main", |
506 | | - url = "content", |
507 | | - defaultBranch = "main", |
508 | | - archived = false, |
509 | | - visibility = RepositoryVisibility.PRIVATE, |
510 | | - languages = emptyList(), |
511 | | - topics = emptyList(), |
512 | | - updatedAt = "2021-09-01" |
513 | | - ) |
514 | | - every { gitHubClient.searchManifestFiles(any(), any()) } returnsMany listOf( |
515 | | - GitHubSearchResponse( |
516 | | - 2, |
517 | | - listOf( |
518 | | - createItemResponse("repo-test", "cider-org-3"), |
519 | | - createItemResponse("repo-test", "cider-org-3") |
520 | | - ) |
521 | | - ), |
522 | | - GitHubSearchResponse( |
523 | | - 3, |
524 | | - listOf( |
525 | | - createItemResponse("demo-repo-1", "cider-org-3"), |
526 | | - createItemResponse("demo-repo-1", "cider-org-3") |
527 | | - ) |
528 | | - ) |
529 | | - ) |
530 | | - |
531 | | - val payload = """ |
532 | | - { |
533 | | - "action": "added", |
534 | | - "installation": { |
535 | | - "id": 150, |
536 | | - "account": { |
537 | | - "login": "cider-org-3", |
538 | | - "id": 47 |
539 | | - }, |
540 | | - "repository_selection": "selected", |
541 | | - "access_tokens_url": "https://cider-gh-enterprise.northeurope.cloudapp.azure.com/api/v3/app/installations/150/access_tokens", |
542 | | - "repositories_url": "https://cider-gh-enterprise.northeurope.cloudapp.azure.com/api/v3/installation/repositories", |
543 | | - "html_url": "https://cider-gh-enterprise.northeurope.cloudapp.azure.com/organizations/cider-org-3/settings/installations/150", |
544 | | - "app_id": 3, |
545 | | - "app_slug": "test-github-app", |
546 | | - "target_id": 47, |
547 | | - "target_type": "Organization", |
548 | | - "permissions": { |
549 | | - "checks": "write", |
550 | | - "members": "read", |
551 | | - "contents": "read", |
552 | | - "metadata": "read", |
553 | | - "administration": "read" |
554 | | - }, |
555 | | - "events": [ |
556 | | - "check_run", |
557 | | - "check_suite", |
558 | | - "label", |
559 | | - "organization", |
560 | | - "public", |
561 | | - "push", |
562 | | - "repository" |
563 | | - ] |
564 | | - }, |
565 | | - "repository_selection": "selected", |
566 | | - "repositories_added": [ |
567 | | - { |
568 | | - "id": 30, |
569 | | - "node_id": "MDEwOlJlcG9zaXRvcnkzMA==", |
570 | | - "name": "repo-test", |
571 | | - "full_name": "cider-org-3/kostas-test", |
572 | | - "private": true |
573 | | - }, |
574 | | - { |
575 | | - "id": 1648, |
576 | | - "node_id": "MDEwOlJlcG9zaXRvcnkxNjQ4", |
577 | | - "name": "demo-repo-1", |
578 | | - "full_name": "cider-org-3/demo-repo-1", |
579 | | - "private": true |
580 | | - }, |
581 | | - { |
582 | | - "id": 1649, |
583 | | - "node_id": "MDEwOlJlcG9zaXRvcnkxNjQ5", |
584 | | - "name": "demo-repo-2", |
585 | | - "full_name": "cider-org-3/demo-repo-2", |
586 | | - "private": true |
587 | | - } |
588 | | - ], |
589 | | - "repositories_removed": [] |
590 | | - } |
591 | | - """ |
592 | | - |
593 | | - webhookEventService.consumeWebhookEvent(INSTALLATION_REPOSITORIES, payload) |
594 | | - |
595 | | - verify(exactly = 3) { webSocketService.sendMessage("/events/repository", any()) } |
596 | | - verify(exactly = 6) { webSocketService.sendMessage("/events/manifestFile", any()) } |
597 | | - } |
598 | | - |
599 | 490 | fun createItemResponse(repoName: String, organization: String): ItemResponse { |
600 | 491 | return ItemResponse( |
601 | 492 | MANIFEST_FILE_NAME, |
|
0 commit comments