|
1 | 1 | // |
2 | | -// Copyright 2025 The Chainloop Authors. |
| 2 | +// Copyright 2025-2026 The Chainloop Authors. |
3 | 3 | // |
4 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | // you may not use this file except in compliance with the License. |
@@ -100,16 +100,31 @@ func TestAPITokenEvents(t *testing.T) { |
100 | 100 | actor: auditor.ActorTypeAPIToken, |
101 | 101 | actorID: apiTokenUUID, |
102 | 102 | }, |
| 103 | + { |
| 104 | + name: "API Token auto-revoked by system", |
| 105 | + event: &events.APITokenRevoked{ |
| 106 | + APITokenBase: &events.APITokenBase{ |
| 107 | + APITokenID: uuidPtr(apiTokenUUID), |
| 108 | + APITokenName: apiTokenName, |
| 109 | + }, |
| 110 | + }, |
| 111 | + expected: "testdata/apitokens/api_token_revoked_by_system.json", |
| 112 | + actor: auditor.ActorTypeSystem, |
| 113 | + actorID: uuid.Nil, |
| 114 | + }, |
103 | 115 | } |
104 | 116 |
|
105 | 117 | for _, tt := range tests { |
106 | 118 | t.Run(tt.name, func(t *testing.T) { |
107 | 119 | opts := []auditor.GeneratorOption{ |
108 | 120 | auditor.WithOrgID(orgUUID), |
109 | 121 | } |
110 | | - if tt.actor == auditor.ActorTypeAPIToken { |
| 122 | + switch tt.actor { |
| 123 | + case auditor.ActorTypeAPIToken: |
111 | 124 | opts = append(opts, auditor.WithActor(auditor.ActorTypeAPIToken, tt.actorID, "", testAPITokenName)) |
112 | | - } else { |
| 125 | + case auditor.ActorTypeSystem: |
| 126 | + opts = append(opts, auditor.WithActor(auditor.ActorTypeSystem, uuid.Nil, "", "")) |
| 127 | + default: |
113 | 128 | opts = append(opts, auditor.WithActor(auditor.ActorTypeUser, tt.actorID, testEmail, testName)) |
114 | 129 | } |
115 | 130 |
|
|
0 commit comments