mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-31 06:21:11 +00:00 
			
		
		
		
	[CLI] implement forgejo-cli actions register
(cherry picked from commit2f95143000) (cherry picked from commit42f2f8731e) [CLI] implement forgejo-cli actions register (squash) no private Do not go through the private API, directly modify the database (cherry picked from commit1ba7c0d39d)
This commit is contained in:
		
					parent
					
						
							
								4c121ef022
							
						
					
				
			
			
				commit
				
					
						fd7f8bec98
					
				
			
		
					 8 changed files with 484 additions and 8 deletions
				
			
		
							
								
								
									
										29
									
								
								models/actions/forgejo_test.go
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								models/actions/forgejo_test.go
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,29 @@ | |||
| // SPDX-License-Identifier: MIT | ||||
| 
 | ||||
| package actions | ||||
| 
 | ||||
| import ( | ||||
| 	"crypto/subtle" | ||||
| 	"testing" | ||||
| 
 | ||||
| 	auth_model "code.gitea.io/gitea/models/auth" | ||||
| 	"code.gitea.io/gitea/models/db" | ||||
| 	"code.gitea.io/gitea/models/unittest" | ||||
| 
 | ||||
| 	"github.com/stretchr/testify/assert" | ||||
| ) | ||||
| 
 | ||||
| func TestActions_RegisterRunner(t *testing.T) { | ||||
| 	assert.NoError(t, unittest.PrepareTestDatabase()) | ||||
| 	ownerID := int64(0) | ||||
| 	repoID := int64(0) | ||||
| 	token := "0123456789012345678901234567890123456789" | ||||
| 	labels := []string{} | ||||
| 	name := "runner" | ||||
| 	version := "v1.2.3" | ||||
| 	runner, err := RegisterRunner(db.DefaultContext, ownerID, repoID, token, labels, name, version) | ||||
| 	assert.NoError(t, err) | ||||
| 	assert.EqualValues(t, name, runner.Name) | ||||
| 
 | ||||
| 	assert.EqualValues(t, 1, subtle.ConstantTimeCompare([]byte(runner.TokenHash), []byte(auth_model.HashToken(token, runner.TokenSalt))), "the token cannot be verified with the same method as routers/api/actions/runner/interceptor.go as of 8228751c55d6a4263f0fec2932ca16181c09c97d") | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue