diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 1a6d708..f1f6700 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -22,7 +22,7 @@ jobs: - name: Build run: go build ./cmd/vault-plugin-secrets-gitlab - name: Test - run: go test -cover -coverprofile=coverage.out + run: go test -cover -coverprofile=coverage.out -tags unit,selfhosted,saas,local env: GITLAB_SERVICE_ACCOUNT_URL: ${{ vars.GITLAB_SERVICE_ACCOUNT_URL }} - name: Upload coverage reports to Codecov diff --git a/.gitignore b/.gitignore index 6b28bc0..3c46bc3 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,6 @@ fabric.properties go.work tmp/ bin/ +/coverage.html +/coverage.out +.envrc \ No newline at end of file diff --git a/.idea/vault-plugin-secrets-gitlab.iml b/.idea/vault-plugin-secrets-gitlab.iml index 6b7800b..7605a01 100644 --- a/.idea/vault-plugin-secrets-gitlab.iml +++ b/.idea/vault-plugin-secrets-gitlab.iml @@ -4,7 +4,10 @@ diff --git a/README.md b/README.md index a5b6f36..7444115 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ through Vault. - Gitlab Group Access Tokens - https://docs.gitlab.com/ee/api/group_access_tokens.html - Gitlab User Service Account Tokens - https://docs.gitlab.com/ee/api/users.html#create-service-account-user - Gitlab Group Service Account Tokens - https://docs.gitlab.com/ee/api/group_service_accounts.html +- Gitlab Pipeline Project Trigger Tokens - https://docs.gitlab.com/ee/api/pipeline_triggers.html +- Gitlab Group/Project Deploy Tokens - https://docs.gitlab.com/ee/user/project/deploy_tokens ## Getting Started @@ -92,7 +94,7 @@ The current authentication model requires providing Vault with a Gitlab Token. | base_url | yes | n/a | no | The address to access Gitlab | | auto_rotate_token | no | no | no | Should we autorotate the token when it's close to expiry? (Experimental) | | auto_rotate_before | no | 24h | no | How much time should be remaining on the token validity before we should rotate it? Minimum can be set to 24h and maximum to 730h | -| type | yes | n/a | no | The type of gitlab instance that we use can be one of saas, self-managed or dedicated | +| type | yes | n/a | no | The type of gitlab instance that we use can be one of saas, self-managed or dedicated | ### Role @@ -105,11 +107,41 @@ The current authentication model requires providing Vault with a Gitlab Token. | scopes | no | [] | no | List of scopes | | token_type | yes | n/a | no | Access token type | | gitlab_revokes_token | no | no | no | Gitlab revokes the token when it's time. Vault will not revoke the token when the lease expires | -| config_name | no | default | no | The configuration to use for the role | +| config_name | no | default | no | The configuration to use for the role | #### path -If `token_type` is `group-service-account` then the format of the path is `{groupId}/{serviceAccountName}` example `265/service_account_65c74d39b4f71fc3fdc72330fce28c28`. +##### `token_type` is `personal` + +Format of the path is `{username}` example `admin`. + +##### `token_type` is `project` + +Format of the path is the full path of the project for example `group/project` or `group/subgroup/project` + +##### `token_type` is `group` + +Format of the path is the full path of the project for example `group` or `group/subgroup` + +##### `token_type` is `user-service-account` + +Format of the path is `{username}` example `service_account_65c74d39b4f71fc3fdc72330fce28c28`. + +##### `token_type` is `group-service-account` + +Format of the path is `{groupId}/{serviceAccountName}` example `265/service_account_65c74d39b4f71fc3fdc72330fce28c28`. + +##### `token_type` is `project-deploy` + +Format of the path is the full path of the project for example `group/project` or `group/subgroup/project` + +##### `token_type` is `group-deploy` + +Format of the path is the full path of the project for example `group` or `group/subgroup` + +##### `token_type` is `pipeline-project-trigger` + +Format of the path is the full path of the project for example `group/project` or `group/subgroup/project` #### name @@ -154,17 +186,20 @@ Depending on `gitlab_revokes_token` the TTL will change. #### access_level -It's not required if `token_type` is set to `personal`. +It's not required if `token_type` is set to `personal`, `pipeline-project-trigger`, `project-deploy`, `group-deploy`. For a list of available roles check https://docs.gitlab.com/ee/user/permissions.html #### scopes +It's not required if `token_type` is set to `pipeline-project-trigger`. + Depending on the type of token you have different scopes: * `Personal` - https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#personal-access-token-scopes * `Project` - https://docs.gitlab.com/ee/user/project/settings/project_access_tokens.html#scopes-for-a-project-access-token * `Group` - https://docs.gitlab.com/ee/user/group/settings/group_access_tokens.html#scopes-for-a-group-access-token +* `Deploy` - https://docs.gitlab.com/ee/user/project/deploy_tokens/#scope #### token_types @@ -175,6 +210,9 @@ Can be * group * user-service-account * group-service-account +* pipeline-project-trigger +* project-deploy +* group-deploy #### gitlab_revokes_token @@ -223,6 +261,9 @@ token_expires_at 2025-07-11T00:00:00Z token_id 1 token_sha1_hash 9441e6e07d77a2d5601ab5d7cac5868d358d885c type self-managed +gitlab_version 17.5.3-ee +gitlab_revision 9d81c27eee7 +gitlab_is_enterprise true ``` After initial setup should you wish to change any value you can do so by using the patch command for example @@ -241,6 +282,9 @@ token_expires_at 2025-07-11T00:00:00Z token_id 2 token_sha1_hash c6e762667cadb936f0c8439b0d240661a270eba1 type saas +gitlab_version 17.7.0-pre +gitlab_revision 22e9474dc6b +gitlab_is_enterprise true ``` All the config properties as defined above in the Config section can be patched. @@ -257,8 +301,6 @@ $ vault secrets tune -max-lease-ttl=8784h -default-lease-ttl=168h gitlab/ Check https://developer.hashicorp.com/vault/docs/commands/secrets/tune for more information. There is a periodic func that runs that is responsible for autorotation and main token expiry time. -So in the beginning you may see `token_expires_at n/a`. But when the function runs it will update itself -with the correct expiry date and the corresponding `token_id`. ### Roles @@ -326,7 +368,7 @@ token_sha1_hash 91a91bb30f816770081c570504c5e2723bcb1f38 type self-managed ``` -**Important**: Token will be showed after rotation, it will not be shown again. +**Important**: Token will be shown only after rotation, and it will not be shown again. ## Upgrading diff --git a/backend.go b/backend.go index b85d7bc..554cc34 100644 --- a/backend.go +++ b/backend.go @@ -95,6 +95,8 @@ func (b *Backend) periodicFunc(ctx context.Context, req *logical.Request) (err e unlockLockClientMutex := sync.OnceFunc(func() { b.lockClientMutex.Unlock() }) defer unlockLockClientMutex() + // @TODO: Check and fix this is not correct, the locking mechanism doesn't make sense + var configs []string configs, err = req.Storage.List(ctx, fmt.Sprintf("%s/", PathConfigStorage)) diff --git a/backend_test.go b/backend_test.go index 5ae0c24..0093673 100644 --- a/backend_test.go +++ b/backend_test.go @@ -1,3 +1,5 @@ +//go:build unit + package gitlab_test import ( @@ -12,7 +14,7 @@ import ( func TestBackend(t *testing.T) { var err error var b *gitlab.Backend - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") b, _, err = getBackend(ctx) require.NoError(t, err) require.NotNil(t, b) diff --git a/cmd/vault-plugin-secrets-gitlab/main.go b/cmd/vault-plugin-secrets-gitlab/main.go index 38c910e..82b50e7 100644 --- a/cmd/vault-plugin-secrets-gitlab/main.go +++ b/cmd/vault-plugin-secrets-gitlab/main.go @@ -6,6 +6,7 @@ import ( "github.com/hashicorp/go-hclog" "github.com/hashicorp/vault/api" "github.com/hashicorp/vault/sdk/plugin" + gat "github.com/ilijamt/vault-plugin-secrets-gitlab" ) diff --git a/defs_test.go b/defs_test.go index 4b3da30..d9643ab 100644 --- a/defs_test.go +++ b/defs_test.go @@ -1,4 +1,4 @@ -//go:build !integration +//go:build unit package gitlab_test diff --git a/entry_config.go b/entry_config.go index d07d080..601a668 100644 --- a/entry_config.go +++ b/entry_config.go @@ -14,16 +14,19 @@ import ( ) type EntryConfig struct { - TokenId int `json:"token_id" yaml:"token_id" mapstructure:"token_id"` - BaseURL string `json:"base_url" structs:"base_url" mapstructure:"base_url"` - Token string `json:"token" structs:"token" mapstructure:"token"` - AutoRotateToken bool `json:"auto_rotate_token" structs:"auto_rotate_token" mapstructure:"auto_rotate_token"` - AutoRotateBefore time.Duration `json:"auto_rotate_before" structs:"auto_rotate_before" mapstructure:"auto_rotate_before"` - TokenCreatedAt time.Time `json:"token_created_at" structs:"token_created_at" mapstructure:"token_created_at"` - TokenExpiresAt time.Time `json:"token_expires_at" structs:"token_expires_at" mapstructure:"token_expires_at"` - Scopes []string `json:"scopes" structs:"scopes" mapstructure:"scopes"` - Type Type `json:"type" structs:"type" mapstructure:"type"` - Name string `json:"name" structs:"name" mapstructure:"name"` + TokenId int `json:"token_id" yaml:"token_id" mapstructure:"token_id"` + BaseURL string `json:"base_url" structs:"base_url" mapstructure:"base_url"` + Token string `json:"token" structs:"token" mapstructure:"token"` + AutoRotateToken bool `json:"auto_rotate_token" structs:"auto_rotate_token" mapstructure:"auto_rotate_token"` + AutoRotateBefore time.Duration `json:"auto_rotate_before" structs:"auto_rotate_before" mapstructure:"auto_rotate_before"` + TokenCreatedAt time.Time `json:"token_created_at" structs:"token_created_at" mapstructure:"token_created_at"` + TokenExpiresAt time.Time `json:"token_expires_at" structs:"token_expires_at" mapstructure:"token_expires_at"` + Scopes []string `json:"scopes" structs:"scopes" mapstructure:"scopes"` + Type Type `json:"type" structs:"type" mapstructure:"type"` + Name string `json:"name" structs:"name" mapstructure:"name"` + GitlabVersion string `json:"gitlab_version" structs:"gitlab_version" mapstructure:"gitlab_version"` + GitlabRevision string `json:"gitlab_revision" structs:"gitlab_revision" mapstructure:"gitlab_revision"` + GitlabIsEnterprise bool `json:"gitlab_is_enterprise" structs:"gitlab_is_enterprise" mapstructure:"gitlab_is_enterprise"` } func (e *EntryConfig) Merge(data *framework.FieldData) (warnings []string, changes map[string]string, err error) { @@ -146,16 +149,19 @@ func (e *EntryConfig) LogicalResponseData() map[string]any { } return map[string]any{ - "base_url": e.BaseURL, - "auto_rotate_token": e.AutoRotateToken, - "auto_rotate_before": e.AutoRotateBefore.String(), - "token_id": e.TokenId, - "token_created_at": tokenCreatedAt, - "token_expires_at": tokenExpiresAt, - "token_sha1_hash": fmt.Sprintf("%x", sha1.Sum([]byte(e.Token))), - "scopes": strings.Join(e.Scopes, ", "), - "type": e.Type.String(), - "name": e.Name, + "base_url": e.BaseURL, + "auto_rotate_token": e.AutoRotateToken, + "auto_rotate_before": e.AutoRotateBefore.String(), + "token_id": e.TokenId, + "gitlab_version": e.GitlabVersion, + "gitlab_revision": e.GitlabRevision, + "gitlab_is_enterprise": e.GitlabIsEnterprise, + "token_created_at": tokenCreatedAt, + "token_expires_at": tokenExpiresAt, + "token_sha1_hash": fmt.Sprintf("%x", sha1.Sum([]byte(e.Token))), + "scopes": strings.Join(e.Scopes, ", "), + "type": e.Type.String(), + "name": e.Name, } } diff --git a/entry_config_merge_test.go b/entry_config_merge_test.go index 33ce6d3..8c7f32c 100644 --- a/entry_config_merge_test.go +++ b/entry_config_merge_test.go @@ -1,3 +1,5 @@ +//go:build unit + package gitlab_test import ( diff --git a/entry_config_update_form_field_data_test.go b/entry_config_update_form_field_data_test.go index 0497f8c..412106c 100644 --- a/entry_config_update_form_field_data_test.go +++ b/entry_config_update_form_field_data_test.go @@ -1,3 +1,5 @@ +//go:build unit + package gitlab_test import ( diff --git a/gitlab_client.go b/gitlab_client.go index 5a1c3de..a87a5e1 100644 --- a/gitlab_client.go +++ b/gitlab_client.go @@ -6,12 +6,13 @@ import ( "fmt" "io" "net/http" + "strconv" "strings" "time" "github.com/hashicorp/go-hclog" "github.com/hashicorp/vault/sdk/helper/logging" - g "github.com/xanzy/go-gitlab" + g "gitlab.com/gitlab-org/api/client-go" "golang.org/x/time/rate" ) @@ -23,6 +24,7 @@ var ( type Client interface { GitlabClient(ctx context.Context) *g.Client Valid(ctx context.Context) bool + Metadata(ctx context.Context) (*g.Metadata, error) CurrentTokenInfo(ctx context.Context) (*EntryToken, error) RotateCurrentToken(ctx context.Context) (newToken *EntryToken, oldToken *EntryToken, err error) CreatePersonalAccessToken(ctx context.Context, username string, userId int, name string, expiresAt time.Time, scopes []string) (*EntryToken, error) @@ -33,10 +35,17 @@ type Client interface { RevokeGroupAccessToken(ctx context.Context, tokenId int, groupId string) error GetUserIdByUsername(ctx context.Context, username string) (int, error) GetGroupIdByPath(ctx context.Context, path string) (int, error) + GetProjectIdByPath(ctx context.Context, path string) (int, error) CreateGroupServiceAccountAccessToken(ctx context.Context, group string, groupId string, userId int, name string, expiresAt time.Time, scopes []string) (*EntryToken, error) CreateUserServiceAccountAccessToken(ctx context.Context, username string, userId int, name string, expiresAt time.Time, scopes []string) (*EntryToken, error) RevokeUserServiceAccountAccessToken(ctx context.Context, token string) error RevokeGroupServiceAccountAccessToken(ctx context.Context, token string) error + CreatePipelineProjectTriggerAccessToken(ctx context.Context, path, name string, projectId int, description string, expiresAt *time.Time) (*EntryToken, error) + RevokePipelineProjectTriggerAccessToken(ctx context.Context, projectId int, tokenId int) error + CreateProjectDeployToken(ctx context.Context, path string, projectId int, name string, expiresAt *time.Time, scopes []string) (et *EntryToken, err error) + RevokeProjectDeployToken(ctx context.Context, projectId, deployTokenId int) (err error) + CreateGroupDeployToken(ctx context.Context, path string, groupId int, name string, expiresAt *time.Time, scopes []string) (et *EntryToken, err error) + RevokeGroupDeployToken(ctx context.Context, groupId, deployTokenId int) (err error) } type gitlabClient struct { @@ -46,6 +55,142 @@ type gitlabClient struct { logger hclog.Logger } +func (gc *gitlabClient) GetProjectIdByPath(ctx context.Context, path string) (projectId int, err error) { + defer func() { + gc.logger.Debug("Get project id by path", "path", path, "projectId", projectId, "error", err) + }() + + projectId = -1 + var project *g.Project + if project, _, err = gc.client.Projects.GetProject(path, &g.GetProjectOptions{}, g.WithContext(ctx)); err == nil { + projectId = project.ID + } + + return projectId, err +} + +func (gc *gitlabClient) CreateGroupDeployToken(ctx context.Context, path string, groupId int, name string, expiresAt *time.Time, scopes []string) (et *EntryToken, err error) { + var dt *g.DeployToken + defer func() { + gc.logger.Debug("Create group deploy token", "groupId", groupId, "name", name, "path", path, "expiresAt", expiresAt, "scopes", scopes, "error", err) + }() + + if dt, _, err = gc.client.DeployTokens.CreateGroupDeployToken( + groupId, + &g.CreateGroupDeployTokenOptions{ + Name: &name, + ExpiresAt: expiresAt, + Scopes: &scopes, + }, + g.WithContext(ctx), + ); err == nil { + et = &EntryToken{ + TokenID: dt.ID, + ParentID: strconv.Itoa(groupId), + Path: path, + Name: name, + Token: dt.Token, + TokenType: TokenTypeGroupDeploy, + Scopes: scopes, + AccessLevel: AccessLevelUnknown, + CreatedAt: g.Ptr(time.Now()), + } + } + return et, err +} + +func (gc *gitlabClient) CreateProjectDeployToken(ctx context.Context, path string, projectId int, name string, expiresAt *time.Time, scopes []string) (et *EntryToken, err error) { + var dt *g.DeployToken + defer func() { + gc.logger.Debug("Create project deploy token", "projectId", projectId, "name", name, "path", path, "expiresAt", expiresAt, "scopes", scopes, "error", err) + }() + if dt, _, err = gc.client.DeployTokens.CreateProjectDeployToken( + projectId, + &g.CreateProjectDeployTokenOptions{ + Name: &name, + ExpiresAt: expiresAt, + Scopes: &scopes, + }, + g.WithContext(ctx), + ); err == nil { + et = &EntryToken{ + TokenID: dt.ID, + ParentID: strconv.Itoa(projectId), + Path: path, + Name: name, + Token: dt.Token, + TokenType: TokenTypeProjectDeploy, + Scopes: scopes, + AccessLevel: AccessLevelUnknown, + CreatedAt: g.Ptr(time.Now()), + } + } + return et, err +} + +func (gc *gitlabClient) RevokeGroupDeployToken(ctx context.Context, groupId, deployTokenId int) (err error) { + defer func() { + gc.logger.Debug("Revoke group deploy token", "groupId", groupId, "deployTokenId", deployTokenId, "error", err) + }() + + _, err = gc.client.DeployTokens.DeleteGroupDeployToken(groupId, deployTokenId, g.WithContext(ctx)) + return err +} + +func (gc *gitlabClient) RevokeProjectDeployToken(ctx context.Context, projectId, deployTokenId int) (err error) { + defer func() { + gc.logger.Debug("Revoke project deploy token", "projectId", projectId, "deployTokenId", deployTokenId, "error", err) + }() + + _, err = gc.client.DeployTokens.DeleteProjectDeployToken(projectId, deployTokenId, g.WithContext(ctx)) + return err +} + +func (gc *gitlabClient) Metadata(ctx context.Context) (metadata *g.Metadata, err error) { + defer func() { + gc.logger.Debug("Fetch metadata information", "metadata", metadata, "error", err) + }() + + metadata, _, err = gc.client.Metadata.GetMetadata(g.WithContext(ctx)) + return metadata, err +} + +func (gc *gitlabClient) CreatePipelineProjectTriggerAccessToken(ctx context.Context, path, name string, projectId int, description string, expiresAt *time.Time) (et *EntryToken, err error) { + var pt *g.PipelineTrigger + defer func() { + gc.logger.Debug("Create a pipeline project trigger access token", "path", path, "name", name, "projectId", description, "description", "error", err) + }() + + if pt, _, err = gc.client.PipelineTriggers.AddPipelineTrigger( + projectId, + &g.AddPipelineTriggerOptions{Description: &description}, + g.WithContext(ctx), + ); err == nil { + et = &EntryToken{ + TokenID: pt.ID, + ParentID: strconv.Itoa(projectId), + Path: path, + Name: name, + Token: pt.Token, + TokenType: TokenTypePipelineProjectTrigger, + Scopes: []string{}, + AccessLevel: AccessLevelUnknown, + ExpiresAt: expiresAt, + } + } + + return et, err +} + +func (gc *gitlabClient) RevokePipelineProjectTriggerAccessToken(ctx context.Context, projectId int, tokenId int) (err error) { + defer func() { + gc.logger.Debug("Revoke pipeline project trigger access token", "projectId", projectId, "tokenId", tokenId, "error", err) + }() + + _, err = gc.client.PipelineTriggers.DeletePipelineTrigger(projectId, tokenId, g.WithContext(ctx)) + return err +} + func (gc *gitlabClient) GetGroupIdByPath(ctx context.Context, path string) (groupId int, err error) { defer func() { gc.logger.Debug("Get group id by path", "path", path, "groupId", groupId, "error", err) @@ -55,14 +200,14 @@ func (gc *gitlabClient) GetGroupIdByPath(ctx context.Context, path string) (grou Search: g.Ptr(path), } - g, _, err := gc.client.Groups.ListGroups(l) + groups, _, err := gc.client.Groups.ListGroups(l, g.WithContext(ctx)) if err != nil { return 0, fmt.Errorf("%v", err) } - if len(g) == 0 { + if len(groups) == 0 { return 0, fmt.Errorf("path '%s' not found: %w", path, ErrInvalidValue) } - groupId = g[0].ID + groupId = groups[0].ID return groupId, nil } @@ -74,13 +219,13 @@ func (gc *gitlabClient) GitlabClient(ctx context.Context) *g.Client { func (gc *gitlabClient) CreateGroupServiceAccountAccessToken(ctx context.Context, path string, groupId string, userId int, name string, expiresAt time.Time, scopes []string) (et *EntryToken, err error) { var at *g.PersonalAccessToken defer func() { - gc.logger.Debug("Created group service access token", "pat", at, "et", et, "path", path, "groupId", groupId, "userId", userId, "name", name, "expiresAt", expiresAt, "scopes", scopes, "error", err) + gc.logger.Debug("Create group service access token", "pat", at, "et", et, "path", path, "groupId", groupId, "userId", userId, "name", name, "expiresAt", expiresAt, "scopes", scopes, "error", err) }() at, _, err = gc.client.Groups.CreateServiceAccountPersonalAccessToken(groupId, userId, &g.CreateServiceAccountPersonalAccessTokenOptions{ Name: g.Ptr(name), ExpiresAt: (*g.ISOTime)(&expiresAt), Scopes: &scopes, - }) + }, g.WithContext(ctx)) if err == nil { et = &EntryToken{ TokenID: at.ID, @@ -101,7 +246,7 @@ func (gc *gitlabClient) CreateGroupServiceAccountAccessToken(ctx context.Context func (gc *gitlabClient) CreateUserServiceAccountAccessToken(ctx context.Context, username string, userId int, name string, expiresAt time.Time, scopes []string) (et *EntryToken, err error) { defer func() { - gc.logger.Debug("Created user service access token", "et", et, "username", username, "userId", userId, "name", name, "expiresAt", expiresAt, "scopes", scopes, "error", err) + gc.logger.Debug("Create user service access token", "et", et, "username", username, "userId", userId, "name", name, "expiresAt", expiresAt, "scopes", scopes, "error", err) }() et, err = gc.CreatePersonalAccessToken(ctx, username, userId, name, expiresAt, scopes) if err == nil && et != nil { @@ -122,7 +267,7 @@ func (gc *gitlabClient) RevokeUserServiceAccountAccessToken(ctx context.Context, BaseURL: gc.config.BaseURL, Token: token, }, gc.httpClient); err == nil { - _, err = c.PersonalAccessTokens.RevokePersonalAccessTokenSelf() + _, err = c.PersonalAccessTokens.RevokePersonalAccessTokenSelf(g.WithContext(ctx)) } return err @@ -140,7 +285,7 @@ func (gc *gitlabClient) RevokeGroupServiceAccountAccessToken(ctx context.Context BaseURL: gc.config.BaseURL, Token: token, }, gc.httpClient); err == nil { - _, err = c.PersonalAccessTokens.RevokePersonalAccessTokenSelf() + _, err = c.PersonalAccessTokens.RevokePersonalAccessTokenSelf(g.WithContext(ctx)) } return err @@ -149,24 +294,22 @@ func (gc *gitlabClient) RevokeGroupServiceAccountAccessToken(ctx context.Context func (gc *gitlabClient) CurrentTokenInfo(ctx context.Context) (et *EntryToken, err error) { var pat *g.PersonalAccessToken defer func() { gc.logger.Debug("Current token info", "token", et, "error", err) }() - pat, _, err = gc.client.PersonalAccessTokens.GetSinglePersonalAccessToken() - if err != nil { - return nil, err - } - et = &EntryToken{ - TokenID: pat.ID, - UserID: pat.UserID, - ParentID: "", - Path: "", - Name: pat.Name, - Token: pat.Token, - TokenType: TokenTypePersonal, - CreatedAt: pat.CreatedAt, - ExpiresAt: (*time.Time)(pat.ExpiresAt), - Scopes: pat.Scopes, - AccessLevel: "", + if pat, _, err = gc.client.PersonalAccessTokens.GetSinglePersonalAccessToken(g.WithContext(ctx)); err == nil { + et = &EntryToken{ + TokenID: pat.ID, + UserID: pat.UserID, + ParentID: "", + Path: "", + Name: pat.Name, + Token: pat.Token, + TokenType: TokenTypePersonal, + CreatedAt: pat.CreatedAt, + ExpiresAt: (*time.Time)(pat.ExpiresAt), + Scopes: pat.Scopes, + AccessLevel: "", + } } - return et, nil + return et, err } func (gc *gitlabClient) RotateCurrentToken(ctx context.Context) (token *EntryToken, currentEntryToken *EntryToken, err error) { @@ -235,7 +378,7 @@ func (gc *gitlabClient) GetUserIdByUsername(ctx context.Context, username string Username: g.Ptr(username), } - u, _, err := gc.client.Users.ListUsers(l) + u, _, err := gc.client.Users.ListUsers(l, g.WithContext(ctx)) if err != nil { return 0, fmt.Errorf("%v", err) } @@ -251,28 +394,26 @@ func (gc *gitlabClient) CreatePersonalAccessToken(ctx context.Context, username defer func() { gc.logger.Debug("Create personal access token", "pat", at, "et", et, "username", username, "userId", userId, "name", name, "expiresAt", expiresAt, "scopes", scopes, "error", err) }() - at, _, err = gc.client.Users.CreatePersonalAccessToken(userId, &g.CreatePersonalAccessTokenOptions{ + if at, _, err = gc.client.Users.CreatePersonalAccessToken(userId, &g.CreatePersonalAccessTokenOptions{ Name: g.Ptr(name), ExpiresAt: (*g.ISOTime)(&expiresAt), Scopes: &scopes, - }) - if err != nil { - return nil, err - } - et = &EntryToken{ - TokenID: at.ID, - UserID: userId, - ParentID: "", - Path: username, - Name: name, - Token: at.Token, - TokenType: TokenTypePersonal, - CreatedAt: at.CreatedAt, - ExpiresAt: (*time.Time)(at.ExpiresAt), - Scopes: scopes, - AccessLevel: AccessLevelUnknown, + }, g.WithContext(ctx)); err == nil { + et = &EntryToken{ + TokenID: at.ID, + UserID: userId, + ParentID: "", + Path: username, + Name: name, + Token: at.Token, + TokenType: TokenTypePersonal, + CreatedAt: at.CreatedAt, + ExpiresAt: (*time.Time)(at.ExpiresAt), + Scopes: scopes, + AccessLevel: AccessLevelUnknown, + } } - return et, nil + return et, err } func (gc *gitlabClient) CreateGroupAccessToken(ctx context.Context, groupId string, name string, expiresAt time.Time, scopes []string, accessLevel AccessLevel) (et *EntryToken, err error) { @@ -282,56 +423,57 @@ func (gc *gitlabClient) CreateGroupAccessToken(ctx context.Context, groupId stri }() var al = new(g.AccessLevelValue) *al = g.AccessLevelValue(accessLevel.Value()) - at, _, err = gc.client.GroupAccessTokens.CreateGroupAccessToken(groupId, &g.CreateGroupAccessTokenOptions{ + if at, _, err = gc.client.GroupAccessTokens.CreateGroupAccessToken(groupId, &g.CreateGroupAccessTokenOptions{ Name: g.Ptr(name), Scopes: &scopes, ExpiresAt: (*g.ISOTime)(&expiresAt), AccessLevel: al, - }) - if err != nil { - return nil, err + }, g.WithContext(ctx)); err == nil { + et = &EntryToken{ + TokenID: at.ID, + UserID: 0, + ParentID: groupId, + Path: groupId, + Name: name, + Token: at.Token, + TokenType: TokenTypeGroup, + CreatedAt: at.CreatedAt, + ExpiresAt: (*time.Time)(at.ExpiresAt), + Scopes: scopes, + AccessLevel: accessLevel, + } } - et = &EntryToken{ - TokenID: at.ID, - UserID: 0, - ParentID: groupId, - Path: groupId, - Name: name, - Token: at.Token, - TokenType: TokenTypeGroup, - CreatedAt: at.CreatedAt, - ExpiresAt: (*time.Time)(at.ExpiresAt), - Scopes: scopes, - AccessLevel: accessLevel, - } - return et, nil + return et, err } -func (gc *gitlabClient) CreateProjectAccessToken(ctx context.Context, projectId string, name string, expiresAt time.Time, scopes []string, accessLevel AccessLevel) (*EntryToken, error) { +func (gc *gitlabClient) CreateProjectAccessToken(ctx context.Context, projectId string, name string, expiresAt time.Time, scopes []string, accessLevel AccessLevel) (et *EntryToken, err error) { + var at *g.ProjectAccessToken + defer func() { + gc.logger.Debug("Create project access token", "gat", at, "et", et, "projectId", projectId, "name", name, "expiresAt", expiresAt, "scopes", scopes, "accessLevel", accessLevel, "error", err) + }() var al = new(g.AccessLevelValue) *al = g.AccessLevelValue(accessLevel.Value()) - at, _, err := gc.client.ProjectAccessTokens.CreateProjectAccessToken(projectId, &g.CreateProjectAccessTokenOptions{ + if at, _, err = gc.client.ProjectAccessTokens.CreateProjectAccessToken(projectId, &g.CreateProjectAccessTokenOptions{ Name: g.Ptr(name), Scopes: &scopes, ExpiresAt: (*g.ISOTime)(&expiresAt), AccessLevel: al, - }) - if err != nil { - return nil, err + }, g.WithContext(ctx)); err == nil { + et = &EntryToken{ + TokenID: at.ID, + UserID: 0, + ParentID: projectId, + Path: projectId, + Name: name, + Token: at.Token, + TokenType: TokenTypeProject, + CreatedAt: at.CreatedAt, + ExpiresAt: (*time.Time)(at.ExpiresAt), + Scopes: scopes, + AccessLevel: accessLevel, + } } - return &EntryToken{ - TokenID: at.ID, - UserID: 0, - ParentID: projectId, - Path: projectId, - Name: name, - Token: at.Token, - TokenType: TokenTypeProject, - CreatedAt: at.CreatedAt, - ExpiresAt: (*time.Time)(at.ExpiresAt), - Scopes: scopes, - AccessLevel: accessLevel, - }, nil + return et, err } func (gc *gitlabClient) RevokePersonalAccessToken(ctx context.Context, tokenId int) (err error) { @@ -339,7 +481,7 @@ func (gc *gitlabClient) RevokePersonalAccessToken(ctx context.Context, tokenId i gc.logger.Debug("Revoke personal access token", "tokenId", tokenId, "error", err) }() var resp *g.Response - resp, err = gc.client.PersonalAccessTokens.RevokePersonalAccessToken(tokenId) + resp, err = gc.client.PersonalAccessTokens.RevokePersonalAccessToken(tokenId, g.WithContext(ctx)) if resp != nil && resp.StatusCode == http.StatusNotFound { return fmt.Errorf("personal: %w", ErrAccessTokenNotFound) } @@ -354,7 +496,7 @@ func (gc *gitlabClient) RevokeProjectAccessToken(ctx context.Context, tokenId in gc.logger.Debug("Revoke project access token", "tokenId", tokenId, "error", err) }() var resp *g.Response - resp, err = gc.client.ProjectAccessTokens.RevokeProjectAccessToken(projectId, tokenId) + resp, err = gc.client.ProjectAccessTokens.RevokeProjectAccessToken(projectId, tokenId, g.WithContext(ctx)) if resp != nil && resp.StatusCode == http.StatusNotFound { return fmt.Errorf("project: %w", ErrAccessTokenNotFound) } @@ -369,7 +511,7 @@ func (gc *gitlabClient) RevokeGroupAccessToken(ctx context.Context, tokenId int, gc.logger.Debug("Revoke group access token", "tokenId", tokenId, "error", err) }() var resp *g.Response - resp, err = gc.client.GroupAccessTokens.RevokeGroupAccessToken(groupId, tokenId) + resp, err = gc.client.GroupAccessTokens.RevokeGroupAccessToken(groupId, tokenId, g.WithContext(ctx)) if resp != nil && resp.StatusCode == http.StatusNotFound { return fmt.Errorf("group: %w", ErrAccessTokenNotFound) } diff --git a/gitlab_client_test.go b/gitlab_client_test.go index bb875b9..77d7c39 100644 --- a/gitlab_client_test.go +++ b/gitlab_client_test.go @@ -1,3 +1,5 @@ +//go:build unit + package gitlab_test import ( @@ -58,7 +60,7 @@ func TestGitlabClient(t *testing.T) { func TestGitlabClient_InvalidToken(t *testing.T) { ctx, timeExpiresAt := ctxTestTime(context.Background(), t.Name()) var err error - httpClient, url := getClient(t) + httpClient, url := getClient(t, "unit") var client gitlab.Client client, err = gitlab.NewGitlabClient(&gitlab.EntryConfig{ Token: "super-secret-token", @@ -101,7 +103,7 @@ func TestGitlabClient_InvalidToken(t *testing.T) { func TestGitlabClient_RevokeToken_NotFound(t *testing.T) { var ctx = context.Background() var err error - httpClient, url := getClient(t) + httpClient, url := getClient(t, "unit") var client gitlab.Client client, err = gitlab.NewGitlabClient(&gitlab.EntryConfig{ Token: "glpat-secret-random-token", @@ -120,7 +122,7 @@ func TestGitlabClient_RevokeToken_NotFound(t *testing.T) { func TestGitlabClient_GetGroupIdByPath(t *testing.T) { var ctx = context.Background() var err error - httpClient, url := getClient(t) + httpClient, url := getClient(t, "unit") var client gitlab.Client client, err = gitlab.NewGitlabClient(&gitlab.EntryConfig{ Token: "glpat-secret-random-token", @@ -141,7 +143,7 @@ func TestGitlabClient_GetGroupIdByPath(t *testing.T) { func TestGitlabClient_GetUserIdByUsername(t *testing.T) { var ctx = context.Background() var err error - httpClient, url := getClient(t) + httpClient, url := getClient(t, "unit") var client gitlab.Client client, err = gitlab.NewGitlabClient(&gitlab.EntryConfig{ Token: "glpat-secret-random-token", @@ -159,7 +161,7 @@ func TestGitlabClient_GetUserIdByUsername(t *testing.T) { func TestGitlabClient_GetUserIdByUsernameDoesNotMatch(t *testing.T) { var err error var ctx = context.Background() - httpClient, url := getClient(t) + httpClient, url := getClient(t, "unit") var client gitlab.Client client, err = gitlab.NewGitlabClient(&gitlab.EntryConfig{ Token: "glpat-secret-random-token", @@ -181,7 +183,7 @@ func TestGitlabClient_GetUserIdByUsernameDoesNotMatch(t *testing.T) { func TestGitlabClient_Revoke_NonExistingTokens(t *testing.T) { var ctx = context.Background() var err error - httpClient, url := getClient(t) + httpClient, url := getClient(t, "unit") var client gitlab.Client client, err = gitlab.NewGitlabClient(&gitlab.EntryConfig{ Token: "glpat-secret-random-token", @@ -199,7 +201,7 @@ func TestGitlabClient_Revoke_NonExistingTokens(t *testing.T) { func TestGitlabClient_CurrentTokenInfo(t *testing.T) { var err error var ctx = context.Background() - httpClient, url := getClient(t) + httpClient, url := getClient(t, "unit") var client gitlab.Client client, err = gitlab.NewGitlabClient(&gitlab.EntryConfig{ Token: "glpat-secret-random-token", @@ -215,10 +217,28 @@ func TestGitlabClient_CurrentTokenInfo(t *testing.T) { assert.EqualValues(t, gitlab.TokenTypePersonal, token.TokenType) } +func TestGitlabClient_Metadata(t *testing.T) { + var err error + var ctx = context.Background() + httpClient, url := getClient(t, "unit") + var client gitlab.Client + client, err = gitlab.NewGitlabClient(&gitlab.EntryConfig{ + Token: "glpat-secret-random-token", + BaseURL: url, + }, httpClient, nil) + require.NoError(t, err) + require.NotNil(t, client) + require.True(t, client.Valid(ctx)) + + metadata, err := client.Metadata(ctx) + require.NoError(t, err) + require.NotNil(t, metadata) +} + func TestGitlabClient_CreateAccessToken_And_Revoke(t *testing.T) { var err error ctx, timeExpiresAt := ctxTestTime(context.Background(), t.Name()) - httpClient, url := getClient(t) + httpClient, url := getClient(t, "unit") var client gitlab.Client client, err = gitlab.NewGitlabClient(&gitlab.EntryConfig{ Token: "glpat-secret-random-token", @@ -274,7 +294,7 @@ func TestGitlabClient_CreateAccessToken_And_Revoke(t *testing.T) { func TestGitlabClient_RotateCurrentToken(t *testing.T) { var err error var ctx = context.Background() - httpClient, url := getClient(t) + httpClient, url := getClient(t, "unit") var client gitlab.Client client, err = gitlab.NewGitlabClient(&gitlab.EntryConfig{ Token: "glpat-secret-admin-token-ar1", diff --git a/gitlab_record_client_test.go b/gitlab_record_client_test.go index e58f92a..ceddc81 100644 --- a/gitlab_record_client_test.go +++ b/gitlab_record_client_test.go @@ -1,3 +1,5 @@ +//go:build unit || saas || selfhosted || local + package gitlab_test import ( @@ -11,10 +13,10 @@ import ( "gopkg.in/dnaeon/go-vcr.v4/pkg/recorder" ) -func getClient(t *testing.T) (client *http.Client, u string) { +func getClient(t *testing.T, target string) (client *http.Client, u string) { t.Helper() - filename := fmt.Sprintf("testdata/fixtures/%s/%s", gitlabVersion, sanitizePath(t.Name())) + filename := fmt.Sprintf("testdata/%s/%s", target, sanitizePath(t.Name())) r, err := recorder.New(filename, []recorder.Option{ recorder.WithMode(recorder.ModeRecordOnce), diff --git a/gitlab_type_test.go b/gitlab_type_test.go index 8f04b21..3dafdad 100644 --- a/gitlab_type_test.go +++ b/gitlab_type_test.go @@ -1,3 +1,5 @@ +//go:build unit + package gitlab_test import ( diff --git a/gitlab_version_test.go b/gitlab_version_test.go index 94dceff..493e18b 100644 --- a/gitlab_version_test.go +++ b/gitlab_version_test.go @@ -1,3 +1,5 @@ +//go:build unit || saas || selfhosted || local + package gitlab_test const ( diff --git a/go.mod b/go.mod index a571ee0..a5a9ea4 100644 --- a/go.mod +++ b/go.mod @@ -3,12 +3,13 @@ module github.com/ilijamt/vault-plugin-secrets-gitlab go 1.22 require ( + github.com/google/uuid v1.6.0 github.com/hashicorp/go-hclog v1.6.3 github.com/hashicorp/go-multierror v1.1.1 github.com/hashicorp/vault/api v1.15.0 github.com/hashicorp/vault/sdk v0.14.0 github.com/stretchr/testify v1.10.0 - github.com/xanzy/go-gitlab v0.114.0 + gitlab.com/gitlab-org/api/client-go v0.116.0 golang.org/x/time v0.8.0 google.golang.org/protobuf v1.35.2 gopkg.in/dnaeon/go-vcr.v4 v4.0.2 @@ -83,7 +84,7 @@ require ( golang.org/x/crypto v0.28.0 // indirect golang.org/x/mod v0.20.0 // indirect golang.org/x/net v0.30.0 // indirect - golang.org/x/oauth2 v0.23.0 // indirect + golang.org/x/oauth2 v0.24.0 // indirect golang.org/x/sync v0.8.0 // indirect golang.org/x/sys v0.26.0 // indirect golang.org/x/text v0.19.0 // indirect diff --git a/go.sum b/go.sum index b53db61..4a7602a 100644 --- a/go.sum +++ b/go.sum @@ -239,10 +239,10 @@ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1F github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= -github.com/xanzy/go-gitlab v0.114.0 h1:0wQr/KBckwrZPfEMjRqpUz0HmsKKON9UhCYv9KDy19M= -github.com/xanzy/go-gitlab v0.114.0/go.mod h1:wKNKh3GkYDMOsGmnfuX+ITCmDuSDWFO0G+C4AygL9RY= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +gitlab.com/gitlab-org/api/client-go v0.116.0 h1:Dy534gtZPMrnm3fAcmQRMadrcoUyFO4FQ4rXlSAdHAw= +gitlab.com/gitlab-org/api/client-go v0.116.0/go.mod h1:B29OfnZklmaoiR7uHANh9jTyfWEgmXvZLVEnosw2Dx0= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0 h1:Xs2Ncz0gNihqu9iosIZ5SkBbWo5T8JhhLJFMQL1qmLI= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0/go.mod h1:vy+2G/6NvVMpwGX/NyLqcC41fxepnuKHk16E6IZUcJc= go.opentelemetry.io/otel v1.30.0 h1:F2t8sK4qf1fAmY9ua4ohFS/K+FUuOPemHUIXHtktrts= @@ -279,8 +279,8 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= -golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= -golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE= +golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/helpers_test.go b/helpers_test.go index a1b7159..31d94bf 100644 --- a/helpers_test.go +++ b/helpers_test.go @@ -1,3 +1,5 @@ +//go:build unit || saas || selfhosted || local + package gitlab_test import ( @@ -8,22 +10,26 @@ import ( "io" "os" "slices" + "strconv" "strings" "sync" "testing" "time" "unicode" + "github.com/google/uuid" log "github.com/hashicorp/go-hclog" "github.com/hashicorp/go-multierror" "github.com/hashicorp/vault/sdk/helper/logging" "github.com/hashicorp/vault/sdk/logical" "github.com/stretchr/testify/require" - g "github.com/xanzy/go-gitlab" + g "gitlab.com/gitlab-org/api/client-go" gitlab "github.com/ilijamt/vault-plugin-secrets-gitlab" ) +var _ gitlab.Client = new(inMemoryClient) + var ( gitlabComPersonalAccessToken = cmp.Or(os.Getenv("GITLAB_COM_TOKEN"), "glpat-invalid-value") gitlabComUrl = cmp.Or(os.Getenv("GITLAB_COM_URL"), "https://gitlab.com") @@ -164,6 +170,14 @@ type inMemoryClient struct { revokeGroupServiceAccountPersonalAccessTokenError bool createUserServiceAccountAccessTokenError bool createGroupServiceAccountAccessTokenError bool + createPipelineProjectTriggerAccessTokenError bool + revokePipelineProjectTriggerAccessTokenError bool + metadataError bool + revokeProjectDeployTokenError bool + revokeGroupDeployTokenError bool + createProjectDeployTokenError bool + createGroupDeployTokenError bool + getProjectIdByPathError bool calledMainToken int calledRotateMainToken int @@ -173,6 +187,128 @@ type inMemoryClient struct { rotateMainToken gitlab.EntryToken accessTokens map[string]gitlab.EntryToken + + valueGetProjectIdByPath int +} + +func (i *inMemoryClient) GetProjectIdByPath(ctx context.Context, path string) (int, error) { + if i.getProjectIdByPathError { + return -1, fmt.Errorf("unable to get project id by path") + } + return i.valueGetProjectIdByPath, nil +} + +func (i *inMemoryClient) CreateProjectDeployToken(ctx context.Context, path string, projectId int, name string, expiresAt *time.Time, scopes []string) (et *gitlab.EntryToken, err error) { + i.muLock.Lock() + defer i.muLock.Unlock() + if i.createProjectDeployTokenError { + return nil, fmt.Errorf("unable to create project deploy token") + } + i.internalCounter++ + var tokenId = i.internalCounter + key := fmt.Sprintf("%s_%v_%v", gitlab.TokenTypeProjectDeploy.String(), projectId, tokenId) + var entryToken = gitlab.EntryToken{ + TokenID: tokenId, + ParentID: strconv.Itoa(projectId), + Path: path, + Name: name, + Token: fmt.Sprintf("glpat-%s", uuid.New().String()), + TokenType: gitlab.TokenTypeProjectDeploy, + ExpiresAt: expiresAt, + CreatedAt: g.Ptr(time.Now()), + } + i.accessTokens[key] = entryToken + return &entryToken, nil +} + +func (i *inMemoryClient) CreateGroupDeployToken(ctx context.Context, path string, groupId int, name string, expiresAt *time.Time, scopes []string) (et *gitlab.EntryToken, err error) { + i.muLock.Lock() + defer i.muLock.Unlock() + if i.createGroupDeployTokenError { + return nil, fmt.Errorf("unable to create project deploy token") + } + i.internalCounter++ + var tokenId = i.internalCounter + key := fmt.Sprintf("%s_%v_%v", gitlab.TokenTypeGroupDeploy.String(), groupId, tokenId) + var entryToken = gitlab.EntryToken{ + TokenID: tokenId, + ParentID: strconv.Itoa(groupId), + Path: path, + Name: name, + Token: fmt.Sprintf("glpat-%s", uuid.New().String()), + TokenType: gitlab.TokenTypeGroupDeploy, + ExpiresAt: expiresAt, + CreatedAt: g.Ptr(time.Now()), + } + i.accessTokens[key] = entryToken + return &entryToken, nil +} + +func (i *inMemoryClient) RevokeProjectDeployToken(ctx context.Context, projectId, deployTokenId int) (err error) { + i.muLock.Lock() + defer i.muLock.Unlock() + if i.revokeProjectDeployTokenError { + return errors.New("revoke project deploy token error") + } + key := fmt.Sprintf("%s_%v_%v", gitlab.TokenTypeProjectDeploy.String(), projectId, deployTokenId) + delete(i.accessTokens, key) + return nil +} + +func (i *inMemoryClient) RevokeGroupDeployToken(ctx context.Context, groupId, deployTokenId int) (err error) { + i.muLock.Lock() + defer i.muLock.Unlock() + if i.revokeGroupDeployTokenError { + return errors.New("revoke group deploy token error") + } + key := fmt.Sprintf("%s_%v_%v", gitlab.TokenTypeGroupDeploy.String(), groupId, deployTokenId) + delete(i.accessTokens, key) + return nil +} + +func (i *inMemoryClient) Metadata(ctx context.Context) (*g.Metadata, error) { + if i.metadataError { + return nil, errors.New("metadata error") + } + return &g.Metadata{ + Version: "version", + Revision: "revision", + Enterprise: false, + }, nil +} + +func (i *inMemoryClient) CreatePipelineProjectTriggerAccessToken(ctx context.Context, path, name string, projectId int, description string, expiresAt *time.Time) (et *gitlab.EntryToken, err error) { + i.muLock.Lock() + defer i.muLock.Unlock() + if i.createPipelineProjectTriggerAccessTokenError { + return nil, fmt.Errorf("CreatePipelineProjectTriggerAccessToken") + } + i.internalCounter++ + var tokenId = i.internalCounter + key := fmt.Sprintf("%s_%v_%v", gitlab.TokenTypePipelineProjectTrigger.String(), projectId, tokenId) + var entryToken = gitlab.EntryToken{ + TokenID: tokenId, + ParentID: strconv.Itoa(projectId), + Path: strconv.Itoa(projectId), + Name: name, + Token: fmt.Sprintf("glptt-%s", uuid.New().String()), + TokenType: gitlab.TokenTypePipelineProjectTrigger, + ExpiresAt: expiresAt, + CreatedAt: g.Ptr(time.Now()), + } + i.accessTokens[key] = entryToken + return &entryToken, nil +} + +func (i *inMemoryClient) RevokePipelineProjectTriggerAccessToken(ctx context.Context, projectId int, tokenId int) error { + i.muLock.Lock() + defer i.muLock.Unlock() + if i.revokePipelineProjectTriggerAccessTokenError { + return fmt.Errorf("RevokePipelineProjectTriggerAccessToken") + } + key := fmt.Sprintf("%s_%v_%v", gitlab.TokenTypePipelineProjectTrigger.String(), projectId, tokenId) + delete(i.accessTokens, key) + return nil } func (i *inMemoryClient) GetGroupIdByPath(ctx context.Context, path string) (int, error) { @@ -361,8 +497,6 @@ func (i *inMemoryClient) GetUserIdByUsername(ctx context.Context, username strin return idx, nil } -var _ gitlab.Client = new(inMemoryClient) - func sanitizePath(path string) string { var builder strings.Builder @@ -377,22 +511,34 @@ func sanitizePath(path string) string { return strings.ReplaceAll(builder.String(), "__", "_") } -func getCtxGitlabClient(t *testing.T) context.Context { - httpClient, _ := getClient(t) +func getCtxGitlabClient(t *testing.T, target string) context.Context { + httpClient, _ := getClient(t, target) return gitlab.HttpClientNewContext(context.Background(), httpClient) } -func getCtxGitlabClientWithUrl(t *testing.T) (context.Context, string) { - httpClient, url := getClient(t) +func getCtxGitlabClientWithUrl(t *testing.T, target string) (context.Context, string) { + httpClient, url := getClient(t, target) return gitlab.HttpClientNewContext(context.Background(), httpClient), url } func ctxTestTime(ctx context.Context, tn string) (_ context.Context, t time.Time) { switch tn { case "TestGitlabClient_RotateCurrentToken", "TestWithGitlabUser_RotateToken": - t = time.Date(2024, 8, 12, 0, 0, 0, 0, time.UTC) - default: t = time.Date(2024, 12, 12, 0, 0, 0, 0, time.UTC) + default: + t = time.Date(2025, 3, 12, 0, 0, 0, 0, time.UTC) } return gitlab.WithStaticTime(ctx, t), t } + +func filterSlice[T any, Slice ~[]T](collection Slice, predicate func(item T, index int) bool) Slice { + result := make(Slice, 0, len(collection)) + + for i := range collection { + if predicate(collection[i], i) { + result = append(result, collection[i]) + } + } + + return result +} diff --git a/name_tpl_rand_string_test.go b/name_tpl_rand_string_test.go index 468a7fb..f079f87 100644 --- a/name_tpl_rand_string_test.go +++ b/name_tpl_rand_string_test.go @@ -1,3 +1,5 @@ +//go:build unit + package gitlab_test import ( diff --git a/name_tpl_test.go b/name_tpl_test.go index aef26a3..dd534b8 100644 --- a/name_tpl_test.go +++ b/name_tpl_test.go @@ -1,3 +1,5 @@ +//go:build unit + package gitlab_test import ( diff --git a/name_tpl_unix_timestamp_test.go b/name_tpl_unix_timestamp_test.go index 4dde7a0..7579786 100644 --- a/name_tpl_unix_timestamp_test.go +++ b/name_tpl_unix_timestamp_test.go @@ -1,3 +1,5 @@ +//go:build unit + package gitlab_test import ( diff --git a/path_config.go b/path_config.go index 6e3ca0d..3839261 100644 --- a/path_config.go +++ b/path_config.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/vault/sdk/framework" "github.com/hashicorp/vault/sdk/logical" + g "gitlab.com/gitlab-org/api/client-go" ) const ( @@ -171,6 +172,13 @@ func (b *Backend) updateConfigClientInfo(ctx context.Context, config *EntryConfi config.TokenId = et.TokenID config.Scopes = et.Scopes + var metadata *g.Metadata + if metadata, err = client.Metadata(ctx); err == nil { + config.GitlabVersion = metadata.Version + config.GitlabRevision = metadata.Revision + config.GitlabIsEnterprise = metadata.Enterprise + } + return et, nil } diff --git a/path_config_list_test.go b/path_config_list_test.go index 27a5932..fc4dd31 100644 --- a/path_config_list_test.go +++ b/path_config_list_test.go @@ -1,3 +1,5 @@ +//go:build unit + package gitlab_test import ( @@ -16,7 +18,7 @@ import ( func TestPathConfigList(t *testing.T) { t.Run("empty list", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackend(ctx) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -30,7 +32,7 @@ func TestPathConfigList(t *testing.T) { }) t.Run("multiple configs", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, events, err = getBackendWithEventsAndConfigName(ctx, map[string]any{ "token": "glpat-secret-random-token", diff --git a/path_config_rotate.go b/path_config_rotate.go index 64f6f15..1f0016b 100644 --- a/path_config_rotate.go +++ b/path_config_rotate.go @@ -108,12 +108,13 @@ func (b *Backend) pathConfigTokenRotate(ctx context.Context, request *logical.Re lResp = &logical.Response{Data: config.LogicalResponseData()} lResp.Data["token"] = config.Token event(ctx, b.Backend, "config-token-rotate", map[string]string{ - "path": fmt.Sprintf("%s/%s", PathConfigStorage, name), - "expires_at": entryToken.ExpiresAt.Format(time.RFC3339), - "created_at": entryToken.CreatedAt.Format(time.RFC3339), - "scopes": strings.Join(entryToken.Scopes, ", "), - "token_id": strconv.Itoa(entryToken.TokenID), - "name": entryToken.Name, + "path": fmt.Sprintf("%s/%s", PathConfigStorage, name), + "expires_at": entryToken.ExpiresAt.Format(time.RFC3339), + "created_at": entryToken.CreatedAt.Format(time.RFC3339), + "scopes": strings.Join(entryToken.Scopes, ", "), + "token_id": strconv.Itoa(entryToken.TokenID), + "name": entryToken.Name, + "config_name": entryToken.ConfigName, }) b.SetClient(nil, name) diff --git a/path_config_rotate_test.go b/path_config_rotate_test.go index c2de920..5646dac 100644 --- a/path_config_rotate_test.go +++ b/path_config_rotate_test.go @@ -1,3 +1,5 @@ +//go:build unit + package gitlab_test import ( @@ -12,7 +14,7 @@ import ( func TestPathConfigRotate(t *testing.T) { t.Run("initial config should be empty fail with backend not configured", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") b, l, err := getBackend(ctx) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ diff --git a/path_config_test.go b/path_config_test.go index 79cffe1..e2037f2 100644 --- a/path_config_test.go +++ b/path_config_test.go @@ -1,3 +1,5 @@ +//go:build unit + package gitlab_test import ( @@ -15,7 +17,7 @@ import ( func TestPathConfig(t *testing.T) { t.Run("initial config should be empty fail with backend not configured", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") b, l, err := getBackend(ctx) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -29,7 +31,7 @@ func TestPathConfig(t *testing.T) { }) t.Run("deleting uninitialized config should fail with backend not configured", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") b, l, err := getBackend(ctx) require.NoError(t, err) @@ -45,7 +47,7 @@ func TestPathConfig(t *testing.T) { }) t.Run("write, read, delete and read config", func(t *testing.T) { - httpClient, url := getClient(t) + httpClient, url := getClient(t, "unit") ctx := gitlab.HttpClientNewContext(context.Background(), httpClient) b, l, events, err := getBackendWithEvents(ctx) @@ -101,7 +103,7 @@ func TestPathConfig(t *testing.T) { }) t.Run("invalid token", func(t *testing.T) { - httpClient, url := getClient(t) + httpClient, url := getClient(t, "unit") ctx := gitlab.HttpClientNewContext(context.Background(), httpClient) b, l, events, err := getBackendWithEvents(ctx) @@ -124,7 +126,7 @@ func TestPathConfig(t *testing.T) { }) t.Run("missing token from the request", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") b, l, err := getBackend(ctx) require.NoError(t, err) @@ -143,7 +145,7 @@ func TestPathConfig(t *testing.T) { }) t.Run("patch a config with no storage", func(t *testing.T) { - httpClient, url := getClient(t) + httpClient, url := getClient(t, "unit") ctx := gitlab.HttpClientNewContext(context.Background(), httpClient) b, _, err := getBackend(ctx) @@ -164,7 +166,7 @@ func TestPathConfig(t *testing.T) { }) t.Run("patch a config no backend", func(t *testing.T) { - httpClient, url := getClient(t) + httpClient, url := getClient(t, "unit") ctx := gitlab.HttpClientNewContext(context.Background(), httpClient) b, l, err := getBackend(ctx) @@ -186,7 +188,7 @@ func TestPathConfig(t *testing.T) { }) t.Run("patch a config", func(t *testing.T) { - httpClient, url := getClient(t) + httpClient, url := getClient(t, "unit") ctx := gitlab.HttpClientNewContext(context.Background(), httpClient) var path = fmt.Sprintf("%s/%s", gitlab.PathConfigStorage, gitlab.DefaultConfigName) diff --git a/path_config_token_autorotate_test.go b/path_config_token_autorotate_test.go index 1439db4..290f5a7 100644 --- a/path_config_token_autorotate_test.go +++ b/path_config_token_autorotate_test.go @@ -1,3 +1,5 @@ +//go:build unit + package gitlab_test import ( @@ -14,7 +16,7 @@ import ( func TestPathConfig_AutoRotate(t *testing.T) { t.Run("auto_rotate_token should be false if not specified", func(t *testing.T) { - ctx, url := getCtxGitlabClientWithUrl(t) + ctx, url := getCtxGitlabClientWithUrl(t, "unit") b, l, err := getBackend(ctx) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -32,7 +34,7 @@ func TestPathConfig_AutoRotate(t *testing.T) { }) t.Run("auto_rotate_before cannot be more than the minimal value", func(t *testing.T) { - ctx, url := getCtxGitlabClientWithUrl(t) + ctx, url := getCtxGitlabClientWithUrl(t, "unit") b, l, err := getBackend(ctx) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -51,7 +53,7 @@ func TestPathConfig_AutoRotate(t *testing.T) { }) t.Run("auto_rotate_before should be less than the maximal limit", func(t *testing.T) { - ctx, url := getCtxGitlabClientWithUrl(t) + ctx, url := getCtxGitlabClientWithUrl(t, "unit") b, l, err := getBackend(ctx) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -69,7 +71,7 @@ func TestPathConfig_AutoRotate(t *testing.T) { }) t.Run("auto_rotate_before should be set to correct value", func(t *testing.T) { - ctx, url := getCtxGitlabClientWithUrl(t) + ctx, url := getCtxGitlabClientWithUrl(t, "unit") b, l, err := getBackend(ctx) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -88,7 +90,7 @@ func TestPathConfig_AutoRotate(t *testing.T) { }) t.Run("auto_rotate_before should be more than the minimal limit", func(t *testing.T) { - ctx, url := getCtxGitlabClientWithUrl(t) + ctx, url := getCtxGitlabClientWithUrl(t, "unit") b, l, err := getBackend(ctx) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -106,7 +108,7 @@ func TestPathConfig_AutoRotate(t *testing.T) { }) t.Run("auto_rotate_before should be set to min if not specified", func(t *testing.T) { - ctx, url := getCtxGitlabClientWithUrl(t) + ctx, url := getCtxGitlabClientWithUrl(t, "unit") b, l, err := getBackend(ctx) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -124,7 +126,7 @@ func TestPathConfig_AutoRotate(t *testing.T) { }) t.Run("auto_rotate_before should be between the min and max value", func(t *testing.T) { - ctx, url := getCtxGitlabClientWithUrl(t) + ctx, url := getCtxGitlabClientWithUrl(t, "unit") b, l, err := getBackend(ctx) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -144,7 +146,7 @@ func TestPathConfig_AutoRotate(t *testing.T) { func TestPathConfig_AutoRotateToken(t *testing.T) { t.Run("no error when auto rotate is disabled and config is not set", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") b, l, err := getBackend(ctx) require.NoError(t, err) @@ -154,7 +156,7 @@ func TestPathConfig_AutoRotateToken(t *testing.T) { t.Run("no error when auto rotate is disabled and config is set", func(t *testing.T) { var client = newInMemoryClient(true) - ctx, url := getCtxGitlabClientWithUrl(t) + ctx, url := getCtxGitlabClientWithUrl(t, "unit") ctx = gitlab.GitlabClientNewContext(ctx, client) b, l, err := getBackendWithConfig(ctx, map[string]any{ "token": "glpat-secret-token", @@ -170,7 +172,7 @@ func TestPathConfig_AutoRotateToken(t *testing.T) { t.Run("call auto rotate the main token and rotate the token", func(t *testing.T) { var client = newInMemoryClient(true) - ctx, url := getCtxGitlabClientWithUrl(t) + ctx, url := getCtxGitlabClientWithUrl(t, "unit") ctx = gitlab.GitlabClientNewContext(ctx, newInMemoryClient(true)) b, l, events, err := getBackendWithEventsAndConfig(ctx, map[string]any{ "token": "token", @@ -221,7 +223,7 @@ func TestPathConfig_AutoRotateToken(t *testing.T) { t.Run("call auto rotate the main token but the token is still valid", func(t *testing.T) { var client = newInMemoryClient(true) - ctx, url := getCtxGitlabClientWithUrl(t) + ctx, url := getCtxGitlabClientWithUrl(t, "unit") ctx = gitlab.GitlabClientNewContext(ctx, newInMemoryClient(true)) b, l, err := getBackendWithConfig(ctx, map[string]any{ "token": "token", diff --git a/path_role.go b/path_role.go index 611c102..f733070 100644 --- a/path_role.go +++ b/path_role.go @@ -59,7 +59,7 @@ var ( "ttl": { Type: framework.TypeDurationSecond, Description: "The TTL of the token", - Required: true, + Required: false, DisplayAttrs: &framework.DisplayAttributes{ Name: "Token TTL", }, @@ -103,13 +103,16 @@ var ( } ) -func (b *Backend) pathRolesList(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) { - roles, err := req.Storage.List(ctx, fmt.Sprintf("%s/", PathRoleStorage)) - if err != nil { - return logical.ErrorResponse("Error listing roles"), err +func (b *Backend) pathRolesList(ctx context.Context, req *logical.Request, data *framework.FieldData) (l *logical.Response, err error) { + var roles []string + defer func() { + b.Logger().Debug("Available", "roles", roles, "err", err) + }() + l = logical.ErrorResponse("Error listing roles") + if roles, err = req.Storage.List(ctx, fmt.Sprintf("%s/", PathRoleStorage)); err == nil { + l = logical.ListResponse(roles) } - b.Logger().Debug("Available", "roles", roles) - return logical.ListResponse(roles), nil + return l, err } func pathListRoles(b *Backend) *framework.Path { @@ -143,12 +146,7 @@ func pathListRoles(b *Backend) *framework.Path { func (b *Backend) pathRolesDelete(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) { var resp *logical.Response var err error - var roleName string - - if roleName = data.Get("role_name").(string); roleName == "" { - return logical.ErrorResponse("Unable to delete, missing role name"), nil - } - + var roleName = data.Get("role_name").(string) lock := locksutil.LockForKey(b.roleLocks, roleName) lock.RLock() defer lock.RUnlock() @@ -174,10 +172,7 @@ func (b *Backend) pathRolesDelete(ctx context.Context, req *logical.Request, dat } func (b *Backend) pathRolesRead(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) { - var roleName string - if roleName = data.Get("role_name").(string); roleName == "" { - return logical.ErrorResponse("Unable to read, missing role name"), nil - } + var roleName = data.Get("role_name").(string) lock := locksutil.LockForKey(b.roleLocks, roleName) lock.RLock() @@ -200,11 +195,7 @@ func (b *Backend) pathRolesRead(ctx context.Context, req *logical.Request, data } func (b *Backend) pathRolesWrite(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) { - var roleName string - if roleName = data.Get("role_name").(string); roleName == "" { - return logical.ErrorResponse("Unable to write, missing role name"), nil - } - + var roleName = data.Get("role_name").(string) var config *EntryConfig var err error var warnings []string @@ -250,22 +241,45 @@ func (b *Backend) pathRolesWrite(ctx context.Context, req *logical.Request, data var skipFields = []string{"config_name"} - // validate access level + // validate access level and which fields to skip for validation var validAccessLevels []string + var invalidScopes []string + var validScopes []string + var noEmptyScopes bool + switch tokenType { case TokenTypePersonal: validAccessLevels = ValidPersonalAccessLevels + validScopes = slices.Concat(validTokenScopes, ValidPersonalTokenScopes) skipFields = append(skipFields, "access_level") case TokenTypeGroup: validAccessLevels = ValidGroupAccessLevels + validScopes = validTokenScopes case TokenTypeProject: validAccessLevels = ValidProjectAccessLevels + validScopes = validTokenScopes case TokenTypeUserServiceAccount: validAccessLevels = ValidUserServiceAccountAccessLevels + validScopes = slices.Concat(validTokenScopes, ValidPersonalTokenScopes, ValidUserServiceAccountTokenScopes) skipFields = append(skipFields, "access_level") case TokenTypeGroupServiceAccount: validAccessLevels = ValidGroupServiceAccountAccessLevels + validScopes = slices.Concat(validTokenScopes, ValidPersonalTokenScopes, ValidGroupServiceAccountTokenScopes) + skipFields = append(skipFields, "access_level") + case TokenTypePipelineProjectTrigger: + validAccessLevels = ValidPipelineProjectTriggerAccessLevels + validScopes = []string{} + skipFields = append(skipFields, "access_level", "scopes") + case TokenTypeProjectDeploy: + validAccessLevels = ValidProjectDeployAccessLevels + validScopes = ValidProjectDeployTokenScopes skipFields = append(skipFields, "access_level") + noEmptyScopes = true + case TokenTypeGroupDeploy: + validAccessLevels = ValidGroupDeployAccessLevels + validScopes = ValidGroupDeployTokenScopes + skipFields = append(skipFields, "access_level") + noEmptyScopes = true } // check if all required fields are set @@ -273,46 +287,41 @@ func (b *Backend) pathRolesWrite(ctx context.Context, req *logical.Request, data if slices.Contains(skipFields, name) { continue } + val, ok, _ := data.GetOkErr(name) if (tokenType == TokenTypePersonal && name == "access_level") || name == "gitlab_revokes_token" { continue } - if field.Required && !ok { + + var required = field.Required + if name == "ttl" && !slices.Contains([]TokenType{TokenTypePipelineProjectTrigger}, tokenType) { + required = true + } + + if required && !ok { err = multierror.Append(err, fmt.Errorf("%s: %w", name, ErrFieldRequired)) - } else if !field.Required && val == nil { + } else if !required && val == nil { warnings = append(warnings, fmt.Sprintf("field '%s' is using expected default value of %v", name, val)) } - } - - if role.TTL > DefaultAccessTokenMaxPossibleTTL { - err = multierror.Append(err, fmt.Errorf("ttl = %s [ttl <= max_ttl = %s]: %w", role.TTL.String(), DefaultAccessTokenMaxPossibleTTL, ErrInvalidValue)) - } - if role.GitlabRevokesTokens && role.TTL < 24*time.Hour { - err = multierror.Append(err, fmt.Errorf("ttl = %s [%s <= ttl <= %s]: %w", role.TTL, DefaultAccessTokenMinTTL, DefaultAccessTokenMaxPossibleTTL, ErrInvalidValue)) - } - - if !role.GitlabRevokesTokens && role.TTL < time.Hour { - err = multierror.Append(err, fmt.Errorf("ttl = %s [ttl >= 1h]: %w", role.TTL, ErrInvalidValue)) + if required && name == "ttl" { + if role.TTL > DefaultAccessTokenMaxPossibleTTL { + err = multierror.Append(err, fmt.Errorf("ttl = %s [ttl <= max_ttl = %s]: %w", role.TTL.String(), DefaultAccessTokenMaxPossibleTTL, ErrInvalidValue)) + } + if role.GitlabRevokesTokens && role.TTL < 24*time.Hour { + err = multierror.Append(err, fmt.Errorf("ttl = %s [%s <= ttl <= %s]: %w", role.TTL, DefaultAccessTokenMinTTL, DefaultAccessTokenMaxPossibleTTL, ErrInvalidValue)) + } + if !role.GitlabRevokesTokens && role.TTL < time.Hour { + err = multierror.Append(err, fmt.Errorf("ttl = %s [ttl >= 1h]: %w", role.TTL, ErrInvalidValue)) + } + } } if !slices.Contains(validAccessLevels, accessLevel.String()) { err = multierror.Append(err, fmt.Errorf("access_level='%s', should be one of %v: %w", data.Get("access_level").(string), validAccessLevels, ErrFieldInvalidValue)) } - // validate scopes - var invalidScopes []string - var validScopes = validTokenScopes - if tokenType == TokenTypePersonal || tokenType == TokenTypeUserServiceAccount || tokenType == TokenTypeGroupServiceAccount { - validScopes = append(validScopes, ValidPersonalTokenScopes...) - } - if tokenType == TokenTypeUserServiceAccount { - validScopes = append(validScopes, ValidUserServiceAccountTokenScopes...) - } - if tokenType == TokenTypeGroupServiceAccount { - validScopes = append(validScopes, ValidGroupServiceAccountTokenScopes...) - } for _, scope := range role.Scopes { if !slices.Contains(validScopes, scope) { invalidScopes = append(invalidScopes, scope) @@ -323,6 +332,10 @@ func (b *Backend) pathRolesWrite(ctx context.Context, req *logical.Request, data err = multierror.Append(err, fmt.Errorf("scopes='%v', should be one or more of '%v': %w", invalidScopes, validScopes, ErrFieldInvalidValue)) } + if noEmptyScopes && len(role.Scopes) == 0 { + err = multierror.Append(err, fmt.Errorf("should be one or more of '%v': %w", validScopes, ErrFieldInvalidValue)) + } + if tokenType == TokenTypeUserServiceAccount && (config.Type == TypeSaaS || config.Type == TypeDedicated) { err = multierror.Append(err, fmt.Errorf("cannot create %s with %s: %w", tokenType, config.Type, ErrInvalidValue)) } @@ -345,8 +358,9 @@ func (b *Backend) pathRolesWrite(ctx context.Context, req *logical.Request, data } event(ctx, b.Backend, "role-write", map[string]string{ - "path": "roles", - "role_name": roleName, + "path": "roles", + "role_name": roleName, + "config_name": role.ConfigName, }) b.Logger().Debug("Role written", "role", roleName) @@ -359,7 +373,6 @@ func (b *Backend) pathRolesWrite(ctx context.Context, req *logical.Request, data func (b *Backend) pathRoleExistenceCheck(ctx context.Context, req *logical.Request, data *framework.FieldData) (bool, error) { name := data.Get("role_name").(string) - role, err := getRole(ctx, name, req.Storage) if err != nil { if strings.Contains(err.Error(), logical.ErrReadOnly.Error()) { diff --git a/path_role_deploy_tokens_test.go b/path_role_deploy_tokens_test.go new file mode 100644 index 0000000..ec20424 --- /dev/null +++ b/path_role_deploy_tokens_test.go @@ -0,0 +1,92 @@ +//go:build unit + +package gitlab_test + +import ( + "cmp" + "fmt" + "os" + "testing" + "time" + + "github.com/hashicorp/go-multierror" + "github.com/hashicorp/vault/sdk/logical" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + gitlab "github.com/ilijamt/vault-plugin-secrets-gitlab" +) + +func TestPathRolesDeployTokens(t *testing.T) { + var defaultConfig = map[string]any{ + "token": "glpat-secret-random-token", + "base_url": cmp.Or(os.Getenv("GITLAB_URL"), "http://localhost:8080/"), + "type": gitlab.TypeSelfManaged.String(), + } + + var tests = []struct { + tokenType gitlab.TokenType + accessLevel gitlab.AccessLevel + scopes []string + ttl string + path string + name string + }{ + { + tokenType: gitlab.TokenTypeProjectDeploy, + path: "example/example", + scopes: []string{gitlab.TokenScopeReadRepository.String()}, + }, + { + tokenType: gitlab.TokenTypeGroupDeploy, + path: "test/test1", + scopes: []string{gitlab.TokenScopeReadRepository.String()}, + }, + } + + for _, tt := range tests { + t.Run(tt.tokenType.String(), func(t *testing.T) { + t.Run("should create role successfully", func(t *testing.T) { + ctx := getCtxGitlabClient(t, "unit") + var b, l, err = getBackendWithConfig(ctx, defaultConfig) + require.NoError(t, err) + resp, err := b.HandleRequest(ctx, &logical.Request{ + Operation: logical.CreateOperation, + Path: fmt.Sprintf("%s/%d", gitlab.PathRoleStorage, time.Now().UnixNano()), Storage: l, + Data: map[string]any{ + "path": tt.path, + "name": tt.name, + "access_level": cmp.Or(tt.accessLevel, gitlab.AccessLevelUnknown).String(), + "token_type": tt.tokenType.String(), + "scopes": tt.scopes, + "ttl": cmp.Or(tt.ttl, "1h"), + }, + }) + require.NoError(t, err) + require.NotNil(t, resp) + }) + + t.Run("fail to create role due to missing scopes and wrong access level", func(t *testing.T) { + ctx := getCtxGitlabClient(t, "unit") + var b, l, err = getBackendWithConfig(ctx, defaultConfig) + require.NoError(t, err) + resp, err := b.HandleRequest(ctx, &logical.Request{ + Operation: logical.CreateOperation, + Path: fmt.Sprintf("%s/%d", gitlab.PathRoleStorage, time.Now().UnixNano()), Storage: l, + Data: map[string]any{ + "path": tt.path, + "name": tt.name, + "access_level": gitlab.AccessLevelNoPermissions.String(), + "token_type": tt.tokenType.String(), + "ttl": cmp.Or(tt.ttl, "1h"), + "scopes": []string{}, + }, + }) + require.Error(t, err) + require.NotNil(t, resp) + var errorMap = countErrByName(err.(*multierror.Error)) + assert.EqualValues(t, 2, errorMap[gitlab.ErrFieldInvalidValue.Error()]) + }) + }) + } +} diff --git a/path_role_pipeline_project_trigger_token_test.go b/path_role_pipeline_project_trigger_token_test.go new file mode 100644 index 0000000..6eab270 --- /dev/null +++ b/path_role_pipeline_project_trigger_token_test.go @@ -0,0 +1,89 @@ +//go:build unit + +package gitlab_test + +import ( + "cmp" + "fmt" + "os" + "testing" + "time" + + "github.com/hashicorp/go-multierror" + "github.com/hashicorp/vault/sdk/logical" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + gitlab "github.com/ilijamt/vault-plugin-secrets-gitlab" +) + +func TestPathRolesPipelineProjectTrigger(t *testing.T) { + var defaultConfig = map[string]any{ + "token": "glpat-secret-random-token", + "base_url": cmp.Or(os.Getenv("GITLAB_URL"), "http://localhost:8080/"), + "type": gitlab.TypeSelfManaged.String(), + } + + t.Run("should fail if have defined scopes or access level", func(t *testing.T) { + ctx := getCtxGitlabClient(t, "unit") + var b, l, err = getBackendWithConfig(ctx, defaultConfig) + require.NoError(t, err) + resp, err := b.HandleRequest(ctx, &logical.Request{ + Operation: logical.CreateOperation, + Path: fmt.Sprintf("%s/%d", gitlab.PathRoleStorage, time.Now().UnixNano()), Storage: l, + Data: map[string]any{ + "path": "user", + "name": "Example user personal token", + "access_level": gitlab.AccessLevelNoPermissions.String(), + "token_type": gitlab.TokenTypePipelineProjectTrigger.String(), + "scopes": []string{gitlab.TokenScopeApi.String()}, + "ttl": "1h", + }, + }) + require.Error(t, err) + require.NotNil(t, resp) + var errorMap = countErrByName(err.(*multierror.Error)) + assert.EqualValues(t, 2, errorMap[gitlab.ErrFieldInvalidValue.Error()]) + }) + + t.Run("ttl is set", func(t *testing.T) { + ctx := getCtxGitlabClient(t, "unit") + var b, l, err = getBackendWithConfig(ctx, defaultConfig) + require.NoError(t, err) + resp, err := b.HandleRequest(ctx, &logical.Request{ + Operation: logical.CreateOperation, + Path: fmt.Sprintf("%s/%d", gitlab.PathRoleStorage, time.Now().UnixNano()), Storage: l, + Data: map[string]any{ + "path": "user", + "name": "Example user personal token", + "access_level": gitlab.AccessLevelUnknown.String(), + "token_type": gitlab.TokenTypePipelineProjectTrigger.String(), + "scopes": []string{}, + "ttl": "1h", + }, + }) + require.NoError(t, err) + require.NotNil(t, resp) + require.EqualValues(t, 3600, resp.Data["ttl"]) + }) + + t.Run("ttl is optional", func(t *testing.T) { + ctx := getCtxGitlabClient(t, "unit") + var b, l, err = getBackendWithConfig(ctx, defaultConfig) + require.NoError(t, err) + resp, err := b.HandleRequest(ctx, &logical.Request{ + Operation: logical.CreateOperation, + Path: fmt.Sprintf("%s/%d", gitlab.PathRoleStorage, time.Now().UnixNano()), Storage: l, + Data: map[string]any{ + "path": "user", + "name": "Example user personal token", + "access_level": gitlab.AccessLevelUnknown.String(), + "token_type": gitlab.TokenTypePipelineProjectTrigger.String(), + "scopes": []string{}, + }, + }) + require.NoError(t, err) + require.NotNil(t, resp) + require.EqualValues(t, 0, resp.Data["ttl"]) + }) +} diff --git a/path_role_test.go b/path_role_test.go index 22744e7..a957bb7 100644 --- a/path_role_test.go +++ b/path_role_test.go @@ -1,3 +1,5 @@ +//go:build unit + package gitlab_test import ( @@ -17,7 +19,7 @@ import ( func TestPathRolesList(t *testing.T) { t.Run("empty list", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackend(ctx) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -39,7 +41,7 @@ func TestPathRoles(t *testing.T) { } t.Run("delete non existing role", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackend(ctx) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -51,7 +53,7 @@ func TestPathRoles(t *testing.T) { }) t.Run("we get error if backend is not set up during role write", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackend(ctx) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -67,7 +69,7 @@ func TestPathRoles(t *testing.T) { t.Run("access level", func(t *testing.T) { t.Run(gitlab.TokenTypePersonal.String(), func(t *testing.T) { t.Run("no access level defined", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackendWithConfig(ctx, defaultConfig) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -88,7 +90,7 @@ func TestPathRoles(t *testing.T) { require.Empty(t, resp.Warnings) }) t.Run("with access level defined", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackendWithConfig(ctx, defaultConfig) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -112,7 +114,7 @@ func TestPathRoles(t *testing.T) { t.Run(gitlab.TokenTypeProject.String(), func(t *testing.T) { t.Run("no access level defined", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackendWithConfig(ctx, defaultConfig) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -132,7 +134,7 @@ func TestPathRoles(t *testing.T) { require.Error(t, resp.Error()) }) t.Run("with access level defined", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackendWithConfig(ctx, defaultConfig) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -157,7 +159,7 @@ func TestPathRoles(t *testing.T) { t.Run(gitlab.TokenTypeGroup.String(), func(t *testing.T) { t.Run("no access level defined", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackendWithConfig(ctx, defaultConfig) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -177,7 +179,7 @@ func TestPathRoles(t *testing.T) { require.Error(t, resp.Error()) }) t.Run("with access level defined", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackendWithConfig(ctx, defaultConfig) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -204,7 +206,7 @@ func TestPathRoles(t *testing.T) { }) t.Run("create with missing parameters", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackendWithConfig(ctx, defaultConfig) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -221,7 +223,7 @@ func TestPathRoles(t *testing.T) { }) t.Run("invalid name template", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackendWithConfig(ctx, defaultConfig) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -244,7 +246,7 @@ func TestPathRoles(t *testing.T) { t.Run("Project token scopes", func(t *testing.T) { t.Run("valid scopes", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackendWithConfig(ctx, defaultConfig) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -265,7 +267,7 @@ func TestPathRoles(t *testing.T) { }) t.Run("invalid scopes", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackendWithConfig(ctx, defaultConfig) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -290,7 +292,7 @@ func TestPathRoles(t *testing.T) { t.Run("Personal token scopes", func(t *testing.T) { t.Run("valid scopes", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackendWithConfig(ctx, defaultConfig) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -310,7 +312,7 @@ func TestPathRoles(t *testing.T) { }) t.Run("invalid scopes", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackendWithConfig(ctx, defaultConfig) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -334,7 +336,7 @@ func TestPathRoles(t *testing.T) { t.Run("Group token scopes", func(t *testing.T) { t.Run("valid scopes", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackendWithConfig(ctx, defaultConfig) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -355,7 +357,7 @@ func TestPathRoles(t *testing.T) { }) t.Run("invalid scopes", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackendWithConfig(ctx, defaultConfig) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -377,7 +379,7 @@ func TestPathRoles(t *testing.T) { }) t.Run("update handler existence check", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackend(ctx) require.NoError(t, err) hasExistenceCheck, exists, err := b.HandleExistenceCheck(ctx, &logical.Request{ @@ -391,7 +393,7 @@ func TestPathRoles(t *testing.T) { }) t.Run("full flow check roles", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, events, err = getBackendWithEvents(ctx) require.NoError(t, err) diff --git a/path_role_ttl_test.go b/path_role_ttl_test.go index 530febe..e3b7b07 100644 --- a/path_role_ttl_test.go +++ b/path_role_ttl_test.go @@ -1,3 +1,5 @@ +//go:build unit + package gitlab_test import ( @@ -34,7 +36,7 @@ func TestPathRolesTTL(t *testing.T) { } t.Run("role.TTL > DefaultAccessTokenMaxPossibleTTL", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackendWithConfig(ctx, defaultConfig) require.NoError(t, err) var role = maps.Clone(generalRole) @@ -54,7 +56,7 @@ func TestPathRolesTTL(t *testing.T) { }) t.Run("ttl = maxTTL", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackendWithConfig(ctx, defaultConfig) require.NoError(t, err) var role = maps.Clone(generalRole) @@ -95,7 +97,7 @@ func TestPathRolesTTL(t *testing.T) { } t.Run("ttl >= 1h && ttl <= DefaultAccessTokenMaxPossibleTTL", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackendWithConfig(ctx, defaultConfig) require.NoError(t, err) var role = maps.Clone(generalRole) @@ -124,7 +126,7 @@ func TestPathRolesTTL(t *testing.T) { }) t.Run("ttl < 1h", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackendWithConfig(ctx, defaultConfig) require.NoError(t, err) var role = maps.Clone(generalRole) @@ -157,7 +159,7 @@ func TestPathRolesTTL(t *testing.T) { } t.Run("ttl < 24h", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackendWithConfig(ctx, defaultConfig) require.NoError(t, err) var role = maps.Clone(generalRole) @@ -177,7 +179,7 @@ func TestPathRolesTTL(t *testing.T) { }) t.Run("ttl >= 24h && ttl <= DefaultAccessTokenMaxPossibleTTL", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackendWithConfig(ctx, defaultConfig) require.NoError(t, err) var role = maps.Clone(generalRole) diff --git a/path_token_role.go b/path_token_role.go index 835b59a..60560ca 100644 --- a/path_token_role.go +++ b/path_token_role.go @@ -109,6 +109,21 @@ func (b *Backend) pathTokenRoleCreate(ctx context.Context, req *logical.Request, b.Logger().Debug("Creating group service account access token for role", "path", role.Path, "groupId", groupId, "userId", userId, "name", name, "expiresAt", expiresAt, "scopes", role.Scopes) token, err = client.CreateGroupServiceAccountAccessToken(ctx, role.Path, groupId, userId, name, expiresAt, role.Scopes) } + case TokenTypeProjectDeploy: + var projectId int + if projectId, err = client.GetProjectIdByPath(ctx, role.Path); err == nil { + token, err = client.CreateProjectDeployToken(ctx, role.Path, projectId, name, &expiresAt, role.Scopes) + } + case TokenTypeGroupDeploy: + var groupId int + if groupId, err = client.GetGroupIdByPath(ctx, role.Path); err == nil { + token, err = client.CreateGroupDeployToken(ctx, role.Path, groupId, name, &expiresAt, role.Scopes) + } + case TokenTypePipelineProjectTrigger: + var projectId int + if projectId, err = client.GetProjectIdByPath(ctx, role.Path); err == nil { + token, err = client.CreatePipelineProjectTriggerAccessToken(ctx, role.Path, name, projectId, name, &expiresAt) + } default: return logical.ErrorResponse("invalid token type"), fmt.Errorf("%s: %w", role.TokenType.String(), ErrUnknownTokenType) } @@ -148,6 +163,7 @@ func (b *Backend) pathTokenRoleCreate(ctx context.Context, req *logical.Request, "token_type": role.TokenType.String(), "scopes": strings.Join(role.Scopes, ","), "access_level": role.AccessLevel.String(), + "config_name": token.ConfigName, }) return resp, nil } diff --git a/path_token_role_multiple_config_test.go b/path_token_role_multiple_config_test.go index 9551be8..d1f43f5 100644 --- a/path_token_role_multiple_config_test.go +++ b/path_token_role_multiple_config_test.go @@ -1,3 +1,5 @@ +//go:build unit + package gitlab_test import ( @@ -7,13 +9,13 @@ import ( "github.com/hashicorp/vault/sdk/logical" "github.com/stretchr/testify/require" - g "github.com/xanzy/go-gitlab" + g "gitlab.com/gitlab-org/api/client-go" gitlab "github.com/ilijamt/vault-plugin-secrets-gitlab" ) func TestPathTokenRolesMultipleConfigs(t *testing.T) { - httpClient, gitlabUrl := getClient(t) + httpClient, gitlabUrl := getClient(t, "unit") ctx := gitlab.HttpClientNewContext(context.Background(), httpClient) b, l, events, err := getBackendWithEvents(ctx) diff --git a/path_token_role_test.go b/path_token_role_test.go index d92dc13..3b11bf2 100644 --- a/path_token_role_test.go +++ b/path_token_role_test.go @@ -1,3 +1,5 @@ +//go:build unit + package gitlab_test import ( @@ -21,7 +23,7 @@ func TestPathTokenRoles(t *testing.T) { } t.Run("role not found", func(t *testing.T) { - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") var b, l, err = getBackend(ctx) require.NoError(t, err) resp, err := b.HandleRequest(ctx, &logical.Request{ @@ -35,7 +37,7 @@ func TestPathTokenRoles(t *testing.T) { var generalTokenCreation = func(t *testing.T, tokenType gitlab.TokenType, level gitlab.AccessLevel, gitlabRevokesToken bool) { t.Logf("token creation, token type: %s, level: %s, gitlab revokes token: %t", tokenType, level, gitlabRevokesToken) - ctx := getCtxGitlabClient(t) + ctx := getCtxGitlabClient(t, "unit") client := newInMemoryClient(true) ctx = gitlab.GitlabClientNewContext(ctx, client) var b, l, events, err = getBackendWithEvents(ctx) diff --git a/secret_access_tokens.go b/secret_access_tokens.go index d156c61..0824493 100644 --- a/secret_access_tokens.go +++ b/secret_access_tokens.go @@ -68,12 +68,6 @@ func (b *Backend) secretAccessTokenRevoke(ctx context.Context, req *logical.Requ configName = val.(string) } - // var config *EntryConfig - // config, err = getConfig(ctx, req.Storage, configName) - // if err != nil { - // return nil, err - // } - var tokenId int tokenId, err = convertToInt(req.Secret.InternalData["token_id"]) if err != nil { @@ -91,7 +85,7 @@ func (b *Backend) secretAccessTokenRevoke(ctx context.Context, req *logical.Requ var client Client client, err = b.getClient(ctx, req.Storage, configName) if err != nil { - return nil, fmt.Errorf("revoke token cannot get client: %w", err) + return nil, fmt.Errorf("revoke token cannot get client got %s config: %w", configName, err) } switch tokenType { @@ -107,6 +101,21 @@ func (b *Backend) secretAccessTokenRevoke(ctx context.Context, req *logical.Requ case TokenTypeGroupServiceAccount: var token = req.Secret.InternalData["token"].(string) err = client.RevokeGroupServiceAccountAccessToken(ctx, token) + case TokenTypePipelineProjectTrigger: + var projectId int + if projectId, err = strconv.Atoi(parentId); err == nil { + err = client.RevokePipelineProjectTriggerAccessToken(ctx, projectId, tokenId) + } + case TokenTypeGroupDeploy: + var groupId int + if groupId, err = strconv.Atoi(parentId); err == nil { + err = client.RevokeGroupDeployToken(ctx, groupId, tokenId) + } + case TokenTypeProjectDeploy: + var projectId int + if projectId, err = strconv.Atoi(parentId); err == nil { + err = client.RevokeProjectDeployToken(ctx, projectId, tokenId) + } } if err != nil && !errors.Is(err, ErrAccessTokenNotFound) { @@ -120,6 +129,7 @@ func (b *Backend) secretAccessTokenRevoke(ctx context.Context, req *logical.Requ "name": req.Secret.InternalData["name"].(string), "token_id": strconv.Itoa(tokenId), "token_type": tokenTypeValue, + "config_name": configName, "gitlab_revokes_token": strconv.FormatBool(gitlabRevokesToken), }) diff --git a/secret_access_tokens_test.go b/secret_access_tokens_test.go index 320641a..e6acbb7 100644 --- a/secret_access_tokens_test.go +++ b/secret_access_tokens_test.go @@ -1,3 +1,5 @@ +//go:build unit + package gitlab_test import ( @@ -12,7 +14,7 @@ import ( ) func TestSecretAccessTokenRevokeToken(t *testing.T) { - httpClient, url := getClient(t) + httpClient, url := getClient(t, "unit") ctx := gitlab.HttpClientNewContext(context.Background(), httpClient) b, l, events, err := getBackendWithEvents(ctx) diff --git a/testdata/fixtures/16.11.6/TestPathConfig_AutoRotate_auto_rotate_before_should_be_set_to_correct_value.yaml b/testdata/fixtures/16.11.6/TestPathConfig_AutoRotate_auto_rotate_before_should_be_set_to_correct_value.yaml deleted file mode 100644 index 30b0f6d..0000000 --- a/testdata/fixtures/16.11.6/TestPathConfig_AutoRotate_auto_rotate_before_should_be_set_to_correct_value.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Fri, 11 Oct 2024 09:11:10 GMT - Etag: - - W/"86a012f2542444285d00a390ed234220" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH8DZHBKRH9PR08GYRXZ8","version":"1"}' - X-Request-Id: - - 01J9XDH8DZHBKRH9PR08GYRXZ8 - X-Runtime: - - "0.015327" - status: 200 OK - code: 200 - duration: 18.970959ms diff --git a/testdata/fixtures/16.11.6/TestPathConfig_AutoRotate_auto_rotate_before_should_be_set_to_min_if_not_specified.yaml b/testdata/fixtures/16.11.6/TestPathConfig_AutoRotate_auto_rotate_before_should_be_set_to_min_if_not_specified.yaml deleted file mode 100644 index 55e0e79..0000000 --- a/testdata/fixtures/16.11.6/TestPathConfig_AutoRotate_auto_rotate_before_should_be_set_to_min_if_not_specified.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Fri, 11 Oct 2024 09:11:10 GMT - Etag: - - W/"86a012f2542444285d00a390ed234220" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH8FACK5A534NH69R0202","version":"1"}' - X-Request-Id: - - 01J9XDH8FACK5A534NH69R0202 - X-Runtime: - - "0.013821" - status: 200 OK - code: 200 - duration: 17.002042ms diff --git a/testdata/fixtures/16.11.6/TestPathConfig_write_read_delete_and_read_config.yaml b/testdata/fixtures/16.11.6/TestPathConfig_write_read_delete_and_read_config.yaml deleted file mode 100644 index 65731dd..0000000 --- a/testdata/fixtures/16.11.6/TestPathConfig_write_read_delete_and_read_config.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Fri, 11 Oct 2024 09:11:10 GMT - Etag: - - W/"86a012f2542444285d00a390ed234220" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH8ANHVDFW7SA5K20EH5W","version":"1"}' - X-Request-Id: - - 01J9XDH8ANHVDFW7SA5K20EH5W - X-Runtime: - - "0.015270" - status: 200 OK - code: 200 - duration: 18.064125ms diff --git a/testdata/fixtures/16.11.6/TestPathRolesTTL_general_ttl_limits_role_TTL__DefaultAccessTokenMaxPossibleTTL.yaml b/testdata/fixtures/16.11.6/TestPathRolesTTL_general_ttl_limits_role_TTL__DefaultAccessTokenMaxPossibleTTL.yaml deleted file mode 100644 index 0ad8a57..0000000 --- a/testdata/fixtures/16.11.6/TestPathRolesTTL_general_ttl_limits_role_TTL__DefaultAccessTokenMaxPossibleTTL.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Fri, 11 Oct 2024 09:11:11 GMT - Etag: - - W/"86a012f2542444285d00a390ed234220" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH90XY33EXSEACZB1RYGB","version":"1"}' - X-Request-Id: - - 01J9XDH90XY33EXSEACZB1RYGB - X-Runtime: - - "0.010765" - status: 200 OK - code: 200 - duration: 13.049209ms diff --git a/testdata/fixtures/16.11.6/TestPathRolesTTL_general_ttl_limits_ttl__maxTTL.yaml b/testdata/fixtures/16.11.6/TestPathRolesTTL_general_ttl_limits_ttl__maxTTL.yaml deleted file mode 100644 index e0f1c6a..0000000 --- a/testdata/fixtures/16.11.6/TestPathRolesTTL_general_ttl_limits_ttl__maxTTL.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Fri, 11 Oct 2024 09:11:11 GMT - Etag: - - W/"86a012f2542444285d00a390ed234220" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH91XVRM9H5T9MD4SJX4A","version":"1"}' - X-Request-Id: - - 01J9XDH91XVRM9H5T9MD4SJX4A - X-Runtime: - - "0.011083" - status: 200 OK - code: 200 - duration: 13.319375ms diff --git a/testdata/fixtures/16.11.6/TestPathRolesTTL_gitlab_revokes_the_tokens_ttl__24h.yaml b/testdata/fixtures/16.11.6/TestPathRolesTTL_gitlab_revokes_the_tokens_ttl__24h.yaml deleted file mode 100644 index c4ea077..0000000 --- a/testdata/fixtures/16.11.6/TestPathRolesTTL_gitlab_revokes_the_tokens_ttl__24h.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Fri, 11 Oct 2024 09:11:11 GMT - Etag: - - W/"86a012f2542444285d00a390ed234220" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH94P99TJGT60SD7KKN1M","version":"1"}' - X-Request-Id: - - 01J9XDH94P99TJGT60SD7KKN1M - X-Runtime: - - "0.010907" - status: 200 OK - code: 200 - duration: 13.253875ms diff --git a/testdata/fixtures/16.11.6/TestPathRolesTTL_gitlab_revokes_the_tokens_ttl__24h__ttl__DefaultAccessTokenMaxPossibleTTL.yaml b/testdata/fixtures/16.11.6/TestPathRolesTTL_gitlab_revokes_the_tokens_ttl__24h__ttl__DefaultAccessTokenMaxPossibleTTL.yaml deleted file mode 100644 index ab2f4e0..0000000 --- a/testdata/fixtures/16.11.6/TestPathRolesTTL_gitlab_revokes_the_tokens_ttl__24h__ttl__DefaultAccessTokenMaxPossibleTTL.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Fri, 11 Oct 2024 09:11:11 GMT - Etag: - - W/"86a012f2542444285d00a390ed234220" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH95NVQJ09Y06MGFJ55SY","version":"1"}' - X-Request-Id: - - 01J9XDH95NVQJ09Y06MGFJ55SY - X-Runtime: - - "0.009961" - status: 200 OK - code: 200 - duration: 11.944958ms diff --git a/testdata/fixtures/16.11.6/TestPathRolesTTL_vault_revokes_the_token_ttl__1h.yaml b/testdata/fixtures/16.11.6/TestPathRolesTTL_vault_revokes_the_token_ttl__1h.yaml deleted file mode 100644 index f318e8b..0000000 --- a/testdata/fixtures/16.11.6/TestPathRolesTTL_vault_revokes_the_token_ttl__1h.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Fri, 11 Oct 2024 09:11:11 GMT - Etag: - - W/"86a012f2542444285d00a390ed234220" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH93VEPP8JTQBA023R5HC","version":"1"}' - X-Request-Id: - - 01J9XDH93VEPP8JTQBA023R5HC - X-Runtime: - - "0.009332" - status: 200 OK - code: 200 - duration: 11.089084ms diff --git a/testdata/fixtures/16.11.6/TestPathRolesTTL_vault_revokes_the_token_ttl__1h__ttl__DefaultAccessTokenMaxPossibleTTL.yaml b/testdata/fixtures/16.11.6/TestPathRolesTTL_vault_revokes_the_token_ttl__1h__ttl__DefaultAccessTokenMaxPossibleTTL.yaml deleted file mode 100644 index 9f3be9b..0000000 --- a/testdata/fixtures/16.11.6/TestPathRolesTTL_vault_revokes_the_token_ttl__1h__ttl__DefaultAccessTokenMaxPossibleTTL.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Fri, 11 Oct 2024 09:11:11 GMT - Etag: - - W/"86a012f2542444285d00a390ed234220" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH92YMCRH6V1QQH9MQ4N5","version":"1"}' - X-Request-Id: - - 01J9XDH92YMCRH6V1QQH9MQ4N5 - X-Runtime: - - "0.009892" - status: 200 OK - code: 200 - duration: 12.025166ms diff --git a/testdata/fixtures/16.11.6/TestPathRoles_Group_token_scopes_invalid_scopes.yaml b/testdata/fixtures/16.11.6/TestPathRoles_Group_token_scopes_invalid_scopes.yaml deleted file mode 100644 index c3568c4..0000000 --- a/testdata/fixtures/16.11.6/TestPathRoles_Group_token_scopes_invalid_scopes.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Fri, 11 Oct 2024 09:11:11 GMT - Etag: - - W/"86a012f2542444285d00a390ed234220" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH8YTSTG508QDXFVB29QW","version":"1"}' - X-Request-Id: - - 01J9XDH8YTSTG508QDXFVB29QW - X-Runtime: - - "0.010698" - status: 200 OK - code: 200 - duration: 13.098041ms diff --git a/testdata/fixtures/16.11.6/TestPathRoles_Group_token_scopes_valid_scopes.yaml b/testdata/fixtures/16.11.6/TestPathRoles_Group_token_scopes_valid_scopes.yaml deleted file mode 100644 index 11bfe0f..0000000 --- a/testdata/fixtures/16.11.6/TestPathRoles_Group_token_scopes_valid_scopes.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Fri, 11 Oct 2024 09:11:11 GMT - Etag: - - W/"86a012f2542444285d00a390ed234220" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH8XTAJ7A4NT36RCWGCME","version":"1"}' - X-Request-Id: - - 01J9XDH8XTAJ7A4NT36RCWGCME - X-Runtime: - - "0.010774" - status: 200 OK - code: 200 - duration: 13.166458ms diff --git a/testdata/fixtures/16.11.6/TestPathRoles_Personal_token_scopes_invalid_scopes.yaml b/testdata/fixtures/16.11.6/TestPathRoles_Personal_token_scopes_invalid_scopes.yaml deleted file mode 100644 index dc6cf9d..0000000 --- a/testdata/fixtures/16.11.6/TestPathRoles_Personal_token_scopes_invalid_scopes.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Fri, 11 Oct 2024 09:11:11 GMT - Etag: - - W/"86a012f2542444285d00a390ed234220" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH8WSE4CJABE4MDP7TX9X","version":"1"}' - X-Request-Id: - - 01J9XDH8WSE4CJABE4MDP7TX9X - X-Runtime: - - "0.011028" - status: 200 OK - code: 200 - duration: 13.043625ms diff --git a/testdata/fixtures/16.11.6/TestPathRoles_Personal_token_scopes_valid_scopes.yaml b/testdata/fixtures/16.11.6/TestPathRoles_Personal_token_scopes_valid_scopes.yaml deleted file mode 100644 index 4e59e16..0000000 --- a/testdata/fixtures/16.11.6/TestPathRoles_Personal_token_scopes_valid_scopes.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Fri, 11 Oct 2024 09:11:10 GMT - Etag: - - W/"86a012f2542444285d00a390ed234220" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH8VW6TBTX4MASRJRYVX9","version":"1"}' - X-Request-Id: - - 01J9XDH8VW6TBTX4MASRJRYVX9 - X-Runtime: - - "0.010008" - status: 200 OK - code: 200 - duration: 12.248791ms diff --git a/testdata/fixtures/16.11.6/TestPathRoles_Project_token_scopes_invalid_scopes.yaml b/testdata/fixtures/16.11.6/TestPathRoles_Project_token_scopes_invalid_scopes.yaml deleted file mode 100644 index 6558413..0000000 --- a/testdata/fixtures/16.11.6/TestPathRoles_Project_token_scopes_invalid_scopes.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Fri, 11 Oct 2024 09:11:10 GMT - Etag: - - W/"86a012f2542444285d00a390ed234220" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH8TXFN2DG0R0KWZ0FS3T","version":"1"}' - X-Request-Id: - - 01J9XDH8TXFN2DG0R0KWZ0FS3T - X-Runtime: - - "0.009859" - status: 200 OK - code: 200 - duration: 12.447958ms diff --git a/testdata/fixtures/16.11.6/TestPathRoles_Project_token_scopes_valid_scopes.yaml b/testdata/fixtures/16.11.6/TestPathRoles_Project_token_scopes_valid_scopes.yaml deleted file mode 100644 index ec433f6..0000000 --- a/testdata/fixtures/16.11.6/TestPathRoles_Project_token_scopes_valid_scopes.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Fri, 11 Oct 2024 09:11:10 GMT - Etag: - - W/"86a012f2542444285d00a390ed234220" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH8SRQYDPQC73NB1N43H1","version":"1"}' - X-Request-Id: - - 01J9XDH8SRQYDPQC73NB1N43H1 - X-Runtime: - - "0.013668" - status: 200 OK - code: 200 - duration: 16.766458ms diff --git a/testdata/fixtures/16.11.6/TestPathRoles_access_level_group_no_access_level_defined.yaml b/testdata/fixtures/16.11.6/TestPathRoles_access_level_group_no_access_level_defined.yaml deleted file mode 100644 index 7bcfd30..0000000 --- a/testdata/fixtures/16.11.6/TestPathRoles_access_level_group_no_access_level_defined.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Fri, 11 Oct 2024 09:11:10 GMT - Etag: - - W/"86a012f2542444285d00a390ed234220" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH8NE1TSD2Q9VDXRPFQTX","version":"1"}' - X-Request-Id: - - 01J9XDH8NE1TSD2Q9VDXRPFQTX - X-Runtime: - - "0.012909" - status: 200 OK - code: 200 - duration: 15.626875ms diff --git a/testdata/fixtures/16.11.6/TestPathRoles_access_level_group_with_access_level_defined.yaml b/testdata/fixtures/16.11.6/TestPathRoles_access_level_group_with_access_level_defined.yaml deleted file mode 100644 index d8616a3..0000000 --- a/testdata/fixtures/16.11.6/TestPathRoles_access_level_group_with_access_level_defined.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Fri, 11 Oct 2024 09:11:10 GMT - Etag: - - W/"86a012f2542444285d00a390ed234220" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH8PJ2KTM9M5XPXPHGC1Q","version":"1"}' - X-Request-Id: - - 01J9XDH8PJ2KTM9M5XPXPHGC1Q - X-Runtime: - - "0.024885" - status: 200 OK - code: 200 - duration: 28.334083ms diff --git a/testdata/fixtures/16.11.6/TestPathRoles_access_level_personal_no_access_level_defined.yaml b/testdata/fixtures/16.11.6/TestPathRoles_access_level_personal_no_access_level_defined.yaml deleted file mode 100644 index 317b73c..0000000 --- a/testdata/fixtures/16.11.6/TestPathRoles_access_level_personal_no_access_level_defined.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Fri, 11 Oct 2024 09:11:10 GMT - Etag: - - W/"86a012f2542444285d00a390ed234220" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH8GS92AYSYSXWSK99EKP","version":"1"}' - X-Request-Id: - - 01J9XDH8GS92AYSYSXWSK99EKP - X-Runtime: - - "0.012622" - status: 200 OK - code: 200 - duration: 15.563958ms diff --git a/testdata/fixtures/16.11.6/TestPathRoles_access_level_personal_with_access_level_defined.yaml b/testdata/fixtures/16.11.6/TestPathRoles_access_level_personal_with_access_level_defined.yaml deleted file mode 100644 index 099a408..0000000 --- a/testdata/fixtures/16.11.6/TestPathRoles_access_level_personal_with_access_level_defined.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Fri, 11 Oct 2024 09:11:10 GMT - Etag: - - W/"86a012f2542444285d00a390ed234220" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH8HYP20BZCWGE4BMVJWA","version":"1"}' - X-Request-Id: - - 01J9XDH8HYP20BZCWGE4BMVJWA - X-Runtime: - - "0.013288" - status: 200 OK - code: 200 - duration: 16.857792ms diff --git a/testdata/fixtures/16.11.6/TestPathRoles_access_level_project_no_access_level_defined.yaml b/testdata/fixtures/16.11.6/TestPathRoles_access_level_project_no_access_level_defined.yaml deleted file mode 100644 index 05103a6..0000000 --- a/testdata/fixtures/16.11.6/TestPathRoles_access_level_project_no_access_level_defined.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Fri, 11 Oct 2024 09:11:10 GMT - Etag: - - W/"86a012f2542444285d00a390ed234220" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH8K4AX6T79XW7XHCQ7MH","version":"1"}' - X-Request-Id: - - 01J9XDH8K4AX6T79XW7XHCQ7MH - X-Runtime: - - "0.012000" - status: 200 OK - code: 200 - duration: 14.973666ms diff --git a/testdata/fixtures/16.11.6/TestPathRoles_access_level_project_with_access_level_defined.yaml b/testdata/fixtures/16.11.6/TestPathRoles_access_level_project_with_access_level_defined.yaml deleted file mode 100644 index 226ed94..0000000 --- a/testdata/fixtures/16.11.6/TestPathRoles_access_level_project_with_access_level_defined.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Fri, 11 Oct 2024 09:11:10 GMT - Etag: - - W/"86a012f2542444285d00a390ed234220" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH8M6N4MFVN3DVXTA40SA","version":"1"}' - X-Request-Id: - - 01J9XDH8M6N4MFVN3DVXTA40SA - X-Runtime: - - "0.014400" - status: 200 OK - code: 200 - duration: 17.687667ms diff --git a/testdata/fixtures/16.11.6/TestPathRoles_create_with_missing_parameters.yaml b/testdata/fixtures/16.11.6/TestPathRoles_create_with_missing_parameters.yaml deleted file mode 100644 index f23e49b..0000000 --- a/testdata/fixtures/16.11.6/TestPathRoles_create_with_missing_parameters.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Fri, 11 Oct 2024 09:11:10 GMT - Etag: - - W/"86a012f2542444285d00a390ed234220" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH8RHTGDC1XY29NWT7BC6","version":"1"}' - X-Request-Id: - - 01J9XDH8RHTGDC1XY29NWT7BC6 - X-Runtime: - - "0.013626" - status: 200 OK - code: 200 - duration: 17.242667ms diff --git a/testdata/fixtures/16.11.6/TestPathRoles_full_flow_check_roles.yaml b/testdata/fixtures/16.11.6/TestPathRoles_full_flow_check_roles.yaml deleted file mode 100644 index cdd32ba..0000000 --- a/testdata/fixtures/16.11.6/TestPathRoles_full_flow_check_roles.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Fri, 11 Oct 2024 09:11:11 GMT - Etag: - - W/"86a012f2542444285d00a390ed234220" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH8ZV9WM3RWW64VTPJF01","version":"1"}' - X-Request-Id: - - 01J9XDH8ZV9WM3RWW64VTPJF01 - X-Runtime: - - "0.012263" - status: 200 OK - code: 200 - duration: 14.914041ms diff --git a/testdata/fixtures/16.11.6/TestPathRoles_invalid_name_template.yaml b/testdata/fixtures/16.11.6/TestPathRoles_invalid_name_template.yaml deleted file mode 100644 index 4b3b45e..0000000 --- a/testdata/fixtures/16.11.6/TestPathRoles_invalid_name_template.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 0 - transfer_encoding: [] - trailer: {} - host: localhost:8080 - remote_addr: "" - request_uri: "" - body: "" - form: {} - headers: - Accept: - - application/json - Private-Token: - - REPLACED-TOKEN - User-Agent: - - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self - method: GET - response: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - transfer_encoding: - - chunked - trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-12T19:23:31.602Z","active":true,"expires_at":"2025-07-11"}' - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Connection: - - keep-alive - Content-Type: - - application/json - Date: - - Sat, 12 Oct 2024 19:23:31 GMT - Etag: - - W/"8dcc0f233bd2c0bad3d1d91b4107aaa3" - Referrer-Policy: - - strict-origin-when-cross-origin - Server: - - nginx - Strict-Transport-Security: - - max-age=63072000 - Vary: - - Accept-Encoding - - Origin - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - SAMEORIGIN - X-Gitlab-Meta: - - '{"correlation_id":"01JA12Z7BMDQEFQ6RKX08MRRKR","version":"1"}' - X-Request-Id: - - 01JA12Z7BMDQEFQ6RKX08MRRKR - X-Runtime: - - "0.038380" - status: 200 OK - code: 200 - duration: 54.425791ms diff --git a/testdata/fixtures/16.11.6/TestWithAdminUser_PAT_AdminUser_GitlabRevokesToken.yaml b/testdata/local/TestWithAdminUser_PAT_AdminUser_GitlabRevokesToken.yaml similarity index 68% rename from testdata/fixtures/16.11.6/TestWithAdminUser_PAT_AdminUser_GitlabRevokesToken.yaml rename to testdata/local/TestWithAdminUser_PAT_AdminUser_GitlabRevokesToken.yaml index 1dfb188..20d430a 100644 --- a/testdata/fixtures/16.11.6/TestWithAdminUser_PAT_AdminUser_GitlabRevokesToken.yaml +++ b/testdata/local/TestWithAdminUser_PAT_AdminUser_GitlabRevokesToken.yaml @@ -32,7 +32,7 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":2,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:46.924Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":2,"last_used_at":"2024-10-13T12:38:35.438Z","active":true,"expires_at":"2025-07-11"}' + body: '{"id":2,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:46.924Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":2,"last_used_at":"2024-12-14T22:52:51.011Z","active":true,"expires_at":"2025-07-11"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -41,9 +41,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:38:35 GMT + - Sat, 14 Dec 2024 22:56:07 GMT Etag: - - W/"c622b38f506045ed3c55134cf337e4f5" + - W/"294f5bcfa91aa421ae25d18cbc532b92" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -58,15 +58,80 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6FMT3DA19DP7WD81X12Z","version":"1"}' + - '{"correlation_id":"01JF3P5S8S7ECBD7S2QANKDXY1","version":"1"}' X-Request-Id: - - 01JA2Y6FMT3DA19DP7WD81X12Z + - 01JF3P5S8S7ECBD7S2QANKDXY1 X-Runtime: - - "0.024871" + - "0.019084" status: 200 OK code: 200 - duration: 40.17025ms + duration: 45.092667ms - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:56:07 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3P5SB83M10TKS44BPPT1A6","version":"1"}' + X-Request-Id: + - 01JF3P5SB83M10TKS44BPPT1A6 + X-Runtime: + - "0.016927" + status: 200 OK + code: 200 + duration: 20.23925ms + - id: 2 request: proto: HTTP/1.1 proto_major: 1 @@ -97,7 +162,7 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '[{"id":3,"username":"normal-user","name":"Normal User","state":"active","locked":false,"avatar_url":"https://www.gravatar.com/avatar/30ee3a8ed91c220db688a3bde115c203763b4281374c40835f69168786a590af?s=80\u0026d=identicon","web_url":"http://1b25ef517b98/normal-user","created_at":"2024-07-11T18:53:06.485Z","bio":"","location":"","public_email":null,"skype":"","linkedin":"","twitter":"","discord":"","website_url":"","organization":"","job_title":"","pronouns":null,"bot":false,"work_information":null,"followers":0,"following":0,"is_followed":false,"local_time":null,"last_sign_in_at":null,"confirmed_at":"2024-07-11T18:53:06.412Z","last_activity_on":"2024-10-11","email":"normal@local","theme_id":3,"color_scheme_id":1,"projects_limit":100000,"current_sign_in_at":null,"identities":[],"can_create_group":true,"can_create_project":true,"two_factor_enabled":false,"external":false,"private_profile":false,"commit_email":"normal@local","is_admin":false,"note":null,"namespace_id":3,"created_by":null,"email_reset_offered_at":null}]' + body: '[{"id":3,"username":"normal-user","name":"Normal User","state":"active","locked":false,"avatar_url":"https://www.gravatar.com/avatar/30ee3a8ed91c220db688a3bde115c203763b4281374c40835f69168786a590af?s=80\u0026d=identicon","web_url":"http://7b1d891ab6bb/normal-user","created_at":"2024-07-11T18:53:06.485Z","bio":"","location":"","public_email":null,"skype":"","linkedin":"","twitter":"","discord":"","website_url":"","organization":"","job_title":"","pronouns":null,"bot":false,"work_information":null,"followers":0,"following":0,"is_followed":false,"local_time":null,"last_sign_in_at":null,"confirmed_at":"2024-07-11T18:53:06.412Z","last_activity_on":"2024-12-14","email":"normal@local","theme_id":3,"color_scheme_id":1,"projects_limit":100000,"current_sign_in_at":null,"identities":[],"can_create_group":true,"can_create_project":true,"two_factor_enabled":false,"external":false,"private_profile":false,"commit_email":"normal@local","is_admin":false,"note":null,"namespace_id":3,"created_by":null,"email_reset_offered_at":null}]' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -106,11 +171,11 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:38:35 GMT + - Sat, 14 Dec 2024 22:56:07 GMT Etag: - - W/"25fe2b64ac6604f6b3a8740f4910a720" + - W/"c7beb2de3ce9e367a4275f072f8d6ae0" Link: - - ; rel="first", ; rel="last" + - ; rel="first", ; rel="last" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -125,7 +190,7 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6FQ6BRW7H2AB5S2YFQZY","version":"1"}' + - '{"correlation_id":"01JF3P5SCR45WSFA2TCTXKJTAC","version":"1"}' X-Next-Page: - "" X-Page: @@ -135,17 +200,17 @@ interactions: X-Prev-Page: - "" X-Request-Id: - - 01JA2Y6FQ6BRW7H2AB5S2YFQZY + - 01JF3P5SCR45WSFA2TCTXKJTAC X-Runtime: - - "0.139844" + - "0.047627" X-Total: - "1" X-Total-Pages: - "1" status: 200 OK code: 200 - duration: 143.049958ms - - id: 2 + duration: 51.062708ms + - id: 3 request: proto: HTTP/1.1 proto_major: 1 @@ -156,7 +221,7 @@ interactions: host: localhost:8080 remote_addr: "" request_uri: "" - body: '{"name":"personal","expires_at":"2024-12-18","scopes":["read_api"]}' + body: '{"name":"personal","expires_at":"2025-03-18","scopes":["read_api"]}' form: {} headers: Accept: @@ -177,7 +242,7 @@ interactions: trailer: {} content_length: 214 uncompressed: false - body: '{"id":47,"name":"personal","revoked":false,"created_at":"2024-10-13T12:38:35.818Z","scopes":["read_api"],"user_id":3,"last_used_at":null,"active":true,"expires_at":"2024-12-18","token":"glpat-3VQyeQny-yjY66axCsyk"}' + body: '{"id":51,"name":"personal","revoked":false,"created_at":"2024-12-14T22:56:07.698Z","scopes":["read_api"],"user_id":3,"last_used_at":null,"active":true,"expires_at":"2025-03-18","token":"glpat-xHsjgmFvsGPJTRNTcV4o"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -188,9 +253,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:38:35 GMT + - Sat, 14 Dec 2024 22:56:07 GMT Etag: - - W/"b259fff8a9804777b4d61073ade6e6b7" + - W/"73eb445104edef9897de3de8f3956dba" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -204,15 +269,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6G0764DS3ACJTDGSPBHB","version":"1"}' + - '{"correlation_id":"01JF3P5SG3KX5R53E2S7F4W27D","version":"1"}' X-Request-Id: - - 01JA2Y6G0764DS3ACJTDGSPBHB + - 01JF3P5SG3KX5R53E2S7F4W27D X-Runtime: - - "0.092377" + - "0.023732" status: 201 Created code: 201 - duration: 96.453667ms - - id: 3 + duration: 27.805917ms + - id: 4 request: proto: HTTP/1.1 proto_major: 1 @@ -242,7 +307,7 @@ interactions: trailer: {} content_length: 199 uncompressed: false - body: '{"id":47,"name":"personal","revoked":false,"created_at":"2024-10-13T12:38:35.818Z","scopes":["read_api"],"user_id":3,"last_used_at":"2024-10-13T12:38:36.000Z","active":true,"expires_at":"2024-12-18"}' + body: '{"id":51,"name":"personal","revoked":false,"created_at":"2024-12-14T22:56:07.698Z","scopes":["read_api"],"user_id":3,"last_used_at":"2024-12-14T22:56:07.749Z","active":true,"expires_at":"2025-03-18"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -253,9 +318,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:38:36 GMT + - Sat, 14 Dec 2024 22:56:07 GMT Etag: - - W/"39798d8e52838dc7d10463d90baef51b" + - W/"886dcb2af8e0a2b331dda24549257cc0" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -269,15 +334,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6G69D2Q1469WNAF82178","version":"1"}' + - '{"correlation_id":"01JF3P5SHXB90PM3CM3EVSA7KY","version":"1"}' X-Request-Id: - - 01JA2Y6G69D2Q1469WNAF82178 + - 01JF3P5SHXB90PM3CM3EVSA7KY X-Runtime: - - "0.042050" + - "0.011142" status: 200 OK code: 200 - duration: 45.029125ms - - id: 4 + duration: 13.706625ms + - id: 5 request: proto: HTTP/1.1 proto_major: 1 @@ -307,7 +372,7 @@ interactions: trailer: {} content_length: 199 uncompressed: false - body: '{"id":47,"name":"personal","revoked":false,"created_at":"2024-10-13T12:38:35.818Z","scopes":["read_api"],"user_id":3,"last_used_at":"2024-10-13T12:38:36.000Z","active":true,"expires_at":"2024-12-18"}' + body: '{"id":51,"name":"personal","revoked":false,"created_at":"2024-12-14T22:56:07.698Z","scopes":["read_api"],"user_id":3,"last_used_at":"2024-12-14T22:56:07.749Z","active":true,"expires_at":"2025-03-18"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -318,9 +383,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:38:36 GMT + - Sat, 14 Dec 2024 22:56:07 GMT Etag: - - W/"39798d8e52838dc7d10463d90baef51b" + - W/"886dcb2af8e0a2b331dda24549257cc0" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -334,11 +399,11 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6G944GS8Z0KTD0WS3YF2","version":"1"}' + - '{"correlation_id":"01JF3P5SJWKREGRMHPJS06NSR6","version":"1"}' X-Request-Id: - - 01JA2Y6G944GS8Z0KTD0WS3YF2 + - 01JF3P5SJWKREGRMHPJS06NSR6 X-Runtime: - - "0.009559" + - "0.008176" status: 200 OK code: 200 - duration: 11.812ms + duration: 10.673125ms diff --git a/testdata/fixtures/16.11.6/TestWithAdminUser_PAT_AdminUser_VaultRevokesToken.yaml b/testdata/local/TestWithAdminUser_PAT_AdminUser_VaultRevokesToken.yaml similarity index 71% rename from testdata/fixtures/16.11.6/TestWithAdminUser_PAT_AdminUser_VaultRevokesToken.yaml rename to testdata/local/TestWithAdminUser_PAT_AdminUser_VaultRevokesToken.yaml index 5fd6273..a1d221d 100644 --- a/testdata/fixtures/16.11.6/TestWithAdminUser_PAT_AdminUser_VaultRevokesToken.yaml +++ b/testdata/local/TestWithAdminUser_PAT_AdminUser_VaultRevokesToken.yaml @@ -32,7 +32,7 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":2,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:46.924Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":2,"last_used_at":"2024-10-13T12:38:35.438Z","active":true,"expires_at":"2025-07-11"}' + body: '{"id":2,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:46.924Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":2,"last_used_at":"2024-12-14T22:52:51.011Z","active":true,"expires_at":"2025-07-11"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -41,9 +41,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:38:36 GMT + - Sat, 14 Dec 2024 22:56:07 GMT Etag: - - W/"c622b38f506045ed3c55134cf337e4f5" + - W/"294f5bcfa91aa421ae25d18cbc532b92" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -58,15 +58,80 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6H526BKNRXMVDVZKJM9T","version":"1"}' + - '{"correlation_id":"01JF3P5SMB8BSHECD0B5AT06ER","version":"1"}' X-Request-Id: - - 01JA2Y6H526BKNRXMVDVZKJM9T + - 01JF3P5SMB8BSHECD0B5AT06ER X-Runtime: - - "0.023543" + - "0.010411" status: 200 OK code: 200 - duration: 48.414833ms + duration: 13.036583ms - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:56:07 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3P5SN7F65HX3NHVE2WTG1T","version":"1"}' + X-Request-Id: + - 01JF3P5SN7F65HX3NHVE2WTG1T + X-Runtime: + - "0.012643" + status: 200 OK + code: 200 + duration: 15.251125ms + - id: 2 request: proto: HTTP/1.1 proto_major: 1 @@ -97,7 +162,7 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '[{"id":2,"username":"admin-user","name":"Admin User","state":"active","locked":false,"avatar_url":"https://www.gravatar.com/avatar/af0325f5b5bc22760340e6e28bbe467949a83cf3a620329417c7718f89e0f7c5?s=80\u0026d=identicon","web_url":"http://1b25ef517b98/admin-user","created_at":"2024-07-11T18:52:45.504Z","bio":"","location":"","public_email":null,"skype":"","linkedin":"","twitter":"","discord":"","website_url":"","organization":"","job_title":"","pronouns":null,"bot":false,"work_information":null,"local_time":null,"last_sign_in_at":null,"confirmed_at":"2024-07-11T18:52:45.443Z","last_activity_on":"2024-10-13","email":"admin@local","theme_id":3,"color_scheme_id":1,"projects_limit":100000,"current_sign_in_at":null,"identities":[],"can_create_group":true,"can_create_project":true,"two_factor_enabled":false,"external":false,"private_profile":false,"commit_email":"admin@local","is_admin":true,"note":null,"namespace_id":2,"created_by":null,"email_reset_offered_at":null}]' + body: '[{"id":2,"username":"admin-user","name":"Admin User","state":"active","locked":false,"avatar_url":"https://www.gravatar.com/avatar/af0325f5b5bc22760340e6e28bbe467949a83cf3a620329417c7718f89e0f7c5?s=80\u0026d=identicon","web_url":"http://7b1d891ab6bb/admin-user","created_at":"2024-07-11T18:52:45.504Z","bio":"","location":"","public_email":null,"skype":"","linkedin":"","twitter":"","discord":"","website_url":"","organization":"","job_title":"","pronouns":null,"bot":false,"work_information":null,"local_time":null,"last_sign_in_at":null,"confirmed_at":"2024-07-11T18:52:45.443Z","last_activity_on":"2024-12-14","email":"admin@local","theme_id":3,"color_scheme_id":1,"projects_limit":100000,"current_sign_in_at":null,"identities":[],"can_create_group":true,"can_create_project":true,"two_factor_enabled":false,"external":false,"private_profile":false,"commit_email":"admin@local","is_admin":true,"note":null,"namespace_id":2,"created_by":null,"email_reset_offered_at":null}]' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -106,11 +171,11 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:38:37 GMT + - Sat, 14 Dec 2024 22:56:08 GMT Etag: - - W/"e529ce72b73a5e0dbc8ccbc4e988e4e1" + - W/"f223064819d31c48a0be4d173becf031" Link: - - ; rel="first", ; rel="last" + - ; rel="first", ; rel="last" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -125,7 +190,7 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6H7RBSGEY53ZRFEJ7PQW","version":"1"}' + - '{"correlation_id":"01JF3P5SPARHZAZ90WWSNP66P7","version":"1"}' X-Next-Page: - "" X-Page: @@ -135,17 +200,17 @@ interactions: X-Prev-Page: - "" X-Request-Id: - - 01JA2Y6H7RBSGEY53ZRFEJ7PQW + - 01JF3P5SPARHZAZ90WWSNP66P7 X-Runtime: - - "0.034805" + - "0.131789" X-Total: - "1" X-Total-Pages: - "1" status: 200 OK code: 200 - duration: 38.105167ms - - id: 2 + duration: 134.791042ms + - id: 3 request: proto: HTTP/1.1 proto_major: 1 @@ -156,7 +221,7 @@ interactions: host: localhost:8080 remote_addr: "" request_uri: "" - body: '{"name":"personal","expires_at":"2024-12-13","scopes":["read_api"]}' + body: '{"name":"personal","expires_at":"2025-03-13","scopes":["read_api"]}' form: {} headers: Accept: @@ -177,7 +242,7 @@ interactions: trailer: {} content_length: 214 uncompressed: false - body: '{"id":48,"name":"personal","revoked":false,"created_at":"2024-10-13T12:38:37.169Z","scopes":["read_api"],"user_id":2,"last_used_at":null,"active":true,"expires_at":"2024-12-13","token":"glpat-dbiw9ZtysyNAqtLpz5uk"}' + body: '{"id":52,"name":"personal","revoked":false,"created_at":"2024-12-14T22:56:08.194Z","scopes":["read_api"],"user_id":2,"last_used_at":null,"active":true,"expires_at":"2025-03-13","token":"glpat-TzZy7BVeT6B5cdfKVeLa"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -188,9 +253,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:38:37 GMT + - Sat, 14 Dec 2024 22:56:08 GMT Etag: - - W/"ad78461aabd4ab95e7878dd51b1b2e64" + - W/"1e2b1f243fd6e6a99d1ce985eee3c08e" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -204,15 +269,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6HA7CWC14EQKXCFK1V2F","version":"1"}' + - '{"correlation_id":"01JF3P5SYXHZHJR1864Z96M9VC","version":"1"}' X-Request-Id: - - 01JA2Y6HA7CWC14EQKXCFK1V2F + - 01JF3P5SYXHZHJR1864Z96M9VC X-Runtime: - - "0.092150" + - "0.043400" status: 201 Created code: 201 - duration: 95.854417ms - - id: 3 + duration: 47.590416ms + - id: 4 request: proto: HTTP/1.1 proto_major: 1 @@ -242,7 +307,7 @@ interactions: trailer: {} content_length: 199 uncompressed: false - body: '{"id":48,"name":"personal","revoked":false,"created_at":"2024-10-13T12:38:37.169Z","scopes":["read_api"],"user_id":2,"last_used_at":"2024-10-13T12:38:37.329Z","active":true,"expires_at":"2024-12-13"}' + body: '{"id":52,"name":"personal","revoked":false,"created_at":"2024-12-14T22:56:08.194Z","scopes":["read_api"],"user_id":2,"last_used_at":"2024-12-14T22:56:08.264Z","active":true,"expires_at":"2025-03-13"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -253,9 +318,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:38:37 GMT + - Sat, 14 Dec 2024 22:56:08 GMT Etag: - - W/"f0659239028c1b41e0d6c12806348951" + - W/"0ed6dac59f84c605d1dc9b155a193723" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -269,15 +334,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6HG84VBH5HX7FCHP8BJ1","version":"1"}' + - '{"correlation_id":"01JF3P5T1YC2MSFR0BZZ517PHE","version":"1"}' X-Request-Id: - - 01JA2Y6HG84VBH5HX7FCHP8BJ1 + - 01JF3P5T1YC2MSFR0BZZ517PHE X-Runtime: - - "0.013696" + - "0.013308" status: 200 OK code: 200 - duration: 16.850541ms - - id: 4 + duration: 16.454167ms + - id: 5 request: proto: HTTP/1.1 proto_major: 1 @@ -297,7 +362,7 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/48 + url: http://localhost:8080/api/v4/personal_access_tokens/52 method: DELETE response: proto: HTTP/1.1 @@ -314,7 +379,7 @@ interactions: Connection: - keep-alive Date: - - Sun, 13 Oct 2024 12:38:37 GMT + - Sat, 14 Dec 2024 22:56:08 GMT Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -328,15 +393,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6HHASFMMRWNB5PKCAW6P","version":"1"}' + - '{"correlation_id":"01JF3P5T32F4ZYQGX7YAFJKCJS","version":"1"}' X-Request-Id: - - 01JA2Y6HHASFMMRWNB5PKCAW6P + - 01JF3P5T32F4ZYQGX7YAFJKCJS X-Runtime: - - "0.054394" + - "0.022641" status: 204 No Content code: 204 - duration: 57.000542ms - - id: 5 + duration: 25.424958ms + - id: 6 request: proto: HTTP/1.1 proto_major: 1 @@ -377,7 +442,7 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:38:37 GMT + - Sat, 14 Dec 2024 22:56:08 GMT Server: - nginx Vary: @@ -385,11 +450,11 @@ interactions: Www-Authenticate: - Bearer realm="Protected by OAuth 2.0", error="invalid_token", error_description="Token was revoked. You have to re-authorize from the user." X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6HMYBVZSNNFHABRTHYF4","version":"1"}' + - '{"correlation_id":"01JF3P5T4QM20A91RDZKE7TJ7E","version":"1"}' X-Request-Id: - - 01JA2Y6HMYBVZSNNFHABRTHYF4 + - 01JF3P5T4QM20A91RDZKE7TJ7E X-Runtime: - - "0.024553" + - "0.007637" status: 401 Unauthorized code: 401 - duration: 27.516416ms + duration: 10.434291ms diff --git a/testdata/local/TestWithGroupDeployToken.yaml b/testdata/local/TestWithGroupDeployToken.yaml new file mode 100644 index 0000000..91c456e --- /dev/null +++ b/testdata/local/TestWithGroupDeployToken.yaml @@ -0,0 +1,496 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":3,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:54:07.334Z","scopes":["api","read_api","read_user","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":3,"last_used_at":"2024-12-18T23:05:40.296Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Wed, 18 Dec 2024 23:09:49 GMT + Etag: + - W/"be0dfef234b322a232ee48a4b1c17070" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFE0HQT0HA7VJQBDQ5QXP735","version":"1"}' + X-Request-Id: + - 01JFE0HQT0HA7VJQBDQ5QXP735 + X-Runtime: + - "0.023340" + status: 200 OK + code: 200 + duration: 34.600416ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Wed, 18 Dec 2024 23:09:49 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFE0HQW32YAFJDM9T5Z3D1SS","version":"1"}' + X-Request-Id: + - 01JFE0HQW32YAFJDM9T5Z3D1SS + X-Runtime: + - "0.018039" + status: 200 OK + code: 200 + duration: 21.095917ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/groups?search=example + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '[{"id":4,"web_url":"http://7b1d891ab6bb/groups/example","name":"example","path":"example","description":"An example group","visibility":"private","share_with_group_lock":false,"require_two_factor_authentication":false,"two_factor_grace_period":48,"project_creation_level":"developer","auto_devops_enabled":null,"subgroup_creation_level":"maintainer","emails_disabled":false,"emails_enabled":true,"mentions_disabled":null,"lfs_enabled":true,"math_rendering_limits_enabled":true,"lock_math_rendering_limits_enabled":false,"default_branch":null,"default_branch_protection":2,"default_branch_protection_defaults":{"allowed_to_push":[{"access_level":40}],"allow_force_push":false,"allowed_to_merge":[{"access_level":40}]},"avatar_url":null,"request_access_enabled":true,"full_name":"example","full_path":"example","created_at":"2024-07-11T18:56:45.417Z","parent_id":null,"organization_id":1,"shared_runners_setting":"enabled"}]' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Wed, 18 Dec 2024 23:09:49 GMT + Etag: + - W/"6fd9a33736d0be5297949f2bea4f5349" + Link: + - ; rel="first", ; rel="last" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFE0HQXFJZEMP5CRASFRFH27","version":"1"}' + X-Next-Page: + - "" + X-Page: + - "1" + X-Per-Page: + - "20" + X-Prev-Page: + - "" + X-Request-Id: + - 01JFE0HQXFJZEMP5CRASFRFH27 + X-Runtime: + - "0.056516" + X-Total: + - "1" + X-Total-Pages: + - "1" + status: 200 OK + code: 200 + duration: 59.824875ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 88 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: '{"name":"group-deploy","expires_at":"2025-03-18T00:00:00Z","scopes":["read_repository"]}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/groups/4/deploy_tokens + method: POST + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 204 + uncompressed: false + body: '{"id":11,"name":"group-deploy","username":"gitlab+deploy-token-11","expires_at":"2025-03-18T00:00:00.000Z","scopes":["read_repository"],"revoked":false,"expired":false,"token":"gldt-NG7L7VhEp3Y85twMhj1y"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "204" + Content-Type: + - application/json + Date: + - Wed, 18 Dec 2024 23:09:49 GMT + Etag: + - W/"5c8954aa9481460b35b08e8d139a36fb" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFE0HR1AWA968TQKT1F4AFJJ","version":"1"}' + X-Request-Id: + - 01JFE0HR1AWA968TQKT1F4AFJJ + X-Runtime: + - "0.059831" + status: 201 Created + code: 201 + duration: 62.418209ms + - id: 4 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/groups/example/deploy_tokens + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '[{"id":9,"name":"group-deploy","username":"gitlab+deploy-token-9","expires_at":"2025-03-18T00:00:00.000Z","scopes":["read_repository"],"revoked":true,"expired":false},{"id":10,"name":"group-deploy","username":"gitlab+deploy-token-10","expires_at":"2025-03-18T00:00:00.000Z","scopes":["read_repository"],"revoked":true,"expired":false},{"id":11,"name":"group-deploy","username":"gitlab+deploy-token-11","expires_at":"2025-03-18T00:00:00.000Z","scopes":["read_repository"],"revoked":false,"expired":false}]' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Wed, 18 Dec 2024 23:09:49 GMT + Etag: + - W/"2bb8ef669f7d7b70ae49dce0bb17c960" + Link: + - ; rel="first", ; rel="last" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFE0HR58GNHWCESYRFMJHRE3","version":"1"}' + X-Next-Page: + - "" + X-Page: + - "1" + X-Per-Page: + - "20" + X-Prev-Page: + - "" + X-Request-Id: + - 01JFE0HR58GNHWCESYRFMJHRE3 + X-Runtime: + - "0.025797" + X-Total: + - "3" + X-Total-Pages: + - "1" + status: 200 OK + code: 200 + duration: 28.531291ms + - id: 5 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/groups/4/deploy_tokens/11 + method: DELETE + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Cache-Control: + - no-cache + Connection: + - keep-alive + Date: + - Wed, 18 Dec 2024 23:09:49 GMT + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFE0HR73HN9NETJANV3WVPCP","version":"1"}' + X-Request-Id: + - 01JFE0HR73HN9NETJANV3WVPCP + X-Runtime: + - "0.033772" + status: 204 No Content + code: 204 + duration: 36.512833ms + - id: 6 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/groups/example/deploy_tokens + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '[{"id":9,"name":"group-deploy","username":"gitlab+deploy-token-9","expires_at":"2025-03-18T00:00:00.000Z","scopes":["read_repository"],"revoked":true,"expired":false},{"id":10,"name":"group-deploy","username":"gitlab+deploy-token-10","expires_at":"2025-03-18T00:00:00.000Z","scopes":["read_repository"],"revoked":true,"expired":false}]' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Wed, 18 Dec 2024 23:09:49 GMT + Etag: + - W/"e89d1a342309f95048b3c117134c7191" + Link: + - ; rel="first", ; rel="last" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFE0HR9DDCBYZ2Q5MG2G3K2K","version":"1"}' + X-Next-Page: + - "" + X-Page: + - "1" + X-Per-Page: + - "20" + X-Prev-Page: + - "" + X-Request-Id: + - 01JFE0HR9DDCBYZ2Q5MG2G3K2K + X-Runtime: + - "0.020288" + X-Total: + - "2" + X-Total-Pages: + - "1" + status: 200 OK + code: 200 + duration: 23.020667ms diff --git a/testdata/fixtures/16.11.6/TestWithNormalUser_GAT.yaml b/testdata/local/TestWithNormalUser_GAT.yaml similarity index 67% rename from testdata/fixtures/16.11.6/TestWithNormalUser_GAT.yaml rename to testdata/local/TestWithNormalUser_GAT.yaml index 14de79e..d2bb7a9 100644 --- a/testdata/fixtures/16.11.6/TestWithNormalUser_GAT.yaml +++ b/testdata/local/TestWithNormalUser_GAT.yaml @@ -32,7 +32,7 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":3,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:54:07.334Z","scopes":["api","read_api","read_user","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":3,"last_used_at":"2024-10-13T12:38:38.421Z","active":true,"expires_at":"2025-07-11"}' + body: '{"id":3,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:54:07.334Z","scopes":["api","read_api","read_user","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":3,"last_used_at":"2024-12-14T22:52:51.087Z","active":true,"expires_at":"2025-07-11"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -41,9 +41,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:38:38 GMT + - Sat, 14 Dec 2024 22:56:08 GMT Etag: - - W/"cc5eb58605b15a9d07c4de17559ec98c" + - W/"8f85f2050c9c993f8120af90dfd869ae" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -58,15 +58,80 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6JJ60F16H4ZNDGPNP9ZY","version":"1"}' + - '{"correlation_id":"01JF3P5T62T27N8KK434JZ4GYR","version":"1"}' X-Request-Id: - - 01JA2Y6JJ60F16H4ZNDGPNP9ZY + - 01JF3P5T62T27N8KK434JZ4GYR X-Runtime: - - "0.019465" + - "0.009061" status: 200 OK code: 200 - duration: 44.66725ms + duration: 11.25025ms - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:56:08 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3P5T6TYGCTT9H3Q9S0ZPDH","version":"1"}' + X-Request-Id: + - 01JF3P5T6TYGCTT9H3Q9S0ZPDH + X-Runtime: + - "0.010571" + status: 200 OK + code: 200 + duration: 12.913917ms + - id: 2 request: proto: HTTP/1.1 proto_major: 1 @@ -77,7 +142,7 @@ interactions: host: localhost:8080 remote_addr: "" request_uri: "" - body: '{"name":"gat-token","scopes":["read_api"],"access_level":40,"expires_at":"2024-12-18"}' + body: '{"name":"gat-token","scopes":["read_api"],"access_level":40,"expires_at":"2025-03-18"}' form: {} headers: Accept: @@ -98,7 +163,7 @@ interactions: trailer: {} content_length: 233 uncompressed: false - body: '{"id":49,"name":"gat-token","revoked":false,"created_at":"2024-10-13T12:38:38.585Z","scopes":["read_api"],"user_id":7,"last_used_at":null,"active":true,"expires_at":"2024-12-18","access_level":40,"token":"glpat-wiMwr3AFrfqfN2dyir7z"}' + body: '{"id":53,"name":"gat-token","revoked":false,"created_at":"2024-12-14T22:56:08.630Z","scopes":["read_api"],"user_id":9,"last_used_at":null,"active":true,"expires_at":"2025-03-18","access_level":40,"token":"glpat-JmzwgDi-LywTTBoixc53"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -109,9 +174,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:38:38 GMT + - Sat, 14 Dec 2024 22:56:08 GMT Etag: - - W/"5720f864fd167bc12d876edd8d614b73" + - W/"16ab0fd40547a617fa52b5613a677ee1" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -125,15 +190,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6JMMTDEW5Y26NNFC7WM4","version":"1"}' + - '{"correlation_id":"01JF3P5T7T7D0SFXG76NSD9870","version":"1"}' X-Request-Id: - - 01JA2Y6JMMTDEW5Y26NNFC7WM4 + - 01JF3P5T7T7D0SFXG76NSD9870 X-Runtime: - - "0.105643" + - "0.193640" status: 201 Created code: 201 - duration: 109.132416ms - - id: 2 + duration: 196.385166ms + - id: 3 request: proto: HTTP/1.1 proto_major: 1 @@ -163,7 +228,7 @@ interactions: trailer: {} content_length: 200 uncompressed: false - body: '{"id":49,"name":"gat-token","revoked":false,"created_at":"2024-10-13T12:38:38.585Z","scopes":["read_api"],"user_id":7,"last_used_at":"2024-10-13T12:38:38.714Z","active":true,"expires_at":"2024-12-18"}' + body: '{"id":53,"name":"gat-token","revoked":false,"created_at":"2024-12-14T22:56:08.630Z","scopes":["read_api"],"user_id":9,"last_used_at":"2024-12-14T22:56:08.870Z","active":true,"expires_at":"2025-03-18"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -174,9 +239,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:38:38 GMT + - Sat, 14 Dec 2024 22:56:08 GMT Etag: - - W/"ac85a3dcf7d61d2634cfaf44e35c6a59" + - W/"cb8b73735a29788ee0eb59eb8712d425" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -190,15 +255,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6JVGEC8THB5GBRCKHC75","version":"1"}' + - '{"correlation_id":"01JF3P5TM7GJHR8BK52N64TZB3","version":"1"}' X-Request-Id: - - 01JA2Y6JVGEC8THB5GBRCKHC75 + - 01JF3P5TM7GJHR8BK52N64TZB3 X-Runtime: - - "0.020109" + - "0.043875" status: 200 OK code: 200 - duration: 23.452708ms - - id: 3 + duration: 48.609667ms + - id: 4 request: proto: HTTP/1.1 proto_major: 1 @@ -218,7 +283,7 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: http://localhost:8080/api/v4/groups/example/access_tokens/49 + url: http://localhost:8080/api/v4/groups/example/access_tokens/53 method: DELETE response: proto: HTTP/1.1 @@ -235,7 +300,7 @@ interactions: Connection: - keep-alive Date: - - Sun, 13 Oct 2024 12:38:38 GMT + - Sat, 14 Dec 2024 22:56:08 GMT Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -249,15 +314,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6JX19RTKW65YBJ4V6NE2","version":"1"}' + - '{"correlation_id":"01JF3P5TQACHYZQC70QBR7XT6F","version":"1"}' X-Request-Id: - - 01JA2Y6JX19RTKW65YBJ4V6NE2 + - 01JF3P5TQACHYZQC70QBR7XT6F X-Runtime: - - "0.073216" + - "0.035103" status: 204 No Content code: 204 - duration: 76.216667ms - - id: 4 + duration: 37.910917ms + - id: 5 request: proto: HTTP/1.1 proto_major: 1 @@ -298,7 +363,7 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:38:38 GMT + - Sat, 14 Dec 2024 22:56:09 GMT Server: - nginx Vary: @@ -306,11 +371,11 @@ interactions: Www-Authenticate: - Bearer realm="Protected by OAuth 2.0", error="invalid_token", error_description="Token was revoked. You have to re-authorize from the user." X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6K1SWDK0WKWB2Z81DH4T","version":"1"}' + - '{"correlation_id":"01JF3P5TSR5QEY0K8R7M6PBET3","version":"1"}' X-Request-Id: - - 01JA2Y6K1SWDK0WKWB2Z81DH4T + - 01JF3P5TSR5QEY0K8R7M6PBET3 X-Runtime: - - "0.008422" + - "0.007529" status: 401 Unauthorized code: 401 - duration: 11.261667ms + duration: 10.552125ms diff --git a/testdata/fixtures/16.11.6/TestWithNormalUser_PersonalAT_Fails.yaml b/testdata/local/TestWithNormalUser_PersonalAT_Fails.yaml similarity index 64% rename from testdata/fixtures/16.11.6/TestWithNormalUser_PersonalAT_Fails.yaml rename to testdata/local/TestWithNormalUser_PersonalAT_Fails.yaml index 652971b..5f5e9e6 100644 --- a/testdata/fixtures/16.11.6/TestWithNormalUser_PersonalAT_Fails.yaml +++ b/testdata/local/TestWithNormalUser_PersonalAT_Fails.yaml @@ -32,7 +32,7 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":3,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:54:07.334Z","scopes":["api","read_api","read_user","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":3,"last_used_at":"2024-10-13T12:38:38.421Z","active":true,"expires_at":"2025-07-11"}' + body: '{"id":3,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:54:07.334Z","scopes":["api","read_api","read_user","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":3,"last_used_at":"2024-12-14T22:52:51.087Z","active":true,"expires_at":"2025-07-11"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -41,9 +41,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:38:39 GMT + - Sat, 14 Dec 2024 22:56:09 GMT Etag: - - W/"cc5eb58605b15a9d07c4de17559ec98c" + - W/"8f85f2050c9c993f8120af90dfd869ae" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -58,15 +58,80 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6KXPT9DDQTHS0P97ZW6R","version":"1"}' + - '{"correlation_id":"01JF3P5TV1MBBN593G6XKA59GS","version":"1"}' X-Request-Id: - - 01JA2Y6KXPT9DDQTHS0P97ZW6R + - 01JF3P5TV1MBBN593G6XKA59GS X-Runtime: - - "0.031431" + - "0.021441" status: 200 OK code: 200 - duration: 41.503625ms + duration: 23.99375ms - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:56:09 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3P5TWKEZJEPY9SCZYHGC8X","version":"1"}' + X-Request-Id: + - 01JF3P5TWKEZJEPY9SCZYHGC8X + X-Runtime: + - "0.012130" + status: 200 OK + code: 200 + duration: 14.74525ms + - id: 2 request: proto: HTTP/1.1 proto_major: 1 @@ -97,7 +162,7 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '[{"id":3,"username":"normal-user","name":"Normal User","state":"active","locked":false,"avatar_url":"https://www.gravatar.com/avatar/30ee3a8ed91c220db688a3bde115c203763b4281374c40835f69168786a590af?s=80\u0026d=identicon","web_url":"http://1b25ef517b98/normal-user"}]' + body: '[{"id":3,"username":"normal-user","name":"Normal User","state":"active","locked":false,"avatar_url":"https://www.gravatar.com/avatar/30ee3a8ed91c220db688a3bde115c203763b4281374c40835f69168786a590af?s=80\u0026d=identicon","web_url":"http://7b1d891ab6bb/normal-user"}]' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -106,11 +171,11 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:38:39 GMT + - Sat, 14 Dec 2024 22:56:09 GMT Etag: - - W/"8e47761c8cfb2481e9983f2bd4b37cca" + - W/"6f8ceec1ba58b89903625f0ea2be81bc" Link: - - ; rel="first", ; rel="last" + - ; rel="first", ; rel="last" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -125,7 +190,7 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6M0782M70WYC4FDZENSA","version":"1"}' + - '{"correlation_id":"01JF3P5TXPEJJAN7P1XVK2ZEAB","version":"1"}' X-Next-Page: - "" X-Page: @@ -135,17 +200,17 @@ interactions: X-Prev-Page: - "" X-Request-Id: - - 01JA2Y6M0782M70WYC4FDZENSA + - 01JF3P5TXPEJJAN7P1XVK2ZEAB X-Runtime: - - "0.108940" + - "0.086693" X-Total: - "1" X-Total-Pages: - "1" status: 200 OK code: 200 - duration: 112.581917ms - - id: 2 + duration: 89.76825ms + - id: 3 request: proto: HTTP/1.1 proto_major: 1 @@ -156,7 +221,7 @@ interactions: host: localhost:8080 remote_addr: "" request_uri: "" - body: '{"name":"personal","expires_at":"2024-12-18","scopes":["read_api"]}' + body: '{"name":"personal","expires_at":"2025-03-18","scopes":["read_api"]}' form: {} headers: Accept: @@ -188,7 +253,7 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:38:40 GMT + - Sat, 14 Dec 2024 22:56:09 GMT Server: - nginx Vary: @@ -198,11 +263,11 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6M7BXM6P5X757132A299","version":"1"}' + - '{"correlation_id":"01JF3P5V3DT43BSYHW3Z062VZ2","version":"1"}' X-Request-Id: - - 01JA2Y6M7BXM6P5X757132A299 + - 01JF3P5V3DT43BSYHW3Z062VZ2 X-Runtime: - - "0.019930" + - "0.012886" status: 403 Forbidden code: 403 - duration: 24.000625ms + duration: 16.090917ms diff --git a/testdata/fixtures/16.11.6/TestWithNormalUser_ProjectAT.yaml b/testdata/local/TestWithNormalUser_ProjectAT.yaml similarity index 66% rename from testdata/fixtures/16.11.6/TestWithNormalUser_ProjectAT.yaml rename to testdata/local/TestWithNormalUser_ProjectAT.yaml index bf1aab8..c5f27c6 100644 --- a/testdata/fixtures/16.11.6/TestWithNormalUser_ProjectAT.yaml +++ b/testdata/local/TestWithNormalUser_ProjectAT.yaml @@ -32,7 +32,7 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":3,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:54:07.334Z","scopes":["api","read_api","read_user","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":3,"last_used_at":"2024-10-13T12:38:38.421Z","active":true,"expires_at":"2025-07-11"}' + body: '{"id":3,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:54:07.334Z","scopes":["api","read_api","read_user","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":3,"last_used_at":"2024-12-14T22:52:51.087Z","active":true,"expires_at":"2025-07-11"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -41,9 +41,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:38:41 GMT + - Sat, 14 Dec 2024 22:56:09 GMT Etag: - - W/"cc5eb58605b15a9d07c4de17559ec98c" + - W/"8f85f2050c9c993f8120af90dfd869ae" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -58,15 +58,80 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6N3W8Y4D6V0DV98D0Y57","version":"1"}' + - '{"correlation_id":"01JF3P5V500MKQ2034Q5DB5E7H","version":"1"}' X-Request-Id: - - 01JA2Y6N3W8Y4D6V0DV98D0Y57 + - 01JF3P5V500MKQ2034Q5DB5E7H X-Runtime: - - "0.016143" + - "0.012195" status: 200 OK code: 200 - duration: 22.111125ms + duration: 14.919542ms - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:56:09 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3P5V601NXGNACK142HQR2Y","version":"1"}' + X-Request-Id: + - 01JF3P5V601NXGNACK142HQR2Y + X-Runtime: + - "0.015876" + status: 200 OK + code: 200 + duration: 19.262667ms + - id: 2 request: proto: HTTP/1.1 proto_major: 1 @@ -77,7 +142,7 @@ interactions: host: localhost:8080 remote_addr: "" request_uri: "" - body: '{"name":"project","scopes":["read_api"],"access_level":40,"expires_at":"2024-12-18"}' + body: '{"name":"project","scopes":["read_api"],"access_level":40,"expires_at":"2025-03-18"}' form: {} headers: Accept: @@ -96,22 +161,22 @@ interactions: proto_minor: 1 transfer_encoding: [] trailer: {} - content_length: 231 + content_length: 232 uncompressed: false - body: '{"id":50,"name":"project","revoked":false,"created_at":"2024-10-13T12:38:41.278Z","scopes":["read_api"],"user_id":8,"last_used_at":null,"active":true,"expires_at":"2024-12-18","access_level":40,"token":"glpat-yvbXshosBourTuxaddTN"}' + body: '{"id":54,"name":"project","revoked":false,"created_at":"2024-12-14T22:56:09.660Z","scopes":["read_api"],"user_id":10,"last_used_at":null,"active":true,"expires_at":"2025-03-18","access_level":40,"token":"glpat-M9iUXnKNzxxypv7-bS7e"}' headers: Cache-Control: - max-age=0, private, must-revalidate Connection: - keep-alive Content-Length: - - "231" + - "232" Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:38:41 GMT + - Sat, 14 Dec 2024 22:56:09 GMT Etag: - - W/"b38b3cf68e8622b73ded4deebf67cca2" + - W/"40861e5a728d93611d39a2176661607d" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -125,15 +190,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6N58XJW7X1W0KQKG4X5S","version":"1"}' + - '{"correlation_id":"01JF3P5V7BESKT3JHPEZY11A4W","version":"1"}' X-Request-Id: - - 01JA2Y6N58XJW7X1W0KQKG4X5S + - 01JF3P5V7BESKT3JHPEZY11A4W X-Runtime: - - "0.218887" + - "0.214854" status: 201 Created code: 201 - duration: 222.127083ms - - id: 2 + duration: 218.047834ms + - id: 3 request: proto: HTTP/1.1 proto_major: 1 @@ -161,22 +226,22 @@ interactions: proto_minor: 1 transfer_encoding: [] trailer: {} - content_length: 198 + content_length: 199 uncompressed: false - body: '{"id":50,"name":"project","revoked":false,"created_at":"2024-10-13T12:38:41.278Z","scopes":["read_api"],"user_id":8,"last_used_at":"2024-10-13T12:38:41.542Z","active":true,"expires_at":"2024-12-18"}' + body: '{"id":54,"name":"project","revoked":false,"created_at":"2024-12-14T22:56:09.660Z","scopes":["read_api"],"user_id":10,"last_used_at":"2024-12-14T22:56:09.905Z","active":true,"expires_at":"2025-03-18"}' headers: Cache-Control: - max-age=0, private, must-revalidate Connection: - keep-alive Content-Length: - - "198" + - "199" Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:38:41 GMT + - Sat, 14 Dec 2024 22:56:09 GMT Etag: - - W/"bacd3191f3adb053b767c927e436edf1" + - W/"d72ea8bf5bb1c758d1c6906861622fa4" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -190,15 +255,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6NK8GF1F1M0GB371MN3H","version":"1"}' + - '{"correlation_id":"01JF3P5VN386ET3PXZD5930GH2","version":"1"}' X-Request-Id: - - 01JA2Y6NK8GF1F1M0GB371MN3H + - 01JF3P5VN386ET3PXZD5930GH2 X-Runtime: - - "0.044892" + - "0.037436" status: 200 OK code: 200 - duration: 52.550666ms - - id: 3 + duration: 41.255166ms + - id: 4 request: proto: HTTP/1.1 proto_major: 1 @@ -218,7 +283,7 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: http://localhost:8080/api/v4/projects/example%2Fexample/access_tokens/50 + url: http://localhost:8080/api/v4/projects/example%2Fexample/access_tokens/54 method: DELETE response: proto: HTTP/1.1 @@ -235,7 +300,7 @@ interactions: Connection: - keep-alive Date: - - Sun, 13 Oct 2024 12:38:41 GMT + - Sat, 14 Dec 2024 22:56:10 GMT Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -249,15 +314,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6NPH7RK5SH8CYCXVJFPA","version":"1"}' + - '{"correlation_id":"01JF3P5VQQVZ9AFHA0KXGCJ7PM","version":"1"}' X-Request-Id: - - 01JA2Y6NPH7RK5SH8CYCXVJFPA + - 01JF3P5VQQVZ9AFHA0KXGCJ7PM X-Runtime: - - "0.092725" + - "0.032704" status: 204 No Content code: 204 - duration: 95.765458ms - - id: 4 + duration: 36.047625ms + - id: 5 request: proto: HTTP/1.1 proto_major: 1 @@ -298,7 +363,7 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:38:41 GMT + - Sat, 14 Dec 2024 22:56:10 GMT Server: - nginx Vary: @@ -306,11 +371,11 @@ interactions: Www-Authenticate: - Bearer realm="Protected by OAuth 2.0", error="invalid_token", error_description="Token was revoked. You have to re-authorize from the user." X-Gitlab-Meta: - - '{"correlation_id":"01JA2Y6NWJGM2DEYKWDYPVW7X8","version":"1"}' + - '{"correlation_id":"01JF3P5VT0MRDJTEZY5TYN97EH","version":"1"}' X-Request-Id: - - 01JA2Y6NWJGM2DEYKWDYPVW7X8 + - 01JF3P5VT0MRDJTEZY5TYN97EH X-Runtime: - - "0.008327" + - "0.008086" status: 401 Unauthorized code: 401 - duration: 11.218708ms + duration: 10.745583ms diff --git a/testdata/local/TestWithPipelineProjectTriggerAccessToken.yaml b/testdata/local/TestWithPipelineProjectTriggerAccessToken.yaml new file mode 100644 index 0000000..3b9ceb7 --- /dev/null +++ b/testdata/local/TestWithPipelineProjectTriggerAccessToken.yaml @@ -0,0 +1,482 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":3,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:54:07.334Z","scopes":["api","read_api","read_user","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":3,"last_used_at":"2024-12-18T22:01:57.527Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Wed, 18 Dec 2024 22:01:57 GMT + Etag: + - W/"268bcd36006b25382ba281335f4b782a" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFDWNFFA5TQTP6GR7WBXFX6S","version":"1"}' + X-Request-Id: + - 01JFDWNFFA5TQTP6GR7WBXFX6S + X-Runtime: + - "0.055148" + status: 200 OK + code: 200 + duration: 64.912666ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Wed, 18 Dec 2024 22:01:57 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFDWNFKAS156B7G7DEH3Z3NM","version":"1"}' + X-Request-Id: + - 01JFDWNFKAS156B7G7DEH3Z3NM + X-Runtime: + - "0.018433" + status: 200 OK + code: 200 + duration: 21.952333ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/projects/example%2Fexample + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"description":"An example project","name":"example","name_with_namespace":"example / example","path":"example","path_with_namespace":"example/example","created_at":"2024-07-11T18:56:50.987Z","default_branch":"main","tag_list":[],"topics":[],"ssh_url_to_repo":"ssh://git@7b1d891ab6bb:2224/example/example.git","http_url_to_repo":"http://7b1d891ab6bb/example/example.git","web_url":"http://7b1d891ab6bb/example/example","readme_url":null,"forks_count":0,"avatar_url":null,"star_count":0,"last_activity_at":"2024-12-14T22:52:49.801Z","namespace":{"id":4,"name":"example","path":"example","kind":"group","full_path":"example","parent_id":null,"avatar_url":null,"web_url":"http://7b1d891ab6bb/groups/example"},"_links":{"self":"http://7b1d891ab6bb/api/v4/projects/1","issues":"http://7b1d891ab6bb/api/v4/projects/1/issues","merge_requests":"http://7b1d891ab6bb/api/v4/projects/1/merge_requests","repo_branches":"http://7b1d891ab6bb/api/v4/projects/1/repository/branches","labels":"http://7b1d891ab6bb/api/v4/projects/1/labels","events":"http://7b1d891ab6bb/api/v4/projects/1/events","members":"http://7b1d891ab6bb/api/v4/projects/1/members","cluster_agents":"http://7b1d891ab6bb/api/v4/projects/1/cluster_agents"},"packages_enabled":true,"empty_repo":true,"archived":false,"visibility":"private","resolve_outdated_diff_discussions":false,"container_expiration_policy":{"cadence":"1d","enabled":false,"keep_n":10,"older_than":"90d","name_regex":".*","name_regex_keep":null,"next_run_at":"2024-07-12T18:56:51.046Z"},"repository_object_format":"sha1","issues_enabled":true,"merge_requests_enabled":true,"wiki_enabled":true,"jobs_enabled":true,"snippets_enabled":true,"container_registry_enabled":true,"service_desk_enabled":false,"service_desk_address":null,"can_create_merge_request_in":true,"issues_access_level":"enabled","repository_access_level":"enabled","merge_requests_access_level":"enabled","forking_access_level":"enabled","wiki_access_level":"enabled","builds_access_level":"enabled","snippets_access_level":"enabled","pages_access_level":"private","analytics_access_level":"enabled","container_registry_access_level":"enabled","security_and_compliance_access_level":"private","releases_access_level":"enabled","environments_access_level":"enabled","feature_flags_access_level":"enabled","infrastructure_access_level":"enabled","monitor_access_level":"enabled","model_experiments_access_level":"enabled","model_registry_access_level":"enabled","emails_disabled":false,"emails_enabled":true,"shared_runners_enabled":true,"lfs_enabled":true,"creator_id":1,"import_url":null,"import_type":null,"import_status":"none","import_error":null,"open_issues_count":0,"description_html":"\u003cp data-sourcepos=\"1:1-1:18\" dir=\"auto\"\u003eAn example project\u003c/p\u003e","updated_at":"2024-12-14T22:52:49.801Z","ci_default_git_depth":20,"ci_forward_deployment_enabled":true,"ci_forward_deployment_rollback_allowed":true,"ci_job_token_scope_enabled":false,"ci_separated_caches":true,"ci_allow_fork_pipelines_to_run_in_parent_project":true,"build_git_strategy":"fetch","keep_latest_artifact":true,"restrict_user_defined_variables":false,"runners_token":"GR1348941kVN9uhY6NrsD16F27pKx","runner_token_expiration_interval":null,"group_runners_enabled":true,"auto_cancel_pending_pipelines":"enabled","build_timeout":3600,"auto_devops_enabled":true,"auto_devops_deploy_strategy":"continuous","ci_config_path":null,"public_jobs":true,"shared_with_groups":[],"only_allow_merge_if_pipeline_succeeds":false,"allow_merge_on_skipped_pipeline":null,"request_access_enabled":true,"only_allow_merge_if_all_discussions_are_resolved":false,"remove_source_branch_after_merge":true,"printing_merge_request_link_enabled":true,"merge_method":"merge","squash_option":"default_off","enforce_auth_checks_on_uploads":true,"suggestion_commit_message":null,"merge_commit_template":null,"squash_commit_template":null,"issue_branch_template":null,"warn_about_potentially_unwanted_characters":true,"autoclose_referenced_issues":true,"permissions":{"project_access":null,"group_access":{"access_level":50,"notification_level":3}}}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Wed, 18 Dec 2024 22:01:57 GMT + Etag: + - W/"decf557450b6591083de9190167b8808" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFDWNFMSTKG12GQH8VXGH3EC","version":"1"}' + X-Request-Id: + - 01JFDWNFMSTKG12GQH8VXGH3EC + X-Runtime: + - "0.278931" + status: 200 OK + code: 200 + duration: 281.973833ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 42 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: '{"description":"pipeline-project-trigger"}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/projects/1/triggers + method: POST + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 476 + uncompressed: false + body: '{"id":9,"token":"glptt-3e77c19cf7cc84c27eb703c5a2d92c4846fa70c0","description":"pipeline-project-trigger","created_at":"2024-12-18T22:01:58.292Z","updated_at":"2024-12-18T22:01:58.292Z","last_used":null,"owner":{"id":3,"username":"normal-user","name":"Normal User","state":"active","locked":false,"avatar_url":"https://www.gravatar.com/avatar/30ee3a8ed91c220db688a3bde115c203763b4281374c40835f69168786a590af?s=80\u0026d=identicon","web_url":"http://7b1d891ab6bb/normal-user"}}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "476" + Content-Type: + - application/json + Date: + - Wed, 18 Dec 2024 22:01:58 GMT + Etag: + - W/"5bb320ce9746c8559fd73e68751441ae" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFDWNG6JSJD9Q6R46DMBKHEZ","version":"1"}' + X-Request-Id: + - 01JFDWNG6JSJD9Q6R46DMBKHEZ + X-Runtime: + - "0.074706" + status: 201 Created + code: 201 + duration: 83.29975ms + - id: 4 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/projects/example%2Fexample/triggers + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '[{"id":9,"token":"glptt-3e77c19cf7cc84c27eb703c5a2d92c4846fa70c0","description":"pipeline-project-trigger","created_at":"2024-12-18T22:01:58.292Z","updated_at":"2024-12-18T22:01:58.292Z","last_used":null,"owner":{"id":3,"username":"normal-user","name":"Normal User","state":"active","locked":false,"avatar_url":"https://www.gravatar.com/avatar/30ee3a8ed91c220db688a3bde115c203763b4281374c40835f69168786a590af?s=80\u0026d=identicon","web_url":"http://7b1d891ab6bb/normal-user"}}]' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Wed, 18 Dec 2024 22:01:58 GMT + Etag: + - W/"2fd0ec598a2ca60ffc11192b5d65e129" + Link: + - ; rel="first", ; rel="last" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFDWNGBS2ZYBSCWS6VDA7MRB","version":"1"}' + X-Next-Page: + - "" + X-Page: + - "1" + X-Per-Page: + - "20" + X-Prev-Page: + - "" + X-Request-Id: + - 01JFDWNGBS2ZYBSCWS6VDA7MRB + X-Runtime: + - "0.038019" + X-Total: + - "1" + X-Total-Pages: + - "1" + status: 200 OK + code: 200 + duration: 42.206459ms + - id: 5 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/projects/1/triggers/9 + method: DELETE + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Cache-Control: + - no-cache + Connection: + - keep-alive + Date: + - Wed, 18 Dec 2024 22:01:58 GMT + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFDWNGEG7FY1CTDPW5DFS5J1","version":"1"}' + X-Request-Id: + - 01JFDWNGEG7FY1CTDPW5DFS5J1 + X-Runtime: + - "0.026468" + status: 204 No Content + code: 204 + duration: 29.447958ms + - id: 6 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/projects/example%2Fexample/triggers + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 2 + uncompressed: false + body: '[]' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "2" + Content-Type: + - application/json + Date: + - Wed, 18 Dec 2024 22:01:58 GMT + Etag: + - W/"4f53cda18c2baa0c0354bb5f9a3ecbe5" + Link: + - ; rel="first", ; rel="last" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFDWNGGCVWYPWZE1Y0A4DR1S","version":"1"}' + X-Next-Page: + - "" + X-Page: + - "1" + X-Per-Page: + - "20" + X-Prev-Page: + - "" + X-Request-Id: + - 01JFDWNGGCVWYPWZE1Y0A4DR1S + X-Runtime: + - "0.028556" + X-Total: + - "0" + X-Total-Pages: + - "1" + status: 200 OK + code: 200 + duration: 31.911167ms diff --git a/testdata/local/TestWithProjectDeployToken.yaml b/testdata/local/TestWithProjectDeployToken.yaml new file mode 100644 index 0000000..5b4f88a --- /dev/null +++ b/testdata/local/TestWithProjectDeployToken.yaml @@ -0,0 +1,482 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":3,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:54:07.334Z","scopes":["api","read_api","read_user","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":3,"last_used_at":"2024-12-18T23:05:40.296Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Wed, 18 Dec 2024 23:06:22 GMT + Etag: + - W/"be0dfef234b322a232ee48a4b1c17070" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFE0BE7ZGZE3AR63MP09BN47","version":"1"}' + X-Request-Id: + - 01JFE0BE7ZGZE3AR63MP09BN47 + X-Runtime: + - "0.023002" + status: 200 OK + code: 200 + duration: 34.494333ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Wed, 18 Dec 2024 23:06:22 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFE0BEA1QX9DX6RH0V8K81JY","version":"1"}' + X-Request-Id: + - 01JFE0BEA1QX9DX6RH0V8K81JY + X-Runtime: + - "0.019967" + status: 200 OK + code: 200 + duration: 23.325833ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/projects/example%2Fexample + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"description":"An example project","name":"example","name_with_namespace":"example / example","path":"example","path_with_namespace":"example/example","created_at":"2024-07-11T18:56:50.987Z","default_branch":"main","tag_list":[],"topics":[],"ssh_url_to_repo":"ssh://git@7b1d891ab6bb:2224/example/example.git","http_url_to_repo":"http://7b1d891ab6bb/example/example.git","web_url":"http://7b1d891ab6bb/example/example","readme_url":null,"forks_count":0,"avatar_url":null,"star_count":0,"last_activity_at":"2024-12-14T22:52:49.801Z","namespace":{"id":4,"name":"example","path":"example","kind":"group","full_path":"example","parent_id":null,"avatar_url":null,"web_url":"http://7b1d891ab6bb/groups/example"},"_links":{"self":"http://7b1d891ab6bb/api/v4/projects/1","issues":"http://7b1d891ab6bb/api/v4/projects/1/issues","merge_requests":"http://7b1d891ab6bb/api/v4/projects/1/merge_requests","repo_branches":"http://7b1d891ab6bb/api/v4/projects/1/repository/branches","labels":"http://7b1d891ab6bb/api/v4/projects/1/labels","events":"http://7b1d891ab6bb/api/v4/projects/1/events","members":"http://7b1d891ab6bb/api/v4/projects/1/members","cluster_agents":"http://7b1d891ab6bb/api/v4/projects/1/cluster_agents"},"packages_enabled":true,"empty_repo":true,"archived":false,"visibility":"private","resolve_outdated_diff_discussions":false,"container_expiration_policy":{"cadence":"1d","enabled":false,"keep_n":10,"older_than":"90d","name_regex":".*","name_regex_keep":null,"next_run_at":"2024-07-12T18:56:51.046Z"},"repository_object_format":"sha1","issues_enabled":true,"merge_requests_enabled":true,"wiki_enabled":true,"jobs_enabled":true,"snippets_enabled":true,"container_registry_enabled":true,"service_desk_enabled":false,"service_desk_address":null,"can_create_merge_request_in":true,"issues_access_level":"enabled","repository_access_level":"enabled","merge_requests_access_level":"enabled","forking_access_level":"enabled","wiki_access_level":"enabled","builds_access_level":"enabled","snippets_access_level":"enabled","pages_access_level":"private","analytics_access_level":"enabled","container_registry_access_level":"enabled","security_and_compliance_access_level":"private","releases_access_level":"enabled","environments_access_level":"enabled","feature_flags_access_level":"enabled","infrastructure_access_level":"enabled","monitor_access_level":"enabled","model_experiments_access_level":"enabled","model_registry_access_level":"enabled","emails_disabled":false,"emails_enabled":true,"shared_runners_enabled":true,"lfs_enabled":true,"creator_id":1,"import_url":null,"import_type":null,"import_status":"none","import_error":null,"open_issues_count":0,"description_html":"\u003cp data-sourcepos=\"1:1-1:18\" dir=\"auto\"\u003eAn example project\u003c/p\u003e","updated_at":"2024-12-14T22:52:49.801Z","ci_default_git_depth":20,"ci_forward_deployment_enabled":true,"ci_forward_deployment_rollback_allowed":true,"ci_job_token_scope_enabled":false,"ci_separated_caches":true,"ci_allow_fork_pipelines_to_run_in_parent_project":true,"build_git_strategy":"fetch","keep_latest_artifact":true,"restrict_user_defined_variables":false,"runners_token":"GR1348941kVN9uhY6NrsD16F27pKx","runner_token_expiration_interval":null,"group_runners_enabled":true,"auto_cancel_pending_pipelines":"enabled","build_timeout":3600,"auto_devops_enabled":true,"auto_devops_deploy_strategy":"continuous","ci_config_path":null,"public_jobs":true,"shared_with_groups":[],"only_allow_merge_if_pipeline_succeeds":false,"allow_merge_on_skipped_pipeline":null,"request_access_enabled":true,"only_allow_merge_if_all_discussions_are_resolved":false,"remove_source_branch_after_merge":true,"printing_merge_request_link_enabled":true,"merge_method":"merge","squash_option":"default_off","enforce_auth_checks_on_uploads":true,"suggestion_commit_message":null,"merge_commit_template":null,"squash_commit_template":null,"issue_branch_template":null,"warn_about_potentially_unwanted_characters":true,"autoclose_referenced_issues":true,"permissions":{"project_access":null,"group_access":{"access_level":50,"notification_level":3}}}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Wed, 18 Dec 2024 23:06:23 GMT + Etag: + - W/"decf557450b6591083de9190167b8808" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFE0BEBJXKFND042AKQNAS29","version":"1"}' + X-Request-Id: + - 01JFE0BEBJXKFND042AKQNAS29 + X-Runtime: + - "0.082759" + status: 200 OK + code: 200 + duration: 85.264209ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 90 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: '{"name":"project-deploy","expires_at":"2025-03-18T00:00:00Z","scopes":["read_repository"]}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/projects/1/deploy_tokens + method: POST + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 204 + uncompressed: false + body: '{"id":8,"name":"project-deploy","username":"gitlab+deploy-token-8","expires_at":"2025-03-18T00:00:00.000Z","scopes":["read_repository"],"revoked":false,"expired":false,"token":"gldt-8DFCxRz1tWK_MEqGeoSN"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "204" + Content-Type: + - application/json + Date: + - Wed, 18 Dec 2024 23:06:23 GMT + Etag: + - W/"8420d8f2ceb95eb2e536b564993645cb" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFE0BEGZKD7MY63P4HR3JHA3","version":"1"}' + X-Request-Id: + - 01JFE0BEGZKD7MY63P4HR3JHA3 + X-Runtime: + - "0.024528" + status: 201 Created + code: 201 + duration: 26.744375ms + - id: 4 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/projects/example%2Fexample/deploy_tokens + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '[{"id":1,"name":"project-deploy","username":"gitlab+deploy-token-1","expires_at":"2025-03-18T00:00:00.000Z","scopes":["read_repository"],"revoked":true,"expired":false},{"id":2,"name":"project-deploy","username":"gitlab+deploy-token-2","expires_at":"2025-03-18T00:00:00.000Z","scopes":["read_repository"],"revoked":true,"expired":false},{"id":3,"name":"project-deploy","username":"gitlab+deploy-token-3","expires_at":"2025-03-18T00:00:00.000Z","scopes":["read_repository"],"revoked":true,"expired":false},{"id":4,"name":"project-deploy","username":"gitlab+deploy-token-4","expires_at":"2025-03-18T00:00:00.000Z","scopes":["read_repository"],"revoked":true,"expired":false},{"id":5,"name":"project-deploy","username":"gitlab+deploy-token-5","expires_at":"2025-03-18T00:00:00.000Z","scopes":["read_repository"],"revoked":true,"expired":false},{"id":6,"name":"project-deploy","username":"gitlab+deploy-token-6","expires_at":"2025-03-18T00:00:00.000Z","scopes":["read_repository"],"revoked":true,"expired":false},{"id":7,"name":"project-deploy","username":"gitlab+deploy-token-7","expires_at":"2025-03-18T00:00:00.000Z","scopes":["read_repository"],"revoked":true,"expired":false},{"id":8,"name":"project-deploy","username":"gitlab+deploy-token-8","expires_at":"2025-03-18T00:00:00.000Z","scopes":["read_repository"],"revoked":false,"expired":false}]' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Wed, 18 Dec 2024 23:06:23 GMT + Etag: + - W/"d1a141f9167d754aac5731f97b60fefd" + Link: + - ; rel="first", ; rel="last" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFE0BEJPQ7JCGDF5S94JTB0W","version":"1"}' + X-Next-Page: + - "" + X-Page: + - "1" + X-Per-Page: + - "20" + X-Prev-Page: + - "" + X-Request-Id: + - 01JFE0BEJPQ7JCGDF5S94JTB0W + X-Runtime: + - "0.019235" + X-Total: + - "8" + X-Total-Pages: + - "1" + status: 200 OK + code: 200 + duration: 21.385125ms + - id: 5 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/projects/1/deploy_tokens/8 + method: DELETE + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Cache-Control: + - no-cache + Connection: + - keep-alive + Date: + - Wed, 18 Dec 2024 23:06:23 GMT + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFE0BEM4PX67VZQ32SP9RJPF","version":"1"}' + X-Request-Id: + - 01JFE0BEM4PX67VZQ32SP9RJPF + X-Runtime: + - "0.023513" + status: 204 No Content + code: 204 + duration: 25.872375ms + - id: 6 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/projects/example%2Fexample/deploy_tokens + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '[{"id":1,"name":"project-deploy","username":"gitlab+deploy-token-1","expires_at":"2025-03-18T00:00:00.000Z","scopes":["read_repository"],"revoked":true,"expired":false},{"id":2,"name":"project-deploy","username":"gitlab+deploy-token-2","expires_at":"2025-03-18T00:00:00.000Z","scopes":["read_repository"],"revoked":true,"expired":false},{"id":3,"name":"project-deploy","username":"gitlab+deploy-token-3","expires_at":"2025-03-18T00:00:00.000Z","scopes":["read_repository"],"revoked":true,"expired":false},{"id":4,"name":"project-deploy","username":"gitlab+deploy-token-4","expires_at":"2025-03-18T00:00:00.000Z","scopes":["read_repository"],"revoked":true,"expired":false},{"id":5,"name":"project-deploy","username":"gitlab+deploy-token-5","expires_at":"2025-03-18T00:00:00.000Z","scopes":["read_repository"],"revoked":true,"expired":false},{"id":6,"name":"project-deploy","username":"gitlab+deploy-token-6","expires_at":"2025-03-18T00:00:00.000Z","scopes":["read_repository"],"revoked":true,"expired":false},{"id":7,"name":"project-deploy","username":"gitlab+deploy-token-7","expires_at":"2025-03-18T00:00:00.000Z","scopes":["read_repository"],"revoked":true,"expired":false}]' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Wed, 18 Dec 2024 23:06:23 GMT + Etag: + - W/"8d50b6ece480b7f2410808039db50a0d" + Link: + - ; rel="first", ; rel="last" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFE0BENSDW6ZJMGXTA6DBHC2","version":"1"}' + X-Next-Page: + - "" + X-Page: + - "1" + X-Per-Page: + - "20" + X-Prev-Page: + - "" + X-Request-Id: + - 01JFE0BENSDW6ZJMGXTA6DBHC2 + X-Runtime: + - "0.023720" + X-Total: + - "7" + X-Total-Pages: + - "1" + status: 200 OK + code: 200 + duration: 26.157333ms diff --git a/testdata/fixtures/16.11.6/TestWithGitlabUser_RotateToken.yaml b/testdata/saas/TestWithGitlabUser_RotateToken.yaml similarity index 57% rename from testdata/fixtures/16.11.6/TestWithGitlabUser_RotateToken.yaml rename to testdata/saas/TestWithGitlabUser_RotateToken.yaml index 85504fd..f73d026 100644 --- a/testdata/fixtures/16.11.6/TestWithGitlabUser_RotateToken.yaml +++ b/testdata/saas/TestWithGitlabUser_RotateToken.yaml @@ -31,24 +31,24 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":10934131,"name":"vault-plugin-test-token","revoked":false,"created_at":"2024-10-13T13:03:17.081Z","scopes":["api","read_api","read_user"],"user_id":32923,"last_used_at":"2024-10-13T13:03:28.577Z","active":true,"expires_at":"2025-10-13"}' + body: '{"id":12599486,"name":"test-vault-plugin","revoked":false,"created_at":"2024-12-14T22:59:20.679Z","description":"","scopes":["api","read_api","read_user","create_runner","manage_runner","k8s_proxy","read_repository","write_repository","read_registry","write_registry","ai_features"],"user_id":32923,"last_used_at":"2024-12-14T22:59:41.430Z","active":true,"expires_at":"2025-01-13"}' headers: Cache-Control: - max-age=0, private, must-revalidate Cf-Cache-Status: - MISS Cf-Ray: - - 8d1f87ab0a8fb75b-AMS + - 8f21ce4749830a55-AMS Content-Security-Policy: - default-src 'none' Content-Type: - application/json Date: - - Sun, 13 Oct 2024 13:03:28 GMT + - Sat, 14 Dec 2024 22:59:41 GMT Etag: - - W/"294188617136d6cc8b17945693da200f" + - W/"f794c61ca0a8939380419c7f4afacc2c" Gitlab-Lb: - - haproxy-main-37-lb-gprd + - haproxy-main-19-lb-gprd Gitlab-Sv: - api-gke-us-east1-c Nel: @@ -56,11 +56,11 @@ interactions: Referrer-Policy: - strict-origin-when-cross-origin Report-To: - - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=VqkuZl76Cg7JiY7ff7SignCsDTQuZVwO5eViaPhx5%2BbcNlqtmqm%2BBYNwFOGskBm67jjH8S74rg%2FFdKmXklNuQ9ve5GZgN1Bw3ZDrWxX1G7oa0AEiIMZgAAtUGCE%3D"}],"group":"cf-nel","max_age":604800}' + - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=E5Ub4Md%2FRVMnvoi35mE6DmGBBhlZz%2B%2BwfKe1cwR2ZszaqsLo1uNyKiyFL%2FpjkWRqFSfOg%2BB46k5VZAhA6%2F%2FG%2B8yChIZRM7%2FEApD02piWOjJr1GBRaKj%2BfjE2V%2BY%3D"}],"group":"cf-nel","max_age":604800}' Server: - cloudflare Set-Cookie: - - _cfuvid=SVJz4DU2cmnbq6b0TFyMEsOMdN7n6i.uSm5eQ_LAwEU-1728824608692-0.0.1.1-604800000; path=/; domain=.gitlab.com; HttpOnly; Secure; SameSite=None + - _cfuvid=LjZU2k1KKJNW9IfL.bwEweQDNgGE_f_ER0mHr_Y_030-1734217181558-0.0.1.1-604800000; path=/; domain=.gitlab.com; HttpOnly; Secure; SameSite=None Strict-Transport-Security: - max-age=31536000 Vary: @@ -70,14 +70,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"c38547d7a5bc8900007b6e1392137f09","version":"1"}' + - '{"correlation_id":"76ae1ba74ac8e4ec33fabadd7a419ec3","version":"1"}' X-Request-Id: - - c38547d7a5bc8900007b6e1392137f09 + - 76ae1ba74ac8e4ec33fabadd7a419ec3 X-Runtime: - - "0.061652" + - "0.076656" status: 200 OK code: 200 - duration: 253.662208ms + duration: 299.593625ms - id: 1 request: proto: HTTP/1.1 @@ -98,7 +98,7 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: https://gitlab.com/api/v4/personal_access_tokens/self + url: https://gitlab.com/api/v4/metadata method: GET response: proto: HTTP/2.0 @@ -108,36 +108,36 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":10934131,"name":"vault-plugin-test-token","revoked":false,"created_at":"2024-10-13T13:03:17.081Z","scopes":["api","read_api","read_user"],"user_id":32923,"last_used_at":"2024-10-13T13:03:28.577Z","active":true,"expires_at":"2025-10-13"}' + body: '{"version":"17.7.0-pre","revision":"a4ebccf2510","kas":{"enabled":true,"externalUrl":"wss://kas.gitlab.com","externalK8sProxyUrl":"https://kas.gitlab.com/k8s-proxy","version":"17.7.0+ed8e69891a82913e19430e094c192833ea5cb066"},"enterprise":true}' headers: Cache-Control: - max-age=0, private, must-revalidate Cf-Cache-Status: - MISS Cf-Ray: - - 8d1f87ae0e30b75b-AMS + - 8f21ce4acb140a55-AMS Content-Security-Policy: - default-src 'none' Content-Type: - application/json Date: - - Sun, 13 Oct 2024 13:03:29 GMT + - Sat, 14 Dec 2024 22:59:42 GMT Etag: - - W/"294188617136d6cc8b17945693da200f" + - W/"42990db62d0a22aa8c185c497cfe94da" Gitlab-Lb: - - haproxy-main-39-lb-gprd + - haproxy-main-59-lb-gprd Gitlab-Sv: - - api-gke-us-east1-b + - api-gke-us-east1-d Nel: - '{"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}' Referrer-Policy: - strict-origin-when-cross-origin Report-To: - - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=Upi8RPW3c7Fs715RcPDacYH3c6gHGTLhWtTNaSug3dJguYvUykj8m9mLGq60qJlei9Z1rmrAeXu8K1tB1oeowT%2F4SxA5MgXJzZAp%2BwwkBonOwpYawa5829nU3fQ%3D"}],"group":"cf-nel","max_age":604800}' + - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=pC7gnuip%2FtI6bQrwQjlDWZnQh8wXf8ZW9UqzFs9rd4H5Fw4Rh8sAmcsZGJRsrMrUjfSF5f8coOSE925wvsvvb6WSe7ZJbIhMF%2F%2FS6Zv0VrgAej9dXE3tQuwGLbs%3D"}],"group":"cf-nel","max_age":604800}' Server: - cloudflare Set-Cookie: - - _cfuvid=lS62hLiOKyL9SLPMzt6B7RDbTJOQeFI1xZJP1fjh90o-1728824609124-0.0.1.1-604800000; path=/; domain=.gitlab.com; HttpOnly; Secure; SameSite=None + - _cfuvid=2LbQE0saTViTYHbPTnKAE7Tei6kveQ4.3b3SCRLgQ.8-1734217182061-0.0.1.1-604800000; path=/; domain=.gitlab.com; HttpOnly; Secure; SameSite=None Strict-Transport-Security: - max-age=31536000 Vary: @@ -147,15 +147,92 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"733bc510aefe3e01f88e50b0e5cd63c6","version":"1"}' + - '{"correlation_id":"5ddc666b281d5b856a041ad838ccbc4c","version":"1"}' X-Request-Id: - - 733bc510aefe3e01f88e50b0e5cd63c6 + - 5ddc666b281d5b856a041ad838ccbc4c X-Runtime: - - "0.026855" + - "0.028307" status: 200 OK code: 200 - duration: 175.366208ms + duration: 197.686875ms - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: gitlab.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: https://gitlab.com/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":12599486,"name":"test-vault-plugin","revoked":false,"created_at":"2024-12-14T22:59:20.679Z","description":"","scopes":["api","read_api","read_user","create_runner","manage_runner","k8s_proxy","read_repository","write_repository","read_registry","write_registry","ai_features"],"user_id":32923,"last_used_at":"2024-12-14T22:59:41.430Z","active":true,"expires_at":"2025-01-13"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Cf-Cache-Status: + - MISS + Cf-Ray: + - 8f21ce4d4c310a55-AMS + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:59:42 GMT + Etag: + - W/"f794c61ca0a8939380419c7f4afacc2c" + Gitlab-Lb: + - haproxy-main-05-lb-gprd + Gitlab-Sv: + - api-gke-us-east1-d + Nel: + - '{"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}' + Referrer-Policy: + - strict-origin-when-cross-origin + Report-To: + - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=4JWaqN7KbOQqrxsL50WUfaK3ARHK5RV6KhEy8pAszNiq5j0ycpjun0HWN1OlBAIoih76TR5CD6ZHPyekYhcPSvWevaMvD1GGuiv31BN8xzZxfhjGThatDcCA8uc%3D"}],"group":"cf-nel","max_age":604800}' + Server: + - cloudflare + Set-Cookie: + - _cfuvid=CkXd8xumccWV0stOKK56vrchDoB2OhCxMUACvPfbxUA-1734217182459-0.0.1.1-604800000; path=/; domain=.gitlab.com; HttpOnly; Secure; SameSite=None + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Origin, Accept-Encoding + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"6b206ba215cb3468a0164645e7318a72","version":"1"}' + X-Request-Id: + - 6b206ba215cb3468a0164645e7318a72 + X-Runtime: + - "0.028247" + status: 200 OK + code: 200 + duration: 191.668792ms + - id: 3 request: proto: HTTP/1.1 proto_major: 1 @@ -185,24 +262,24 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":32923,"username":"ilijamt","name":"Ilija Matoski","state":"active","locked":false,"avatar_url":"https://secure.gravatar.com/avatar/e1bd6bdeae5b3bcd803934a067f39933dd21f9da7974c8e3623ee21ece5fea61?s=80\u0026d=identicon","web_url":"https://gitlab.com/ilijamt","created_at":"2014-05-19T14:51:54.441Z","bio":"","location":"","public_email":"","skype":"","linkedin":"","twitter":"","discord":"","website_url":"","organization":"","job_title":"","pronouns":null,"bot":false,"work_information":null,"local_time":"1:03 PM"}' + body: '{"id":32923,"username":"ilijamt","name":"Ilija Matoski","state":"active","locked":false,"avatar_url":"https://secure.gravatar.com/avatar/e1bd6bdeae5b3bcd803934a067f39933dd21f9da7974c8e3623ee21ece5fea61?s=80\u0026d=identicon","web_url":"https://gitlab.com/ilijamt","created_at":"2014-05-19T14:51:54.441Z","bio":"","location":"","public_email":"","skype":"","linkedin":"","twitter":"","discord":"","website_url":"","organization":"","job_title":"","pronouns":null,"bot":false,"work_information":null,"local_time":"10:59 PM"}' headers: Cache-Control: - max-age=0, private, must-revalidate Cf-Cache-Status: - MISS Cf-Ray: - - 8d1f87b038adb75b-AMS + - 8f21ce4fad330a55-AMS Content-Security-Policy: - default-src 'none' Content-Type: - application/json Date: - - Sun, 13 Oct 2024 13:03:29 GMT + - Sat, 14 Dec 2024 22:59:42 GMT Etag: - - W/"b6346ba117fc3b24678689c5133788c8" + - W/"de8f648eda42b4b038ad09efd43b440a" Gitlab-Lb: - - haproxy-main-18-lb-gprd + - haproxy-main-57-lb-gprd Gitlab-Sv: - api-gke-us-east1-b Nel: @@ -210,11 +287,11 @@ interactions: Referrer-Policy: - strict-origin-when-cross-origin Report-To: - - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=kxk6NWDLHAlAiLO1FN59VF4F%2Bq711B0tXj%2BLYlmTdru7fzhByT%2FnrA6Gx1OhTrhhdrE6Jamxneo5llf2ZTEWwGfz3hq97OSNqjoPz1sOhWnXghJosE%2FrlLwzCWk%3D"}],"group":"cf-nel","max_age":604800}' + - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=911EsboJ1hiAtsVSyvPVP6o4gI2uBXkBdwFWmrQvLv%2FHnUTnHFwI2BY%2BLsDMKB%2FVTgRkQ7OwqXd4sm84RDYLtXlUyikMC0EM8O4MPPSNkf%2FKgnc%2FpLEYkV5jsDQ%3D"}],"group":"cf-nel","max_age":604800}' Server: - cloudflare Set-Cookie: - - _cfuvid=z4k7fwbRiDnlvAkU6aZFjScA.lqHc6TlQov0br8OWk0-1728824609493-0.0.1.1-604800000; path=/; domain=.gitlab.com; HttpOnly; Secure; SameSite=None + - _cfuvid=bUTUieoCBuVRZiZburxH0xHx65YLFLuM1.sQCkJxwdw-1734217182847-0.0.1.1-604800000; path=/; domain=.gitlab.com; HttpOnly; Secure; SameSite=None Strict-Transport-Security: - max-age=31536000 Vary: @@ -224,15 +301,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"c76be0e9529736c4302ea28a308dad49","version":"1"}' + - '{"correlation_id":"6585ba3e8c1327f2d8b169b89b1acca6","version":"1"}' X-Request-Id: - - c76be0e9529736c4302ea28a308dad49 + - 6585ba3e8c1327f2d8b169b89b1acca6 X-Runtime: - - "0.044967" + - "0.037286" status: 200 OK code: 200 - duration: 191.475458ms - - id: 3 + duration: 192.623584ms + - id: 4 request: proto: HTTP/1.1 proto_major: 1 @@ -243,7 +320,7 @@ interactions: host: gitlab.com remote_addr: "" request_uri: "" - body: '{"expires_at":"2025-08-12"}' + body: '{"expires_at":"2025-01-11"}' form: {} headers: Accept: @@ -254,7 +331,7 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: https://gitlab.com/api/v4/personal_access_tokens/10934131/rotate + url: https://gitlab.com/api/v4/personal_access_tokens/12599486/rotate method: POST response: proto: HTTP/2.0 @@ -264,24 +341,24 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":10934133,"name":"vault-plugin-test-token","revoked":false,"created_at":"2024-10-13T13:03:29.810Z","scopes":["api","read_api","read_user"],"user_id":32923,"last_used_at":null,"active":true,"expires_at":"2025-08-12","token":"glpat-U4jnJZhSVRhDh5Wds61K"}' + body: '{"id":12599488,"name":"test-vault-plugin","revoked":false,"created_at":"2024-12-14T22:59:43.256Z","description":null,"scopes":["api","read_api","read_user","create_runner","manage_runner","k8s_proxy","read_repository","write_repository","read_registry","write_registry","ai_features"],"user_id":32923,"last_used_at":null,"active":true,"expires_at":"2025-01-11","token":"glpat-8-Qa_16zzKbhsDM7qTnr"}' headers: Cache-Control: - max-age=0, private, must-revalidate Cf-Cache-Status: - DYNAMIC Cf-Ray: - - 8d1f87b29af7b75b-AMS + - 8f21ce521e720a55-AMS Content-Security-Policy: - default-src 'none' Content-Type: - application/json Date: - - Sun, 13 Oct 2024 13:03:29 GMT + - Sat, 14 Dec 2024 22:59:43 GMT Etag: - - W/"4a42d9b3ba1fbf3b7d1b3f5fe364e001" + - W/"ef62e33e7c3dfa7d14d65db4c41f1dfd" Gitlab-Lb: - - haproxy-main-26-lb-gprd + - haproxy-main-47-lb-gprd Gitlab-Sv: - api-gke-us-east1-d Nel: @@ -289,29 +366,29 @@ interactions: Referrer-Policy: - strict-origin-when-cross-origin Report-To: - - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=NecTlXBiQkTSVAsyvgtCJXPc5O9zwSLaMdIhfoX1XTSVPsHYt4dZ0ynygTe7d0W04R2aDMXVEk5mKALd5urwwC9vBqlKvOODjBbiKLo6yjnPgjxTC2xTR%2BRTGgg%3D"}],"group":"cf-nel","max_age":604800}' + - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=QBOsqupRJ0VptIN6zFpUD1Co7Ciq3IA1A1NzDKwLsn8qIT7Z5mSpxjGFGPVlTJAL51d3I7CbMx84pQy80pp1IyM6%2BBicq8jN3OBWLBEvSDfxn%2Fku%2Fv%2Feg7t8I1o%3D"}],"group":"cf-nel","max_age":604800}' Server: - cloudflare Set-Cookie: - - _cfuvid=IIL9zypjHdv79e67ehqXdJCgDiAGNvDaEi9dNVQfiDs-1728824609878-0.0.1.1-604800000; path=/; domain=.gitlab.com; HttpOnly; Secure; SameSite=None + - _cfuvid=dAH2KyLqqUpFu7vIO0VUKP38FRv3DBfGMozyC5oYQfA-1734217183321-0.0.1.1-604800000; path=/; domain=.gitlab.com; HttpOnly; Secure; SameSite=None Strict-Transport-Security: - max-age=31536000 Vary: - - Origin + - Origin, Accept-Encoding X-Content-Type-Options: - nosniff X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"f5213fdce404a3c89baeb6659f65e6fc","version":"1"}' + - '{"correlation_id":"3213604c84fe5429a9a2d7a0a41fae56","version":"1"}' X-Request-Id: - - f5213fdce404a3c89baeb6659f65e6fc + - 3213604c84fe5429a9a2d7a0a41fae56 X-Runtime: - - "0.059880" + - "0.060866" status: 200 OK code: 200 - duration: 289.986208ms - - id: 4 + duration: 275.355417ms + - id: 5 request: proto: HTTP/1.1 proto_major: 1 @@ -348,7 +425,7 @@ interactions: Cf-Cache-Status: - MISS Cf-Ray: - - 8d1f87b64ee6b75b-AMS + - 8f21ce55a81b0a55-AMS Content-Length: - "106" Content-Security-Policy: @@ -356,21 +433,21 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 13:03:30 GMT + - Sat, 14 Dec 2024 22:59:43 GMT Gitlab-Lb: - - haproxy-main-03-lb-gprd + - haproxy-main-35-lb-gprd Gitlab-Sv: - - gke-cny-api + - api-gke-us-east1-d Nel: - '{"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}' Referrer-Policy: - strict-origin-when-cross-origin Report-To: - - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=JT3vmyAsDVstLjbrsgNiYdlWysAcJ2AKqeSueC14lCbwxGn9dameSAX3qfpXLPJZACESDxdejyTvdRJKbQ6FnxXzBxmaO0xmndTHxew%2FfD6Hsr%2Fd3Jrz3imBcPo%3D"}],"group":"cf-nel","max_age":604800}' + - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=46pHZVBGLFWUX7pbFHrYfBG5dzMNkrU2%2F8QtrsiYHVbstQ8Pgr5JFJ2mONFfA9nywjnaRi7kUmMl2%2BKon6MqQsRu32vQbmO2eMQGjG7sdl8krq%2F7%2F60%2BOGKGwEA%3D"}],"group":"cf-nel","max_age":604800}' Server: - cloudflare Set-Cookie: - - _cfuvid=8nyNdxOgaNoXfNX7JiloLSAZtjfDjJx.WNG_49MjtWQ-1728824610450-0.0.1.1-604800000; path=/; domain=.gitlab.com; HttpOnly; Secure; SameSite=None + - _cfuvid=_BlvvpmMsvDJHZzKxZXTnJgISp_16iCMR0cOUIGLL8g-1734217183796-0.0.1.1-604800000; path=/; domain=.gitlab.com; HttpOnly; Secure; SameSite=None Strict-Transport-Security: - max-age=31536000 Vary: @@ -380,15 +457,15 @@ interactions: X-Content-Type-Options: - nosniff X-Gitlab-Meta: - - '{"correlation_id":"c0a1de67f91eba8469438702599c7e3e","version":"1"}' + - '{"correlation_id":"a142605ce05047f24e7b339d8046a371","version":"1"}' X-Request-Id: - - c0a1de67f91eba8469438702599c7e3e + - a142605ce05047f24e7b339d8046a371 X-Runtime: - - "0.025753" + - "0.026048" status: 401 Unauthorized code: 401 - duration: 182.314291ms - - id: 5 + duration: 193.103625ms + - id: 6 request: proto: HTTP/1.1 proto_major: 1 @@ -418,36 +495,36 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":10934133,"name":"vault-plugin-test-token","revoked":false,"created_at":"2024-10-13T13:03:29.810Z","scopes":["api","read_api","read_user"],"user_id":32923,"last_used_at":"2024-10-13T13:03:30.730Z","active":true,"expires_at":"2025-08-12"}' + body: '{"id":12599488,"name":"test-vault-plugin","revoked":false,"created_at":"2024-12-14T22:59:43.256Z","description":null,"scopes":["api","read_api","read_user","create_runner","manage_runner","k8s_proxy","read_repository","write_repository","read_registry","write_registry","ai_features"],"user_id":32923,"last_used_at":"2024-12-14T22:59:44.097Z","active":true,"expires_at":"2025-01-11"}' headers: Cache-Control: - max-age=0, private, must-revalidate Cf-Cache-Status: - MISS Cf-Ray: - - 8d1f87b88968b75b-AMS + - 8f21ce5809450a55-AMS Content-Security-Policy: - default-src 'none' Content-Type: - application/json Date: - - Sun, 13 Oct 2024 13:03:30 GMT + - Sat, 14 Dec 2024 22:59:44 GMT Etag: - - W/"f1cc242435df9abc7a638aa79617ce2c" + - W/"95c32620f7d0655b50dc6712981427b5" Gitlab-Lb: - - haproxy-main-54-lb-gprd + - haproxy-main-44-lb-gprd Gitlab-Sv: - - api-gke-us-east1-b + - api-gke-us-east1-d Nel: - '{"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}' Referrer-Policy: - strict-origin-when-cross-origin Report-To: - - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=%2B5tVE1qoeelpgXD%2FMwcdGr6Gnn6G6HeE0VrKTHRmqmSdmwHAAqELFZ9JxcEGbFW3PnIXQbQvxnxMZSCp13pp7C0DERyizVBvqSAGZyMCVXmCDBRnZ1I1erE85nI%3D"}],"group":"cf-nel","max_age":604800}' + - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=oPzijydgndnljddvaw%2BsZcxxxthxxBl0QO0ZF4pUM9BjHmgczB81DSz4G6Qm7mBB6hkHVBGWws1BAhago4Csx0FoI1ZSCEcbXo2tZFzdxvzoX%2BFdFBizREurRS4%3D"}],"group":"cf-nel","max_age":604800}' Server: - cloudflare Set-Cookie: - - _cfuvid=EQ.WTAKxXELG8XOv6FkApktrWeAWtCQqws5O4a01nmA-1728824610853-0.0.1.1-604800000; path=/; domain=.gitlab.com; HttpOnly; Secure; SameSite=None + - _cfuvid=HFSZxrz_7XyOSww6FO9rD_.sPdb2qhiz8VQ8M4ibVFo-1734217184227-0.0.1.1-604800000; path=/; domain=.gitlab.com; HttpOnly; Secure; SameSite=None Strict-Transport-Security: - max-age=31536000 Vary: @@ -457,11 +534,11 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"3ec87510acb5422dfd941746205bfcc6","version":"1"}' + - '{"correlation_id":"48f77d8435ff9e1b575fce30abf787cf","version":"1"}' X-Request-Id: - - 3ec87510acb5422dfd941746205bfcc6 + - 48f77d8435ff9e1b575fce30abf787cf X-Runtime: - - "0.071831" + - "0.075721" status: 200 OK code: 200 - duration: 263.659416ms + duration: 261.848791ms diff --git a/testdata/fixtures/16.11.6/TestWithServiceAccountGroup.yaml b/testdata/selfhosted/TestWithServiceAccountGroup.yaml similarity index 65% rename from testdata/fixtures/16.11.6/TestWithServiceAccountGroup.yaml rename to testdata/selfhosted/TestWithServiceAccountGroup.yaml index 5e47680..3722c8e 100644 --- a/testdata/fixtures/16.11.6/TestWithServiceAccountGroup.yaml +++ b/testdata/selfhosted/TestWithServiceAccountGroup.yaml @@ -29,20 +29,20 @@ interactions: proto_minor: 0 transfer_encoding: [] trailer: {} - content_length: 252 + content_length: 400 uncompressed: false - body: '{"id":78,"name":"vault-plugin-test-token","revoked":false,"created_at":"2024-10-13T12:45:46.815Z","scopes":["api","read_api","read_user","sudo","admin_mode"],"user_id":2,"last_used_at":"2024-10-13T12:49:05.355Z","active":true,"expires_at":"2024-11-12"}' + body: '{"id":81,"name":"vault-plugin-test-token","revoked":false,"created_at":"2024-12-11T23:34:49.635Z","scopes":["api","read_api","read_user","create_runner","manage_runner","k8s_proxy","read_repository","write_repository","read_registry","write_registry","ai_features","sudo","admin_mode","read_service_ping"],"user_id":2,"last_used_at":"2024-12-14T23:00:53.224Z","active":true,"expires_at":"2025-12-11"}' headers: Cache-Control: - max-age=0, private, must-revalidate Content-Length: - - "252" + - "400" Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:49:05 GMT + - Sat, 14 Dec 2024 23:00:55 GMT Etag: - - W/"b3d26443df799a3330591d7c04051b4c" + - W/"cfea8e3149af01041fbffaa578be74c9" Server: - nginx Vary: @@ -52,15 +52,74 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YSPR443ZE9RNGDW6YSH01","version":"1"}' + - '{"correlation_id":"01JF3PEJMSVMM35XC59AZKAD81","version":"1"}' X-Request-Id: - - 01JA2YSPR443ZE9RNGDW6YSH01 + - 01JF3PEJMSVMM35XC59AZKAD81 X-Runtime: - - "0.086320" + - "0.015660" status: 200 OK code: 200 - duration: 442.064792ms + duration: 53.917209ms - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: git.matoski.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: https://git.matoski.com/api/v4/metadata + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 167 + uncompressed: false + body: '{"version":"17.5.3-ee","revision":"9d81c27eee7","kas":{"enabled":true,"externalUrl":"wss://git.matoski.com//-/kubernetes-agent/","version":"17.5.3"},"enterprise":true}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Content-Length: + - "167" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 23:00:55 GMT + Etag: + - W/"782d9777eaee8b4f8892bc19aa3f8239" + Server: + - nginx + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3PEJR69C461GYC21M98Z7F","version":"1"}' + X-Request-Id: + - 01JF3PEJR69C461GYC21M98Z7F + X-Runtime: + - "0.061085" + status: 200 OK + code: 200 + duration: 80.156ms + - id: 2 request: proto: HTTP/1.1 proto_major: 1 @@ -92,7 +151,7 @@ interactions: trailer: {} content_length: 112 uncompressed: false - body: '{"id":132,"username":"service_account_group_265_62c6a7f98441380f65190ce34b95c600","name":"Service account user"}' + body: '{"id":139,"username":"service_account_group_265_987ee3390146f44aec3a4e89e74a13d0","name":"Service account user"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -101,9 +160,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:49:06 GMT + - Sat, 14 Dec 2024 23:00:55 GMT Etag: - - W/"918e123d2db0d9ca359f403713662770" + - W/"99e6b23ebe6d139d92f794e2f7aeed01" Server: - nginx Vary: @@ -113,15 +172,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YSQ9HTFW61RZZPTD5DQ8W","version":"1"}' + - '{"correlation_id":"01JF3PEJXAB0NWFABFZPB3PZ00","version":"1"}' X-Request-Id: - - 01JA2YSQ9HTFW61RZZPTD5DQ8W + - 01JF3PEJXAB0NWFABFZPB3PZ00 X-Runtime: - - "0.706449" + - "0.143362" status: 201 Created code: 201 - duration: 732.564042ms - - id: 2 + duration: 164.375792ms + - id: 3 request: proto: HTTP/1.1 proto_major: 1 @@ -141,7 +200,7 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: https://git.matoski.com/api/v4/users?username=service_account_group_265_62c6a7f98441380f65190ce34b95c600 + url: https://git.matoski.com/api/v4/users?username=service_account_group_265_987ee3390146f44aec3a4e89e74a13d0 method: GET response: proto: HTTP/2.0 @@ -151,7 +210,7 @@ interactions: trailer: {} content_length: 1771 uncompressed: false - body: '[{"id":132,"username":"service_account_group_265_62c6a7f98441380f65190ce34b95c600","name":"Service account user","state":"active","locked":false,"avatar_url":"https://secure.gravatar.com/avatar/d36c56cd3bcea98ef6cd13946f5479399bddff8c102a09865da32ce601baa4f6?s=80\u0026d=identicon","web_url":"https://git.matoski.com/service_account_group_265_62c6a7f98441380f65190ce34b95c600","created_at":"2024-10-13T12:49:06.085Z","bio":"","location":"","public_email":null,"skype":"","linkedin":"","twitter":"","discord":"","website_url":"","organization":"","job_title":"","pronouns":null,"bot":true,"work_information":null,"followers":0,"following":0,"is_followed":false,"local_time":null,"last_sign_in_at":null,"confirmed_at":"2024-10-13T12:49:05.995Z","last_activity_on":null,"email":"service_account_group_265_62c6a7f98441380f65190ce34b95c600@noreply.git.matoski.com","theme_id":3,"color_scheme_id":1,"projects_limit":0,"current_sign_in_at":null,"identities":[],"can_create_group":false,"can_create_project":false,"two_factor_enabled":false,"external":true,"private_profile":false,"commit_email":"service_account_group_265_62c6a7f98441380f65190ce34b95c600@noreply.git.matoski.com","shared_runners_minutes_limit":null,"extra_shared_runners_minutes_limit":null,"scim_identities":[],"is_admin":false,"note":null,"namespace_id":371,"created_by":{"id":2,"username":"ilijamt","name":"Ilija Matoski","state":"active","locked":false,"avatar_url":"https://secure.gravatar.com/avatar/e1bd6bdeae5b3bcd803934a067f39933dd21f9da7974c8e3623ee21ece5fea61?s=80\u0026d=identicon","web_url":"https://git.matoski.com/ilijamt"},"email_reset_offered_at":null,"using_license_seat":false,"is_auditor":false,"provisioned_by_group_id":265,"enterprise_group_id":null,"enterprise_group_associated_at":null}]' + body: '[{"id":139,"username":"service_account_group_265_987ee3390146f44aec3a4e89e74a13d0","name":"Service account user","state":"active","locked":false,"avatar_url":"https://secure.gravatar.com/avatar/8378ce6ff6f9c69f45faa54e25b08cc497e348b9b92f9f8985d31444f57699f5?s=80\u0026d=identicon","web_url":"https://git.matoski.com/service_account_group_265_987ee3390146f44aec3a4e89e74a13d0","created_at":"2024-12-14T23:00:55.915Z","bio":"","location":"","public_email":null,"skype":"","linkedin":"","twitter":"","discord":"","website_url":"","organization":"","job_title":"","pronouns":null,"bot":true,"work_information":null,"followers":0,"following":0,"is_followed":false,"local_time":null,"last_sign_in_at":null,"confirmed_at":"2024-12-14T23:00:55.903Z","last_activity_on":null,"email":"service_account_group_265_987ee3390146f44aec3a4e89e74a13d0@noreply.git.matoski.com","theme_id":3,"color_scheme_id":1,"projects_limit":0,"current_sign_in_at":null,"identities":[],"can_create_group":false,"can_create_project":false,"two_factor_enabled":false,"external":true,"private_profile":false,"commit_email":"service_account_group_265_987ee3390146f44aec3a4e89e74a13d0@noreply.git.matoski.com","shared_runners_minutes_limit":null,"extra_shared_runners_minutes_limit":null,"scim_identities":[],"is_admin":false,"note":null,"namespace_id":378,"created_by":{"id":2,"username":"ilijamt","name":"Ilija Matoski","state":"active","locked":false,"avatar_url":"https://secure.gravatar.com/avatar/e1bd6bdeae5b3bcd803934a067f39933dd21f9da7974c8e3623ee21ece5fea61?s=80\u0026d=identicon","web_url":"https://git.matoski.com/ilijamt"},"email_reset_offered_at":null,"using_license_seat":false,"is_auditor":false,"provisioned_by_group_id":265,"enterprise_group_id":null,"enterprise_group_associated_at":null}]' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -160,11 +219,11 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:49:07 GMT + - Sat, 14 Dec 2024 23:00:56 GMT Etag: - - W/"c3d3a924595c6d1222a518bfd72a9fa9" + - W/"83c7c7be68288d2a1e5e2449ce13654a" Link: - - ; rel="first", ; rel="last" + - ; rel="first", ; rel="last" Server: - nginx Vary: @@ -174,7 +233,7 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YSRQFCNJHRSM5P9KX0RHY","version":"1"}' + - '{"correlation_id":"01JF3PEK7S5XNM8B0WQFZ0VRJY","version":"1"}' X-Next-Page: - "" X-Page: @@ -184,17 +243,17 @@ interactions: X-Prev-Page: - "" X-Request-Id: - - 01JA2YSRQFCNJHRSM5P9KX0RHY + - 01JF3PEK7S5XNM8B0WQFZ0VRJY X-Runtime: - - "0.136749" + - "0.128966" X-Total: - "1" X-Total-Pages: - "1" status: 200 OK code: 200 - duration: 163.203041ms - - id: 3 + duration: 149.256292ms + - id: 4 request: proto: HTTP/1.1 proto_major: 1 @@ -205,7 +264,7 @@ interactions: host: git.matoski.com remote_addr: "" request_uri: "" - body: '{"scopes":["read_service_ping","read_user","sudo","admin_mode"],"name":"vault-generated-group-service-account-token","expires_at":"2024-12-14"}' + body: '{"scopes":["read_service_ping","read_user","sudo","admin_mode"],"name":"vault-generated-group-service-account-token","expires_at":"2025-03-14"}' form: {} headers: Accept: @@ -216,7 +275,7 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: https://git.matoski.com/api/v4/groups/265/service_accounts/132/personal_access_tokens + url: https://git.matoski.com/api/v4/groups/265/service_accounts/139/personal_access_tokens method: POST response: proto: HTTP/2.0 @@ -226,7 +285,7 @@ interactions: trailer: {} content_length: 292 uncompressed: false - body: '{"id":79,"name":"vault-generated-group-service-account-token","revoked":false,"created_at":"2024-10-13T12:49:07.716Z","scopes":["read_service_ping","read_user","sudo","admin_mode"],"user_id":132,"last_used_at":null,"active":true,"expires_at":"2024-12-14","token":"glpat--zyAc2LTaSHDAitzEAqZ"}' + body: '{"id":83,"name":"vault-generated-group-service-account-token","revoked":false,"created_at":"2024-12-14T23:00:56.530Z","scopes":["read_service_ping","read_user","sudo","admin_mode"],"user_id":139,"last_used_at":null,"active":true,"expires_at":"2025-03-14","token":"glpat-2cFWZUSZB61ue4zEwLG6"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -235,9 +294,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:49:07 GMT + - Sat, 14 Dec 2024 23:00:56 GMT Etag: - - W/"66ef3f65f8db60d4ac1546f55a7d5ffd" + - W/"4c14811490a44d4362bf225bc46ef094" Server: - nginx Vary: @@ -247,15 +306,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YSS1MD957XNH8BWAZFNCQ","version":"1"}' + - '{"correlation_id":"01JF3PEKH9T7XT2E3P7FC8RFNH","version":"1"}' X-Request-Id: - - 01JA2YSS1MD957XNH8BWAZFNCQ + - 01JF3PEKH9T7XT2E3P7FC8RFNH X-Runtime: - - "0.195890" + - "0.066166" status: 201 Created code: 201 - duration: 219.028542ms - - id: 4 + duration: 87.139ms + - id: 5 request: proto: HTTP/1.1 proto_major: 1 @@ -285,7 +344,7 @@ interactions: trailer: {} content_length: 277 uncompressed: false - body: '{"id":79,"name":"vault-generated-group-service-account-token","revoked":false,"created_at":"2024-10-13T12:49:07.716Z","scopes":["read_service_ping","read_user","sudo","admin_mode"],"user_id":132,"last_used_at":"2024-10-13T12:49:08.140Z","active":true,"expires_at":"2024-12-14"}' + body: '{"id":83,"name":"vault-generated-group-service-account-token","revoked":false,"created_at":"2024-12-14T23:00:56.530Z","scopes":["read_service_ping","read_user","sudo","admin_mode"],"user_id":139,"last_used_at":"2024-12-14T23:00:56.734Z","active":true,"expires_at":"2025-03-14"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -294,9 +353,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:49:08 GMT + - Sat, 14 Dec 2024 23:00:56 GMT Etag: - - W/"27b7ec77f60d15142da895987b209391" + - W/"26dd0878088f7ac11a9630f9a32e5e9f" Server: - nginx Vary: @@ -306,15 +365,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YSSFF8FDVY76CBFEF4T1N","version":"1"}' + - '{"correlation_id":"01JF3PEKPTV4P2GX77EMA54YEF","version":"1"}' X-Request-Id: - - 01JA2YSSFF8FDVY76CBFEF4T1N + - 01JF3PEKPTV4P2GX77EMA54YEF X-Runtime: - - "0.386524" + - "0.102092" status: 200 OK code: 200 - duration: 416.044334ms - - id: 5 + duration: 122.434542ms + - id: 6 request: proto: HTTP/1.1 proto_major: 1 @@ -349,7 +408,7 @@ interactions: Cache-Control: - no-cache Date: - - Sun, 13 Oct 2024 12:49:09 GMT + - Sat, 14 Dec 2024 23:00:56 GMT Server: - nginx Vary: @@ -359,15 +418,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YST9H6YJ7V9F4MP1A8DFB","version":"1"}' + - '{"correlation_id":"01JF3PEKYJM1CAYSG34YNHZG9Q","version":"1"}' X-Request-Id: - - 01JA2YST9H6YJ7V9F4MP1A8DFB + - 01JF3PEKYJM1CAYSG34YNHZG9Q X-Runtime: - - "0.085022" + - "0.043060" status: 204 No Content code: 204 - duration: 110.858709ms - - id: 6 + duration: 63.165167ms + - id: 7 request: proto: HTTP/1.1 proto_major: 1 @@ -387,7 +446,7 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: https://git.matoski.com/api/v4/users/132 + url: https://git.matoski.com/api/v4/users/139 method: DELETE response: proto: HTTP/2.0 @@ -402,7 +461,7 @@ interactions: Cache-Control: - no-cache Date: - - Sun, 13 Oct 2024 12:49:09 GMT + - Sat, 14 Dec 2024 23:00:57 GMT Server: - nginx Vary: @@ -412,11 +471,11 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YSTGD376194FSK6W3XGQ6","version":"1"}' + - '{"correlation_id":"01JF3PEM2JK96NEJDCFWWBVSS1","version":"1"}' X-Request-Id: - - 01JA2YSTGD376194FSK6W3XGQ6 + - 01JF3PEM2JK96NEJDCFWWBVSS1 X-Runtime: - - "0.056386" + - "0.034868" status: 204 No Content code: 204 - duration: 78.903333ms + duration: 53.857667ms diff --git a/testdata/fixtures/16.11.6/TestWithServiceAccountUser.yaml b/testdata/selfhosted/TestWithServiceAccountUser.yaml similarity index 65% rename from testdata/fixtures/16.11.6/TestWithServiceAccountUser.yaml rename to testdata/selfhosted/TestWithServiceAccountUser.yaml index fbd6e5f..1f135d1 100644 --- a/testdata/fixtures/16.11.6/TestWithServiceAccountUser.yaml +++ b/testdata/selfhosted/TestWithServiceAccountUser.yaml @@ -29,20 +29,20 @@ interactions: proto_minor: 0 transfer_encoding: [] trailer: {} - content_length: 252 + content_length: 400 uncompressed: false - body: '{"id":78,"name":"vault-plugin-test-token","revoked":false,"created_at":"2024-10-13T12:45:46.815Z","scopes":["api","read_api","read_user","sudo","admin_mode"],"user_id":2,"last_used_at":"2024-10-13T12:49:05.355Z","active":true,"expires_at":"2024-11-12"}' + body: '{"id":81,"name":"vault-plugin-test-token","revoked":false,"created_at":"2024-12-11T23:34:49.635Z","scopes":["api","read_api","read_user","create_runner","manage_runner","k8s_proxy","read_repository","write_repository","read_registry","write_registry","ai_features","sudo","admin_mode","read_service_ping"],"user_id":2,"last_used_at":"2024-12-14T23:00:53.224Z","active":true,"expires_at":"2025-12-11"}' headers: Cache-Control: - max-age=0, private, must-revalidate Content-Length: - - "252" + - "400" Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:49:10 GMT + - Sat, 14 Dec 2024 23:00:57 GMT Etag: - - W/"b3d26443df799a3330591d7c04051b4c" + - W/"cfea8e3149af01041fbffaa578be74c9" Server: - nginx Vary: @@ -52,14 +52,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YSW3K3TR04YV990C5F5PA","version":"1"}' + - '{"correlation_id":"01JF3PEM6TXW26XGCAWDHRE74F","version":"1"}' X-Request-Id: - - 01JA2YSW3K3TR04YV990C5F5PA + - 01JF3PEM6TXW26XGCAWDHRE74F X-Runtime: - - "0.028981" + - "0.016751" status: 200 OK code: 200 - duration: 158.647125ms + duration: 37.910708ms - id: 1 request: proto: HTTP/1.1 @@ -73,6 +73,65 @@ interactions: request_uri: "" body: "" form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: https://git.matoski.com/api/v4/metadata + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 167 + uncompressed: false + body: '{"version":"17.5.3-ee","revision":"9d81c27eee7","kas":{"enabled":true,"externalUrl":"wss://git.matoski.com//-/kubernetes-agent/","version":"17.5.3"},"enterprise":true}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Content-Length: + - "167" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 23:00:57 GMT + Etag: + - W/"782d9777eaee8b4f8892bc19aa3f8239" + Server: + - nginx + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3PEM96YFKDFFAST7P0R8M0","version":"1"}' + X-Request-Id: + - 01JF3PEM96YFKDFFAST7P0R8M0 + X-Runtime: + - "0.017948" + status: 200 OK + code: 200 + duration: 37.877708ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 2 + transfer_encoding: [] + trailer: {} + host: git.matoski.com + remote_addr: "" + request_uri: "" + body: '{}' + form: {} headers: Accept: - application/json @@ -92,7 +151,7 @@ interactions: trailer: {} content_length: 102 uncompressed: false - body: '{"id":133,"username":"service_account_4623be513481a023ef6ba6f465745ccb","name":"Service account user"}' + body: '{"id":140,"username":"service_account_a34b68be2852c344e401b14f16bb71b8","name":"Service account user"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -101,9 +160,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:49:11 GMT + - Sat, 14 Dec 2024 23:00:57 GMT Etag: - - W/"28d749082cac9fdb60adaa1091dec5cc" + - W/"ce164b98775efebb7f8c646865554f1e" Server: - nginx Vary: @@ -113,15 +172,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YSWA9E5X76PP7J72MSCN8","version":"1"}' + - '{"correlation_id":"01JF3PEMBP18GZ5H4V384NSCFW","version":"1"}' X-Request-Id: - - 01JA2YSWA9E5X76PP7J72MSCN8 + - 01JF3PEMBP18GZ5H4V384NSCFW X-Runtime: - - "0.312263" + - "0.324141" status: 201 Created code: 201 - duration: 375.661625ms - - id: 2 + duration: 357.518875ms + - id: 3 request: proto: HTTP/1.1 proto_major: 1 @@ -141,7 +200,7 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: https://git.matoski.com/api/v4/users?username=service_account_4623be513481a023ef6ba6f465745ccb + url: https://git.matoski.com/api/v4/users?username=service_account_a34b68be2852c344e401b14f16bb71b8 method: GET response: proto: HTTP/2.0 @@ -151,7 +210,7 @@ interactions: trailer: {} content_length: 1732 uncompressed: false - body: '[{"id":133,"username":"service_account_4623be513481a023ef6ba6f465745ccb","name":"Service account user","state":"active","locked":false,"avatar_url":"https://secure.gravatar.com/avatar/fe18a522b9c0e2c46e1647af3ca1796ee86ff7cd0329731a255366be973976ca?s=80\u0026d=identicon","web_url":"https://git.matoski.com/service_account_4623be513481a023ef6ba6f465745ccb","created_at":"2024-10-13T12:49:11.106Z","bio":"","location":"","public_email":null,"skype":"","linkedin":"","twitter":"","discord":"","website_url":"","organization":"","job_title":"","pronouns":null,"bot":true,"work_information":null,"followers":0,"following":0,"is_followed":false,"local_time":null,"last_sign_in_at":null,"confirmed_at":"2024-10-13T12:49:11.019Z","last_activity_on":null,"email":"service_account_4623be513481a023ef6ba6f465745ccb@noreply.git.matoski.com","theme_id":3,"color_scheme_id":1,"projects_limit":0,"current_sign_in_at":null,"identities":[],"can_create_group":false,"can_create_project":false,"two_factor_enabled":false,"external":true,"private_profile":false,"commit_email":"service_account_4623be513481a023ef6ba6f465745ccb@noreply.git.matoski.com","shared_runners_minutes_limit":null,"extra_shared_runners_minutes_limit":null,"scim_identities":[],"is_admin":false,"note":null,"namespace_id":372,"created_by":{"id":2,"username":"ilijamt","name":"Ilija Matoski","state":"active","locked":false,"avatar_url":"https://secure.gravatar.com/avatar/e1bd6bdeae5b3bcd803934a067f39933dd21f9da7974c8e3623ee21ece5fea61?s=80\u0026d=identicon","web_url":"https://git.matoski.com/ilijamt"},"email_reset_offered_at":null,"using_license_seat":false,"is_auditor":false,"provisioned_by_group_id":null,"enterprise_group_id":null,"enterprise_group_associated_at":null}]' + body: '[{"id":140,"username":"service_account_a34b68be2852c344e401b14f16bb71b8","name":"Service account user","state":"active","locked":false,"avatar_url":"https://secure.gravatar.com/avatar/ce4e9e96cf01151022dff6ad9f0c7bf75c8163d25a14beec5b93ee9162c9d14e?s=80\u0026d=identicon","web_url":"https://git.matoski.com/service_account_a34b68be2852c344e401b14f16bb71b8","created_at":"2024-12-14T23:00:57.413Z","bio":"","location":"","public_email":null,"skype":"","linkedin":"","twitter":"","discord":"","website_url":"","organization":"","job_title":"","pronouns":null,"bot":true,"work_information":null,"followers":0,"following":0,"is_followed":false,"local_time":null,"last_sign_in_at":null,"confirmed_at":"2024-12-14T23:00:57.369Z","last_activity_on":null,"email":"service_account_a34b68be2852c344e401b14f16bb71b8@noreply.git.matoski.com","theme_id":3,"color_scheme_id":1,"projects_limit":0,"current_sign_in_at":null,"identities":[],"can_create_group":false,"can_create_project":false,"two_factor_enabled":false,"external":true,"private_profile":false,"commit_email":"service_account_a34b68be2852c344e401b14f16bb71b8@noreply.git.matoski.com","shared_runners_minutes_limit":null,"extra_shared_runners_minutes_limit":null,"scim_identities":[],"is_admin":false,"note":null,"namespace_id":379,"created_by":{"id":2,"username":"ilijamt","name":"Ilija Matoski","state":"active","locked":false,"avatar_url":"https://secure.gravatar.com/avatar/e1bd6bdeae5b3bcd803934a067f39933dd21f9da7974c8e3623ee21ece5fea61?s=80\u0026d=identicon","web_url":"https://git.matoski.com/ilijamt"},"email_reset_offered_at":null,"using_license_seat":false,"is_auditor":false,"provisioned_by_group_id":null,"enterprise_group_id":null,"enterprise_group_associated_at":null}]' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -160,11 +219,11 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:49:11 GMT + - Sat, 14 Dec 2024 23:00:58 GMT Etag: - - W/"da11102832b8b74ab77f944c168dfe27" + - W/"a654b25af36baa69931c14cf1af68a63" Link: - - ; rel="first", ; rel="last" + - ; rel="first", ; rel="last" Server: - nginx Vary: @@ -174,7 +233,7 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YSX1YXK2YHK1DGDF9MQAE","version":"1"}' + - '{"correlation_id":"01JF3PEN24CKWPM392FZHSNGN7","version":"1"}' X-Next-Page: - "" X-Page: @@ -184,17 +243,17 @@ interactions: X-Prev-Page: - "" X-Request-Id: - - 01JA2YSX1YXK2YHK1DGDF9MQAE + - 01JF3PEN24CKWPM392FZHSNGN7 X-Runtime: - - "0.047887" + - "0.202440" X-Total: - "1" X-Total-Pages: - "1" status: 200 OK code: 200 - duration: 76.08475ms - - id: 3 + duration: 223.005666ms + - id: 4 request: proto: HTTP/1.1 proto_major: 1 @@ -205,7 +264,7 @@ interactions: host: git.matoski.com remote_addr: "" request_uri: "" - body: '{"name":"vault-generated-user-service-account-token","expires_at":"2024-12-14","scopes":["read_service_ping","read_user","sudo","admin_mode"]}' + body: '{"name":"vault-generated-user-service-account-token","expires_at":"2025-03-14","scopes":["read_service_ping","read_user","sudo","admin_mode"]}' form: {} headers: Accept: @@ -216,7 +275,7 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: https://git.matoski.com/api/v4/users/133/personal_access_tokens + url: https://git.matoski.com/api/v4/users/140/personal_access_tokens method: POST response: proto: HTTP/2.0 @@ -226,7 +285,7 @@ interactions: trailer: {} content_length: 291 uncompressed: false - body: '{"id":80,"name":"vault-generated-user-service-account-token","revoked":false,"created_at":"2024-10-13T12:49:11.932Z","scopes":["read_service_ping","read_user","sudo","admin_mode"],"user_id":133,"last_used_at":null,"active":true,"expires_at":"2024-12-14","token":"glpat--eipYeYixg9xn38exZDJ"}' + body: '{"id":84,"name":"vault-generated-user-service-account-token","revoked":false,"created_at":"2024-12-14T23:00:58.554Z","scopes":["read_service_ping","read_user","sudo","admin_mode"],"user_id":140,"last_used_at":null,"active":true,"expires_at":"2025-03-14","token":"glpat-8z2gC5zqaJxmxkQpaUV_"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -235,9 +294,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:49:11 GMT + - Sat, 14 Dec 2024 23:00:58 GMT Etag: - - W/"83e45713be8cb4b8597e4e5a8f862f46" + - W/"cd162f71ca7a376895fde8e1929d10c4" Server: - nginx Vary: @@ -247,15 +306,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YSX6PESKH4QZ55WFKE0NC","version":"1"}' + - '{"correlation_id":"01JF3PENGBQ0BF1ADTMYRND09J","version":"1"}' X-Request-Id: - - 01JA2YSX6PESKH4QZ55WFKE0NC + - 01JF3PENGBQ0BF1ADTMYRND09J X-Runtime: - - "0.063184" + - "0.092731" status: 201 Created code: 201 - duration: 88.511417ms - - id: 4 + duration: 115.8065ms + - id: 5 request: proto: HTTP/1.1 proto_major: 1 @@ -285,7 +344,7 @@ interactions: trailer: {} content_length: 276 uncompressed: false - body: '{"id":80,"name":"vault-generated-user-service-account-token","revoked":false,"created_at":"2024-10-13T12:49:11.932Z","scopes":["read_service_ping","read_user","sudo","admin_mode"],"user_id":133,"last_used_at":"2024-10-13T12:49:12.086Z","active":true,"expires_at":"2024-12-14"}' + body: '{"id":84,"name":"vault-generated-user-service-account-token","revoked":false,"created_at":"2024-12-14T23:00:58.554Z","scopes":["read_service_ping","read_user","sudo","admin_mode"],"user_id":140,"last_used_at":"2024-12-14T23:00:58.755Z","active":true,"expires_at":"2025-03-14"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -294,9 +353,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:49:12 GMT + - Sat, 14 Dec 2024 23:00:58 GMT Etag: - - W/"1826afe02d216601a5684f39aaa8db19" + - W/"09fc7813739b50ffcdb9ee711c794566" Server: - nginx Vary: @@ -306,15 +365,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YSXCAXCE7CQA0ATWAWQMM","version":"1"}' + - '{"correlation_id":"01JF3PENQK2PG54KAH7TR1YR5Z","version":"1"}' X-Request-Id: - - 01JA2YSXCAXCE7CQA0ATWAWQMM + - 01JF3PENQK2PG54KAH7TR1YR5Z X-Runtime: - - "0.031311" + - "0.033757" status: 200 OK code: 200 - duration: 58.185708ms - - id: 5 + duration: 53.548125ms + - id: 6 request: proto: HTTP/1.1 proto_major: 1 @@ -349,7 +408,7 @@ interactions: Cache-Control: - no-cache Date: - - Sun, 13 Oct 2024 12:49:12 GMT + - Sat, 14 Dec 2024 23:00:58 GMT Server: - nginx Vary: @@ -359,15 +418,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YSXFX5PAYHQSSBJ0K29ME","version":"1"}' + - '{"correlation_id":"01JF3PENV0X2PS8F2R59QKMZ9W","version":"1"}' X-Request-Id: - - 01JA2YSXFX5PAYHQSSBJ0K29ME + - 01JF3PENV0X2PS8F2R59QKMZ9W X-Runtime: - - "0.071212" + - "0.040587" status: 204 No Content code: 204 - duration: 96.199542ms - - id: 6 + duration: 59.759291ms + - id: 7 request: proto: HTTP/1.1 proto_major: 1 @@ -387,7 +446,7 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: https://git.matoski.com/api/v4/users/133 + url: https://git.matoski.com/api/v4/users/140 method: DELETE response: proto: HTTP/2.0 @@ -402,7 +461,7 @@ interactions: Cache-Control: - no-cache Date: - - Sun, 13 Oct 2024 12:49:12 GMT + - Sat, 14 Dec 2024 23:00:58 GMT Server: - nginx Vary: @@ -412,11 +471,11 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YSXP0QDVVYEJCS0SNN4RA","version":"1"}' + - '{"correlation_id":"01JF3PENYV97DYMREV6S2ETCG6","version":"1"}' X-Request-Id: - - 01JA2YSXP0QDVVYEJCS0SNN4RA + - 01JF3PENYV97DYMREV6S2ETCG6 X-Runtime: - - "0.033928" + - "0.023577" status: 204 No Content code: 204 - duration: 57.962791ms + duration: 41.93525ms diff --git a/testdata/selfhosted/TestWithServiceAccountUserFail_dedicated.yaml b/testdata/selfhosted/TestWithServiceAccountUserFail_dedicated.yaml new file mode 100644 index 0000000..306f2a4 --- /dev/null +++ b/testdata/selfhosted/TestWithServiceAccountUserFail_dedicated.yaml @@ -0,0 +1,182 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: git.matoski.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: https://git.matoski.com/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 400 + uncompressed: false + body: '{"id":81,"name":"vault-plugin-test-token","revoked":false,"created_at":"2024-12-11T23:34:49.635Z","scopes":["api","read_api","read_user","create_runner","manage_runner","k8s_proxy","read_repository","write_repository","read_registry","write_registry","ai_features","sudo","admin_mode","read_service_ping"],"user_id":2,"last_used_at":"2024-12-14T23:00:53.224Z","active":true,"expires_at":"2025-12-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Content-Length: + - "400" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 23:00:55 GMT + Etag: + - W/"cfea8e3149af01041fbffaa578be74c9" + Server: + - nginx + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3PEJ1NANQKGPN92HPTNSW6","version":"1"}' + X-Request-Id: + - 01JF3PEJ1NANQKGPN92HPTNSW6 + X-Runtime: + - "0.107825" + status: 200 OK + code: 200 + duration: 129.170875ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: git.matoski.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: https://git.matoski.com/api/v4/metadata + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 167 + uncompressed: false + body: '{"version":"17.5.3-ee","revision":"9d81c27eee7","kas":{"enabled":true,"externalUrl":"wss://git.matoski.com//-/kubernetes-agent/","version":"17.5.3"},"enterprise":true}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Content-Length: + - "167" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 23:00:55 GMT + Etag: + - W/"782d9777eaee8b4f8892bc19aa3f8239" + Server: + - nginx + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3PEJ9R0E6GX3RPVHJ3044H","version":"1"}' + X-Request-Id: + - 01JF3PEJ9R0E6GX3RPVHJ3044H + X-Runtime: + - "0.028934" + status: 200 OK + code: 200 + duration: 49.032ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 2 + transfer_encoding: [] + trailer: {} + host: git.matoski.com + remote_addr: "" + request_uri: "" + body: '{}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: https://git.matoski.com/api/v4/service_accounts + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 102 + uncompressed: false + body: '{"id":138,"username":"service_account_ef4d61ff326df7aad69ba3016b0ccc36","name":"Service account user"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Content-Length: + - "102" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 23:00:55 GMT + Etag: + - W/"3cf253daf0f71ec90e39598924bf4020" + Server: + - nginx + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3PEJCYJ4S2C0YGD82QQX7R","version":"1"}' + X-Request-Id: + - 01JF3PEJCYJ4S2C0YGD82QQX7R + X-Runtime: + - "0.100396" + status: 201 Created + code: 201 + duration: 118.6255ms diff --git a/testdata/selfhosted/TestWithServiceAccountUserFail_saas.yaml b/testdata/selfhosted/TestWithServiceAccountUserFail_saas.yaml new file mode 100644 index 0000000..c504dc5 --- /dev/null +++ b/testdata/selfhosted/TestWithServiceAccountUserFail_saas.yaml @@ -0,0 +1,182 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: git.matoski.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: https://git.matoski.com/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 400 + uncompressed: false + body: '{"id":81,"name":"vault-plugin-test-token","revoked":false,"created_at":"2024-12-11T23:34:49.635Z","scopes":["api","read_api","read_user","create_runner","manage_runner","k8s_proxy","read_repository","write_repository","read_registry","write_registry","ai_features","sudo","admin_mode","read_service_ping"],"user_id":2,"last_used_at":"2024-12-14T23:00:53.224Z","active":true,"expires_at":"2025-12-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Content-Length: + - "400" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 23:00:53 GMT + Etag: + - W/"cfea8e3149af01041fbffaa578be74c9" + Server: + - nginx + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3PEGADVH43D7YFGT7MNPQ1","version":"1"}' + X-Request-Id: + - 01JF3PEGADVH43D7YFGT7MNPQ1 + X-Runtime: + - "0.039197" + status: 200 OK + code: 200 + duration: 198.028667ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: git.matoski.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: https://git.matoski.com/api/v4/metadata + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 167 + uncompressed: false + body: '{"version":"17.5.3-ee","revision":"9d81c27eee7","kas":{"enabled":true,"externalUrl":"wss://git.matoski.com//-/kubernetes-agent/","version":"17.5.3"},"enterprise":true}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Content-Length: + - "167" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 23:00:53 GMT + Etag: + - W/"782d9777eaee8b4f8892bc19aa3f8239" + Server: + - nginx + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3PEGJR0Q9DBYQN0EXB0JFS","version":"1"}' + X-Request-Id: + - 01JF3PEGJR0Q9DBYQN0EXB0JFS + X-Runtime: + - "0.102946" + status: 200 OK + code: 200 + duration: 127.459958ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 2 + transfer_encoding: [] + trailer: {} + host: git.matoski.com + remote_addr: "" + request_uri: "" + body: '{}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: https://git.matoski.com/api/v4/service_accounts + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 102 + uncompressed: false + body: '{"id":137,"username":"service_account_8ce343ad61fa4ae0bb1b98a1a63581b4","name":"Service account user"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Content-Length: + - "102" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 23:00:54 GMT + Etag: + - W/"e014e8962124145febfcb557112a99ee" + Server: + - nginx + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3PEGTT71SMKCVSVNDTPAE2","version":"1"}' + X-Request-Id: + - 01JF3PEGTT71SMKCVSVNDTPAE2 + X-Runtime: + - "0.589800" + status: 201 Created + code: 201 + duration: 610.470209ms diff --git a/testdata/fixtures/16.11.6/TestBackend.yaml b/testdata/unit/TestBackend.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestBackend.yaml rename to testdata/unit/TestBackend.yaml diff --git a/testdata/fixtures/16.11.6/TestGitlabClient_CreateAccessToken_And_Revoke.yaml b/testdata/unit/TestGitlabClient_CreateAccessToken_And_Revoke.yaml similarity index 81% rename from testdata/fixtures/16.11.6/TestGitlabClient_CreateAccessToken_And_Revoke.yaml rename to testdata/unit/TestGitlabClient_CreateAccessToken_And_Revoke.yaml index 056ef0e..f811625 100644 --- a/testdata/fixtures/16.11.6/TestGitlabClient_CreateAccessToken_And_Revoke.yaml +++ b/testdata/unit/TestGitlabClient_CreateAccessToken_And_Revoke.yaml @@ -12,7 +12,7 @@ interactions: host: localhost:8080 remote_addr: "" request_uri: "" - body: '{"name":"name","scopes":["read_api"],"access_level":10,"expires_at":"2024-12-12"}' + body: '{"name":"name","scopes":["read_api"],"access_level":10,"expires_at":"2025-03-12"}' form: {} headers: Accept: @@ -33,7 +33,7 @@ interactions: trailer: {} content_length: 228 uncompressed: false - body: '{"id":43,"name":"name","revoked":false,"created_at":"2024-10-13T12:28:01.037Z","scopes":["read_api"],"user_id":4,"last_used_at":null,"active":true,"expires_at":"2024-12-12","access_level":10,"token":"glpat-Mz4WG_bzFns_o1BoCXZw"}' + body: '{"id":43,"name":"name","revoked":false,"created_at":"2024-12-14T22:52:49.044Z","scopes":["read_api"],"user_id":4,"last_used_at":null,"active":true,"expires_at":"2025-03-12","access_level":10,"token":"glpat-5zuVW1C9tsXy4FiPUjsh"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -44,9 +44,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:28:01 GMT + - Sat, 14 Dec 2024 22:52:49 GMT Etag: - - W/"690d4dfc4d34fda6189e470979599865" + - W/"f0fe365fb1598b65376b0295a8ee8583" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -60,14 +60,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK3VETYS0RV9VJMQZHDV0","version":"1"}' + - '{"correlation_id":"01JF3NZQ9Q7BSPNK8XP9M63TQ0","version":"1"}' X-Request-Id: - - 01JA2XK3VETYS0RV9VJMQZHDV0 + - 01JF3NZQ9Q7BSPNK8XP9M63TQ0 X-Runtime: - - "0.293273" + - "0.227218" status: 201 Created code: 201 - duration: 296.343375ms + duration: 230.275083ms - id: 1 request: proto: HTTP/1.1 @@ -105,7 +105,7 @@ interactions: Connection: - keep-alive Date: - - Sun, 13 Oct 2024 12:28:01 GMT + - Sat, 14 Dec 2024 22:52:49 GMT Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -119,14 +119,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK4E2NSV24WWKHAA0S4HT","version":"1"}' + - '{"correlation_id":"01JF3NZQR91GQGWJBCACQW5JC3","version":"1"}' X-Request-Id: - - 01JA2XK4E2NSV24WWKHAA0S4HT + - 01JF3NZQR91GQGWJBCACQW5JC3 X-Runtime: - - "0.108264" + - "0.144535" status: 204 No Content code: 204 - duration: 115.732833ms + duration: 149.45725ms - id: 2 request: proto: HTTP/1.1 @@ -138,7 +138,7 @@ interactions: host: localhost:8080 remote_addr: "" request_uri: "" - body: '{"name":"name","scopes":["read_api"],"access_level":30,"expires_at":"2024-12-12"}' + body: '{"name":"name","scopes":["read_api"],"access_level":30,"expires_at":"2025-03-12"}' form: {} headers: Accept: @@ -159,7 +159,7 @@ interactions: trailer: {} content_length: 228 uncompressed: false - body: '{"id":44,"name":"name","revoked":false,"created_at":"2024-10-13T12:28:01.893Z","scopes":["read_api"],"user_id":5,"last_used_at":null,"active":true,"expires_at":"2024-12-12","access_level":30,"token":"glpat-wy-XyAGNxoj-Eobgfi-R"}' + body: '{"id":44,"name":"name","revoked":false,"created_at":"2024-12-14T22:52:49.822Z","scopes":["read_api"],"user_id":5,"last_used_at":null,"active":true,"expires_at":"2025-03-12","access_level":30,"token":"glpat-sA6HssMj4vqJ9zNrMkc-"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -170,9 +170,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:28:01 GMT + - Sat, 14 Dec 2024 22:52:49 GMT Etag: - - W/"2994a64698cbfcdd4a8ee798e96a6cfe" + - W/"fc856ba2087839e10323f35ca251a09b" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -186,14 +186,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK4N94C36DY6WVZFAKPVC","version":"1"}' + - '{"correlation_id":"01JF3NZR1N22H59VJWS5HFRV7Z","version":"1"}' X-Request-Id: - - 01JA2XK4N94C36DY6WVZFAKPVC + - 01JF3NZR1N22H59VJWS5HFRV7Z X-Runtime: - - "0.319914" + - "0.237605" status: 201 Created code: 201 - duration: 323.0955ms + duration: 240.706584ms - id: 3 request: proto: HTTP/1.1 @@ -231,7 +231,7 @@ interactions: Connection: - keep-alive Date: - - Sun, 13 Oct 2024 12:28:02 GMT + - Sat, 14 Dec 2024 22:52:50 GMT Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -245,14 +245,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK59KT0Y5HWZD3Y7TJDV1","version":"1"}' + - '{"correlation_id":"01JF3NZRGWG4XM1YRZAF4GFMAN","version":"1"}' X-Request-Id: - - 01JA2XK59KT0Y5HWZD3Y7TJDV1 + - 01JF3NZRGWG4XM1YRZAF4GFMAN X-Runtime: - - "0.177029" + - "0.090176" status: 204 No Content code: 204 - duration: 184.856333ms + duration: 98.538709ms - id: 4 request: proto: HTTP/1.1 @@ -264,7 +264,7 @@ interactions: host: localhost:8080 remote_addr: "" request_uri: "" - body: '{"name":"name","expires_at":"2024-12-12","scopes":["read_api"]}' + body: '{"name":"name","expires_at":"2025-03-12","scopes":["read_api"]}' form: {} headers: Accept: @@ -285,7 +285,7 @@ interactions: trailer: {} content_length: 210 uncompressed: false - body: '{"id":45,"name":"name","revoked":false,"created_at":"2024-10-13T12:28:02.620Z","scopes":["read_api"],"user_id":1,"last_used_at":null,"active":true,"expires_at":"2024-12-12","token":"glpat-4PzriwzNC39CJbq5zveb"}' + body: '{"id":45,"name":"name","revoked":false,"created_at":"2024-12-14T22:52:50.298Z","scopes":["read_api"],"user_id":1,"last_used_at":null,"active":true,"expires_at":"2025-03-12","token":"glpat--H5uQse1yGo2Qo-Bvx6_"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -296,9 +296,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:28:02 GMT + - Sat, 14 Dec 2024 22:52:50 GMT Etag: - - W/"251d45dbbe0af0528d20de74556b0e45" + - W/"d4d57e036e22ffd1d296750cf5eed244" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -312,14 +312,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK5N5WANNE87N6JJ8XNE3","version":"1"}' + - '{"correlation_id":"01JF3NZRQ1K0AC1H7NNX5TP40E","version":"1"}' X-Request-Id: - - 01JA2XK5N5WANNE87N6JJ8XNE3 + - 01JF3NZRQ1K0AC1H7NNX5TP40E X-Runtime: - - "0.065718" + - "0.043138" status: 201 Created code: 201 - duration: 69.537875ms + duration: 46.171166ms - id: 5 request: proto: HTTP/1.1 @@ -357,7 +357,7 @@ interactions: Connection: - keep-alive Date: - - Sun, 13 Oct 2024 12:28:02 GMT + - Sat, 14 Dec 2024 22:52:50 GMT Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -371,11 +371,11 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK5SHK45Y1FNNYEHQV4K7","version":"1"}' + - '{"correlation_id":"01JF3NZRT0SPMCKHA3HDQYRZFT","version":"1"}' X-Request-Id: - - 01JA2XK5SHK45Y1FNNYEHQV4K7 + - 01JF3NZRT0SPMCKHA3HDQYRZFT X-Runtime: - - "0.061870" + - "0.074364" status: 204 No Content code: 204 - duration: 64.560209ms + duration: 77.667042ms diff --git a/testdata/fixtures/16.11.6/TestGitlabClient_CurrentTokenInfo.yaml b/testdata/unit/TestGitlabClient_CurrentTokenInfo.yaml similarity index 84% rename from testdata/fixtures/16.11.6/TestGitlabClient_CurrentTokenInfo.yaml rename to testdata/unit/TestGitlabClient_CurrentTokenInfo.yaml index 0ff2d3d..b184484 100644 --- a/testdata/fixtures/16.11.6/TestGitlabClient_CurrentTokenInfo.yaml +++ b/testdata/unit/TestGitlabClient_CurrentTokenInfo.yaml @@ -32,7 +32,7 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-13T12:27:58.084Z","active":true,"expires_at":"2025-07-11"}' + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -41,9 +41,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:28:00 GMT + - Sat, 14 Dec 2024 22:52:48 GMT Etag: - - W/"90e86831fcf88b60879463ac4225157a" + - W/"d0f486f8d8a3d398674f9cd0e555862f" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -58,11 +58,11 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK3T3EX89BJ1CRG1163SR","version":"1"}' + - '{"correlation_id":"01JF3NZQ8N19MW3C5J1QHQK2VK","version":"1"}' X-Request-Id: - - 01JA2XK3T3EX89BJ1CRG1163SR + - 01JF3NZQ8N19MW3C5J1QHQK2VK X-Runtime: - - "0.016680" + - "0.010274" status: 200 OK code: 200 - duration: 19.699875ms + duration: 12.714625ms diff --git a/testdata/fixtures/16.11.6/TestGitlabClient_GetGroupIdByPath.yaml b/testdata/unit/TestGitlabClient_GetGroupIdByPath.yaml similarity index 86% rename from testdata/fixtures/16.11.6/TestGitlabClient_GetGroupIdByPath.yaml rename to testdata/unit/TestGitlabClient_GetGroupIdByPath.yaml index 98e609a..525a906 100644 --- a/testdata/fixtures/16.11.6/TestGitlabClient_GetGroupIdByPath.yaml +++ b/testdata/unit/TestGitlabClient_GetGroupIdByPath.yaml @@ -32,7 +32,7 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '[{"id":37,"web_url":"http://1b25ef517b98/groups/test","name":"test","path":"test","description":"","visibility":"private","share_with_group_lock":false,"require_two_factor_authentication":false,"two_factor_grace_period":48,"project_creation_level":"developer","auto_devops_enabled":null,"subgroup_creation_level":"maintainer","emails_disabled":false,"emails_enabled":true,"mentions_disabled":null,"lfs_enabled":true,"math_rendering_limits_enabled":true,"lock_math_rendering_limits_enabled":false,"default_branch":null,"default_branch_protection":2,"default_branch_protection_defaults":{"allowed_to_push":[{"access_level":40}],"allow_force_push":false,"allowed_to_merge":[{"access_level":40}]},"avatar_url":null,"request_access_enabled":true,"full_name":"test","full_path":"test","created_at":"2024-10-11T07:48:18.836Z","parent_id":null,"organization_id":1,"shared_runners_setting":"enabled"},{"id":39,"web_url":"http://1b25ef517b98/groups/test/test1","name":"test1","path":"test1","description":"","visibility":"private","share_with_group_lock":false,"require_two_factor_authentication":false,"two_factor_grace_period":48,"project_creation_level":"developer","auto_devops_enabled":null,"subgroup_creation_level":"maintainer","emails_disabled":false,"emails_enabled":true,"mentions_disabled":null,"lfs_enabled":true,"math_rendering_limits_enabled":true,"lock_math_rendering_limits_enabled":false,"default_branch":null,"default_branch_protection":2,"default_branch_protection_defaults":{"allowed_to_push":[{"access_level":40}],"allow_force_push":false,"allowed_to_merge":[{"access_level":40}]},"avatar_url":null,"request_access_enabled":true,"full_name":"test / test1","full_path":"test/test1","created_at":"2024-10-11T07:48:39.999Z","parent_id":37,"organization_id":1,"shared_runners_setting":"enabled"},{"id":40,"web_url":"http://1b25ef517b98/groups/test2","name":"test2","path":"test2","description":"","visibility":"private","share_with_group_lock":false,"require_two_factor_authentication":false,"two_factor_grace_period":48,"project_creation_level":"developer","auto_devops_enabled":null,"subgroup_creation_level":"maintainer","emails_disabled":false,"emails_enabled":true,"mentions_disabled":null,"lfs_enabled":true,"math_rendering_limits_enabled":true,"lock_math_rendering_limits_enabled":false,"default_branch":null,"default_branch_protection":2,"default_branch_protection_defaults":{"allowed_to_push":[{"access_level":40}],"allow_force_push":false,"allowed_to_merge":[{"access_level":40}]},"avatar_url":null,"request_access_enabled":true,"full_name":"test2","full_path":"test2","created_at":"2024-10-11T07:48:59.139Z","parent_id":null,"organization_id":1,"shared_runners_setting":"enabled"}]' + body: '[{"id":37,"web_url":"http://7b1d891ab6bb/groups/test","name":"test","path":"test","description":"","visibility":"private","share_with_group_lock":false,"require_two_factor_authentication":false,"two_factor_grace_period":48,"project_creation_level":"developer","auto_devops_enabled":null,"subgroup_creation_level":"maintainer","emails_disabled":false,"emails_enabled":true,"mentions_disabled":null,"lfs_enabled":true,"math_rendering_limits_enabled":true,"lock_math_rendering_limits_enabled":false,"default_branch":null,"default_branch_protection":2,"default_branch_protection_defaults":{"allowed_to_push":[{"access_level":40}],"allow_force_push":false,"allowed_to_merge":[{"access_level":40}]},"avatar_url":null,"request_access_enabled":true,"full_name":"test","full_path":"test","created_at":"2024-10-11T07:48:18.836Z","parent_id":null,"organization_id":1,"shared_runners_setting":"enabled"},{"id":39,"web_url":"http://7b1d891ab6bb/groups/test/test1","name":"test1","path":"test1","description":"","visibility":"private","share_with_group_lock":false,"require_two_factor_authentication":false,"two_factor_grace_period":48,"project_creation_level":"developer","auto_devops_enabled":null,"subgroup_creation_level":"maintainer","emails_disabled":false,"emails_enabled":true,"mentions_disabled":null,"lfs_enabled":true,"math_rendering_limits_enabled":true,"lock_math_rendering_limits_enabled":false,"default_branch":null,"default_branch_protection":2,"default_branch_protection_defaults":{"allowed_to_push":[{"access_level":40}],"allow_force_push":false,"allowed_to_merge":[{"access_level":40}]},"avatar_url":null,"request_access_enabled":true,"full_name":"test / test1","full_path":"test/test1","created_at":"2024-10-11T07:48:39.999Z","parent_id":37,"organization_id":1,"shared_runners_setting":"enabled"},{"id":40,"web_url":"http://7b1d891ab6bb/groups/test2","name":"test2","path":"test2","description":"","visibility":"private","share_with_group_lock":false,"require_two_factor_authentication":false,"two_factor_grace_period":48,"project_creation_level":"developer","auto_devops_enabled":null,"subgroup_creation_level":"maintainer","emails_disabled":false,"emails_enabled":true,"mentions_disabled":null,"lfs_enabled":true,"math_rendering_limits_enabled":true,"lock_math_rendering_limits_enabled":false,"default_branch":null,"default_branch_protection":2,"default_branch_protection_defaults":{"allowed_to_push":[{"access_level":40}],"allow_force_push":false,"allowed_to_merge":[{"access_level":40}]},"avatar_url":null,"request_access_enabled":true,"full_name":"test2","full_path":"test2","created_at":"2024-10-11T07:48:59.139Z","parent_id":null,"organization_id":1,"shared_runners_setting":"enabled"}]' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -41,11 +41,11 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:27:58 GMT + - Sat, 14 Dec 2024 22:52:47 GMT Etag: - - W/"a5a174aa9f8d8a0f74463379f0b3c209" + - W/"0fa3de16c23f07181937feab699523d1" Link: - - ; rel="first", ; rel="last" + - ; rel="first", ; rel="last" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -60,7 +60,7 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK1K21S99HBNQJGAK1WZQ","version":"1"}' + - '{"correlation_id":"01JF3NZNZVMZYZWW7HWJGAFB2T","version":"1"}' X-Next-Page: - "" X-Page: @@ -70,16 +70,16 @@ interactions: X-Prev-Page: - "" X-Request-Id: - - 01JA2XK1K21S99HBNQJGAK1WZQ + - 01JF3NZNZVMZYZWW7HWJGAFB2T X-Runtime: - - "0.174229" + - "0.066530" X-Total: - "3" X-Total-Pages: - "1" status: 200 OK code: 200 - duration: 178.760917ms + duration: 71.918167ms - id: 1 request: proto: HTTP/1.1 @@ -121,11 +121,11 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:27:58 GMT + - Sat, 14 Dec 2024 22:52:47 GMT Etag: - W/"4f53cda18c2baa0c0354bb5f9a3ecbe5" Link: - - ; rel="first", ; rel="last" + - ; rel="first", ; rel="last" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -139,7 +139,7 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK1YCHDHNHH6YJWEJ5REW","version":"1"}' + - '{"correlation_id":"01JF3NZP4RCH6E9R37XA2CHFBA","version":"1"}' X-Next-Page: - "" X-Page: @@ -149,13 +149,13 @@ interactions: X-Prev-Page: - "" X-Request-Id: - - 01JA2XK1YCHDHNHH6YJWEJ5REW + - 01JF3NZP4RCH6E9R37XA2CHFBA X-Runtime: - - "0.184552" + - "0.016426" X-Total: - "0" X-Total-Pages: - "1" status: 200 OK code: 200 - duration: 195.975417ms + duration: 19.421333ms diff --git a/testdata/fixtures/16.11.6/TestGitlabClient_GetUserIdByUsername.yaml b/testdata/unit/TestGitlabClient_GetUserIdByUsername.yaml similarity index 82% rename from testdata/fixtures/16.11.6/TestGitlabClient_GetUserIdByUsername.yaml rename to testdata/unit/TestGitlabClient_GetUserIdByUsername.yaml index 2ce6df8..e37c197 100644 --- a/testdata/fixtures/16.11.6/TestGitlabClient_GetUserIdByUsername.yaml +++ b/testdata/unit/TestGitlabClient_GetUserIdByUsername.yaml @@ -32,7 +32,7 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '[{"id":1,"username":"root","name":"Administrator","state":"active","locked":false,"avatar_url":"https://www.gravatar.com/avatar/258d8dc916db8cea2cafb6c3cd0cb0246efe061421dbd83ec3a350428cabda4f?s=80\u0026d=identicon","web_url":"http://1b25ef517b98/root","created_at":"2024-07-11T18:51:40.925Z","bio":"","location":"","public_email":null,"skype":"","linkedin":"","twitter":"","discord":"","website_url":"","organization":"","job_title":"","pronouns":null,"bot":false,"work_information":null,"local_time":null,"last_sign_in_at":"2024-07-11T18:54:22.894Z","confirmed_at":"2024-07-11T18:51:40.831Z","last_activity_on":"2024-10-13","email":"admin@example.com","theme_id":3,"color_scheme_id":1,"projects_limit":100000,"current_sign_in_at":"2024-10-11T07:48:06.781Z","identities":[],"can_create_group":true,"can_create_project":true,"two_factor_enabled":false,"external":false,"private_profile":false,"commit_email":"admin@example.com","is_admin":true,"note":null,"namespace_id":1,"created_by":null,"email_reset_offered_at":null}]' + body: '[{"id":1,"username":"root","name":"Administrator","state":"active","locked":false,"avatar_url":"https://www.gravatar.com/avatar/258d8dc916db8cea2cafb6c3cd0cb0246efe061421dbd83ec3a350428cabda4f?s=80\u0026d=identicon","web_url":"http://7b1d891ab6bb/root","created_at":"2024-07-11T18:51:40.925Z","bio":"","location":"","public_email":null,"skype":"","linkedin":"","twitter":"","discord":"","website_url":"","organization":"","job_title":"","pronouns":null,"bot":false,"work_information":null,"local_time":null,"last_sign_in_at":"2024-07-11T18:54:22.894Z","confirmed_at":"2024-07-11T18:51:40.831Z","last_activity_on":"2024-12-14","email":"admin@example.com","theme_id":3,"color_scheme_id":1,"projects_limit":100000,"current_sign_in_at":"2024-10-11T07:48:06.781Z","identities":[],"can_create_group":true,"can_create_project":true,"two_factor_enabled":false,"external":false,"private_profile":false,"commit_email":"admin@example.com","is_admin":true,"note":null,"namespace_id":1,"created_by":null,"email_reset_offered_at":null}]' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -41,11 +41,11 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:27:59 GMT + - Sat, 14 Dec 2024 22:52:47 GMT Etag: - - W/"ff413862d7bbfd875444c622c4921e00" + - W/"0b39ec89d1dbe684694e4d5520a69eca" Link: - - ; rel="first", ; rel="last" + - ; rel="first", ; rel="last" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -60,7 +60,7 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK2AP0NRNASN3C8BV69C5","version":"1"}' + - '{"correlation_id":"01JF3NZP6FVJ6AKG5TFME7428E","version":"1"}' X-Next-Page: - "" X-Page: @@ -70,13 +70,13 @@ interactions: X-Prev-Page: - "" X-Request-Id: - - 01JA2XK2AP0NRNASN3C8BV69C5 + - 01JF3NZP6FVJ6AKG5TFME7428E X-Runtime: - - "0.227706" + - "0.133484" X-Total: - "1" X-Total-Pages: - "1" status: 200 OK code: 200 - duration: 230.88875ms + duration: 137.028ms diff --git a/testdata/fixtures/16.11.6/TestGitlabClient_GetUserIdByUsernameDoesNotMatch.yaml b/testdata/unit/TestGitlabClient_GetUserIdByUsernameDoesNotMatch.yaml similarity index 84% rename from testdata/fixtures/16.11.6/TestGitlabClient_GetUserIdByUsernameDoesNotMatch.yaml rename to testdata/unit/TestGitlabClient_GetUserIdByUsernameDoesNotMatch.yaml index 5e5cadc..3186509 100644 --- a/testdata/fixtures/16.11.6/TestGitlabClient_GetUserIdByUsernameDoesNotMatch.yaml +++ b/testdata/unit/TestGitlabClient_GetUserIdByUsernameDoesNotMatch.yaml @@ -42,11 +42,11 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:27:59 GMT + - Sat, 14 Dec 2024 22:52:48 GMT Etag: - W/"4f53cda18c2baa0c0354bb5f9a3ecbe5" Link: - - ; rel="first", ; rel="last" + - ; rel="first", ; rel="last" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -60,7 +60,7 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK2SA2VH963B8SRC7JMCF","version":"1"}' + - '{"correlation_id":"01JF3NZPFB83PB4P7B9TZ9BYFZ","version":"1"}' X-Next-Page: - "" X-Page: @@ -70,16 +70,16 @@ interactions: X-Prev-Page: - "" X-Request-Id: - - 01JA2XK2SA2VH963B8SRC7JMCF + - 01JF3NZPFB83PB4P7B9TZ9BYFZ X-Runtime: - - "0.183937" + - "0.176857" X-Total: - "0" X-Total-Pages: - "1" status: 200 OK code: 200 - duration: 193.2545ms + duration: 182.2995ms - id: 1 request: proto: HTTP/1.1 @@ -121,11 +121,11 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:28:00 GMT + - Sat, 14 Dec 2024 22:52:48 GMT Etag: - W/"4f53cda18c2baa0c0354bb5f9a3ecbe5" Link: - - ; rel="first", ; rel="last" + - ; rel="first", ; rel="last" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -139,7 +139,7 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK35DVD5VRQTEEHXV1K10","version":"1"}' + - '{"correlation_id":"01JF3NZPTVCMQG0WF75EAY41Q4","version":"1"}' X-Next-Page: - "" X-Page: @@ -149,13 +149,13 @@ interactions: X-Prev-Page: - "" X-Request-Id: - - 01JA2XK35DVD5VRQTEEHXV1K10 + - 01JF3NZPTVCMQG0WF75EAY41Q4 X-Runtime: - - "0.159246" + - "0.027100" X-Total: - "0" X-Total-Pages: - "1" status: 200 OK code: 200 - duration: 166.066708ms + duration: 36.240625ms diff --git a/testdata/fixtures/16.11.6/TestGitlabClient_InvalidToken.yaml b/testdata/unit/TestGitlabClient_InvalidToken.yaml similarity index 86% rename from testdata/fixtures/16.11.6/TestGitlabClient_InvalidToken.yaml rename to testdata/unit/TestGitlabClient_InvalidToken.yaml index 4d80e8e..e4f73a1 100644 --- a/testdata/fixtures/16.11.6/TestGitlabClient_InvalidToken.yaml +++ b/testdata/unit/TestGitlabClient_InvalidToken.yaml @@ -42,7 +42,7 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:27:57 GMT + - Sat, 14 Dec 2024 22:52:46 GMT Server: - nginx Vary: @@ -52,14 +52,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK0N1S4K1065C4JKK7FZW","version":"1"}' + - '{"correlation_id":"01JF3NZN00MY6YACGC7YXPQHXJ","version":"1"}' X-Request-Id: - - 01JA2XK0N1S4K1065C4JKK7FZW + - 01JF3NZN00MY6YACGC7YXPQHXJ X-Runtime: - - "0.068104" + - "0.051312" status: 401 Unauthorized code: 401 - duration: 88.93025ms + duration: 75.880875ms - id: 1 request: proto: HTTP/1.1 @@ -101,7 +101,7 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:27:57 GMT + - Sat, 14 Dec 2024 22:52:46 GMT Server: - nginx Vary: @@ -111,14 +111,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK0T8GBKYCZYCZYTR128J","version":"1"}' + - '{"correlation_id":"01JF3NZN4ACR3A51WN94SX3KZC","version":"1"}' X-Request-Id: - - 01JA2XK0T8GBKYCZYCZYTR128J + - 01JF3NZN4ACR3A51WN94SX3KZC X-Runtime: - - "0.009570" + - "0.010034" status: 401 Unauthorized code: 401 - duration: 12.795ms + duration: 13.204166ms - id: 2 request: proto: HTTP/1.1 @@ -160,7 +160,7 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:27:57 GMT + - Sat, 14 Dec 2024 22:52:46 GMT Server: - nginx Vary: @@ -170,14 +170,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK0V23B8RTZZQ8P7483S3","version":"1"}' + - '{"correlation_id":"01JF3NZN56Z5CVNYVDE1PP192D","version":"1"}' X-Request-Id: - - 01JA2XK0V23B8RTZZQ8P7483S3 + - 01JF3NZN56Z5CVNYVDE1PP192D X-Runtime: - - "0.011357" + - "0.014313" status: 401 Unauthorized code: 401 - duration: 13.806042ms + duration: 18.160125ms - id: 3 request: proto: HTTP/1.1 @@ -219,7 +219,7 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:27:57 GMT + - Sat, 14 Dec 2024 22:52:46 GMT Server: - nginx Vary: @@ -229,14 +229,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK0VZ7X7C3S9TYHHNVTSZ","version":"1"}' + - '{"correlation_id":"01JF3NZN6DG8DZJHP0SF2TTR5P","version":"1"}' X-Request-Id: - - 01JA2XK0VZ7X7C3S9TYHHNVTSZ + - 01JF3NZN6DG8DZJHP0SF2TTR5P X-Runtime: - - "0.043766" + - "0.013139" status: 401 Unauthorized code: 401 - duration: 46.485625ms + duration: 16.53575ms - id: 4 request: proto: HTTP/1.1 @@ -278,7 +278,7 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:27:57 GMT + - Sat, 14 Dec 2024 22:52:46 GMT Server: - nginx Vary: @@ -288,14 +288,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK0YXWY2PHNK4XJJM2VH4","version":"1"}' + - '{"correlation_id":"01JF3NZN7H3YG7DVKFYHQVH6CW","version":"1"}' X-Request-Id: - - 01JA2XK0YXWY2PHNK4XJJM2VH4 + - 01JF3NZN7H3YG7DVKFYHQVH6CW X-Runtime: - - "0.052846" + - "0.039589" status: 401 Unauthorized code: 401 - duration: 55.746625ms + duration: 42.624834ms - id: 5 request: proto: HTTP/1.1 @@ -337,7 +337,7 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:27:57 GMT + - Sat, 14 Dec 2024 22:52:46 GMT Server: - nginx Vary: @@ -347,14 +347,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK12E4BEZ6QB576M293VQ","version":"1"}' + - '{"correlation_id":"01JF3NZNA8HHTM7MBBHE59TT98","version":"1"}' X-Request-Id: - - 01JA2XK12E4BEZ6QB576M293VQ + - 01JF3NZNA8HHTM7MBBHE59TT98 X-Runtime: - - "0.016749" + - "0.042497" status: 401 Unauthorized code: 401 - duration: 19.454375ms + duration: 46.19525ms - id: 6 request: proto: HTTP/1.1 @@ -366,7 +366,7 @@ interactions: host: localhost:8080 remote_addr: "" request_uri: "" - body: '{"name":"name","scopes":["scope"],"access_level":-1,"expires_at":"2024-12-12"}' + body: '{"name":"name","scopes":["scope"],"access_level":-1,"expires_at":"2025-03-12"}' form: {} headers: Accept: @@ -398,7 +398,7 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:27:57 GMT + - Sat, 14 Dec 2024 22:52:46 GMT Server: - nginx Vary: @@ -408,14 +408,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK13QVNE0S5TTNRZD9BBX","version":"1"}' + - '{"correlation_id":"01JF3NZND8Y1HV7DRZ0MV81ZVR","version":"1"}' X-Request-Id: - - 01JA2XK13QVNE0S5TTNRZD9BBX + - 01JF3NZND8Y1HV7DRZ0MV81ZVR X-Runtime: - - "0.015586" + - "0.015286" status: 401 Unauthorized code: 401 - duration: 19.102833ms + duration: 19.381334ms - id: 7 request: proto: HTTP/1.1 @@ -427,7 +427,7 @@ interactions: host: localhost:8080 remote_addr: "" request_uri: "" - body: '{"name":"name","scopes":["scope"],"access_level":-1,"expires_at":"2024-12-12"}' + body: '{"name":"name","scopes":["scope"],"access_level":-1,"expires_at":"2025-03-12"}' form: {} headers: Accept: @@ -459,7 +459,7 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:27:57 GMT + - Sat, 14 Dec 2024 22:52:46 GMT Server: - nginx Vary: @@ -469,14 +469,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK14ZFXHAHX6EYCFCP064","version":"1"}' + - '{"correlation_id":"01JF3NZNEHA4ANMY8C1TMBW6Y2","version":"1"}' X-Request-Id: - - 01JA2XK14ZFXHAHX6EYCFCP064 + - 01JF3NZNEHA4ANMY8C1TMBW6Y2 X-Runtime: - - "0.014638" + - "0.014890" status: 401 Unauthorized code: 401 - duration: 17.091292ms + duration: 18.5075ms - id: 8 request: proto: HTTP/1.1 @@ -488,7 +488,7 @@ interactions: host: localhost:8080 remote_addr: "" request_uri: "" - body: '{"name":"name","expires_at":"2024-12-12","scopes":["scope"]}' + body: '{"name":"name","expires_at":"2025-03-12","scopes":["scope"]}' form: {} headers: Accept: @@ -520,7 +520,7 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:27:58 GMT + - Sat, 14 Dec 2024 22:52:46 GMT Server: - nginx Vary: @@ -530,11 +530,11 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK162QS1E8HBCXG96ZE9R","version":"1"}' + - '{"correlation_id":"01JF3NZNFRP24MX116GCVW34YZ","version":"1"}' X-Request-Id: - - 01JA2XK162QS1E8HBCXG96ZE9R + - 01JF3NZNFRP24MX116GCVW34YZ X-Runtime: - - "0.012494" + - "0.013126" status: 401 Unauthorized code: 401 - duration: 15.038041ms + duration: 17.048209ms diff --git a/testdata/fixtures/16.11.6/TestPathConfig_AutoRotate_auto_rotate_token_should_be_false_if_not_specified.yaml b/testdata/unit/TestGitlabClient_Metadata.yaml similarity index 62% rename from testdata/fixtures/16.11.6/TestPathConfig_AutoRotate_auto_rotate_token_should_be_false_if_not_specified.yaml rename to testdata/unit/TestGitlabClient_Metadata.yaml index 010420a..a01166d 100644 --- a/testdata/fixtures/16.11.6/TestPathConfig_AutoRotate_auto_rotate_token_should_be_false_if_not_specified.yaml +++ b/testdata/unit/TestGitlabClient_Metadata.yaml @@ -21,29 +21,30 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self + url: http://localhost:8080/api/v4/metadata method: GET response: proto: HTTP/1.1 proto_major: 1 proto_minor: 1 - transfer_encoding: - - chunked + transfer_encoding: [] trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' headers: Cache-Control: - max-age=0, private, must-revalidate Connection: - keep-alive + Content-Length: + - "162" Content-Type: - application/json Date: - - Fri, 11 Oct 2024 09:11:10 GMT + - Sat, 14 Dec 2024 22:54:30 GMT Etag: - - W/"86a012f2542444285d00a390ed234220" + - W/"a29dcadce9c4771a1b7b66cc326f6617" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -51,18 +52,17 @@ interactions: Strict-Transport-Security: - max-age=63072000 Vary: - - Accept-Encoding - Origin X-Content-Type-Options: - nosniff X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH8BZBEGTVV8XD60TRJ9P","version":"1"}' + - '{"correlation_id":"01JF3P2TZFPQNHDHSVSFM1P4NQ","version":"1"}' X-Request-Id: - - 01J9XDH8BZBEGTVV8XD60TRJ9P + - 01JF3P2TZFPQNHDHSVSFM1P4NQ X-Runtime: - - "0.024665" + - "0.039610" status: 200 OK code: 200 - duration: 28.05275ms + duration: 70.684625ms diff --git a/testdata/fixtures/16.11.6/TestGitlabClient_RevokeToken_NotFound.yaml b/testdata/unit/TestGitlabClient_RevokeToken_NotFound.yaml similarity index 86% rename from testdata/fixtures/16.11.6/TestGitlabClient_RevokeToken_NotFound.yaml rename to testdata/unit/TestGitlabClient_RevokeToken_NotFound.yaml index 4553136..f7f3379 100644 --- a/testdata/fixtures/16.11.6/TestGitlabClient_RevokeToken_NotFound.yaml +++ b/testdata/unit/TestGitlabClient_RevokeToken_NotFound.yaml @@ -42,20 +42,20 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:27:58 GMT + - Sat, 14 Dec 2024 22:52:47 GMT Server: - nginx Vary: - Origin X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK176XRVT8RYM15YGW92X","version":"1"}' + - '{"correlation_id":"01JF3NZNHWDJZBMR5RK5Z3TQBZ","version":"1"}' X-Request-Id: - - 01JA2XK176XRVT8RYM15YGW92X + - 01JF3NZNHWDJZBMR5RK5Z3TQBZ X-Runtime: - - "0.076812" + - "0.059776" status: 404 Not Found code: 404 - duration: 79.292ms + duration: 63.294125ms - id: 1 request: proto: HTTP/1.1 @@ -97,7 +97,7 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:27:58 GMT + - Sat, 14 Dec 2024 22:52:47 GMT Server: - nginx Vary: @@ -107,14 +107,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK1C724CTNYS11Q5BFS5M","version":"1"}' + - '{"correlation_id":"01JF3NZNNY4BDC6D4F8HWD9QH7","version":"1"}' X-Request-Id: - - 01JA2XK1C724CTNYS11Q5BFS5M + - 01JF3NZNNY4BDC6D4F8HWD9QH7 X-Runtime: - - "0.027324" + - "0.117867" status: 404 Not Found code: 404 - duration: 30.005875ms + duration: 121.439458ms - id: 2 request: proto: HTTP/1.1 @@ -156,7 +156,7 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:27:58 GMT + - Sat, 14 Dec 2024 22:52:47 GMT Server: - nginx Vary: @@ -166,11 +166,11 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK1E4T62H5BCKV7FJ3GS0","version":"1"}' + - '{"correlation_id":"01JF3NZNXM6HDVDGAYFMECN7PT","version":"1"}' X-Request-Id: - - 01JA2XK1E4T62H5BCKV7FJ3GS0 + - 01JF3NZNXM6HDVDGAYFMECN7PT X-Runtime: - - "0.074579" + - "0.026328" status: 404 Not Found code: 404 - duration: 77.232916ms + duration: 29.987667ms diff --git a/testdata/fixtures/16.11.6/TestGitlabClient_Revoke_NonExistingTokens.yaml b/testdata/unit/TestGitlabClient_Revoke_NonExistingTokens.yaml similarity index 86% rename from testdata/fixtures/16.11.6/TestGitlabClient_Revoke_NonExistingTokens.yaml rename to testdata/unit/TestGitlabClient_Revoke_NonExistingTokens.yaml index af3bc79..e5f511c 100644 --- a/testdata/fixtures/16.11.6/TestGitlabClient_Revoke_NonExistingTokens.yaml +++ b/testdata/unit/TestGitlabClient_Revoke_NonExistingTokens.yaml @@ -42,20 +42,20 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:28:00 GMT + - Sat, 14 Dec 2024 22:52:48 GMT Server: - nginx Vary: - Origin X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK3FYHW9R8EFZW6D0TATR","version":"1"}' + - '{"correlation_id":"01JF3NZPXF5FRMYYG324XTC9N2","version":"1"}' X-Request-Id: - - 01JA2XK3FYHW9R8EFZW6D0TATR + - 01JF3NZPXF5FRMYYG324XTC9N2 X-Runtime: - - "0.025061" + - "0.019850" status: 404 Not Found code: 404 - duration: 30.981875ms + duration: 24.34ms - id: 1 request: proto: HTTP/1.1 @@ -97,7 +97,7 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:28:00 GMT + - Sat, 14 Dec 2024 22:52:48 GMT Server: - nginx Vary: @@ -107,14 +107,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK3HW7ZA58537YHRP3QQW","version":"1"}' + - '{"correlation_id":"01JF3NZPZ28YJMS7TB1MP99XG7","version":"1"}' X-Request-Id: - - 01JA2XK3HW7ZA58537YHRP3QQW + - 01JF3NZPZ28YJMS7TB1MP99XG7 X-Runtime: - - "0.058143" + - "0.078111" status: 404 Not Found code: 404 - duration: 61.803917ms + duration: 81.211292ms - id: 2 request: proto: HTTP/1.1 @@ -156,7 +156,7 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:28:00 GMT + - Sat, 14 Dec 2024 22:52:48 GMT Server: - nginx Vary: @@ -166,11 +166,11 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK3NSWTZKWTYQWJDN8AEZ","version":"1"}' + - '{"correlation_id":"01JF3NZQ47F3GBVJNW9ZD82H82","version":"1"}' X-Request-Id: - - 01JA2XK3NSWTZKWTYQWJDN8AEZ + - 01JF3NZQ47F3GBVJNW9ZD82H82 X-Runtime: - - "0.064515" + - "0.062453" status: 404 Not Found code: 404 - duration: 67.39075ms + duration: 66.254208ms diff --git a/testdata/fixtures/16.11.6/TestGitlabClient_RotateCurrentToken.yaml b/testdata/unit/TestGitlabClient_RotateCurrentToken.yaml similarity index 83% rename from testdata/fixtures/16.11.6/TestGitlabClient_RotateCurrentToken.yaml rename to testdata/unit/TestGitlabClient_RotateCurrentToken.yaml index f5986ac..960fef4 100644 --- a/testdata/fixtures/16.11.6/TestGitlabClient_RotateCurrentToken.yaml +++ b/testdata/unit/TestGitlabClient_RotateCurrentToken.yaml @@ -32,7 +32,7 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":6,"name":"Auto rotate token 1","revoked":false,"created_at":"2024-07-11T18:55:07.266Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":2,"last_used_at":"2024-10-13T12:28:02.879Z","active":true,"expires_at":"2025-07-11"}' + body: '{"id":6,"name":"Auto rotate token 1","revoked":false,"created_at":"2024-07-11T18:55:07.266Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":2,"last_used_at":"2024-12-14T22:52:50.555Z","active":true,"expires_at":"2025-07-11"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -41,9 +41,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:28:02 GMT + - Sat, 14 Dec 2024 22:52:50 GMT Etag: - - W/"f9b1f31034f7470b57f6d4b35821dc05" + - W/"a0eefa62eabf96fb00c06e6028a0da42" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -58,14 +58,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK5XNFVGWRJHFJRKR9HJ2","version":"1"}' + - '{"correlation_id":"01JF3NZRZF2Y1CDEPK7XZYMA3R","version":"1"}' X-Request-Id: - - 01JA2XK5XNFVGWRJHFJRKR9HJ2 + - 01JF3NZRZF2Y1CDEPK7XZYMA3R X-Runtime: - - "0.032270" + - "0.066571" status: 200 OK code: 200 - duration: 35.184292ms + duration: 69.969875ms - id: 1 request: proto: HTTP/1.1 @@ -97,7 +97,7 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":2,"username":"admin-user","name":"Admin User","state":"active","locked":false,"avatar_url":"https://www.gravatar.com/avatar/af0325f5b5bc22760340e6e28bbe467949a83cf3a620329417c7718f89e0f7c5?s=80\u0026d=identicon","web_url":"http://1b25ef517b98/admin-user","created_at":"2024-07-11T18:52:45.504Z","bio":"","location":"","public_email":null,"skype":"","linkedin":"","twitter":"","discord":"","website_url":"","organization":"","job_title":"","pronouns":null,"bot":false,"work_information":null,"local_time":null,"last_sign_in_at":null,"confirmed_at":"2024-07-11T18:52:45.443Z","last_activity_on":"2024-10-13","email":"admin@local","theme_id":3,"color_scheme_id":1,"projects_limit":100000,"current_sign_in_at":null,"identities":[],"can_create_group":true,"can_create_project":true,"two_factor_enabled":false,"external":false,"private_profile":false,"commit_email":"admin@local","is_admin":true,"note":null,"namespace_id":2,"created_by":null,"email_reset_offered_at":null,"highest_role":0,"current_sign_in_ip":null,"last_sign_in_ip":null,"sign_in_count":0}' + body: '{"id":2,"username":"admin-user","name":"Admin User","state":"active","locked":false,"avatar_url":"https://www.gravatar.com/avatar/af0325f5b5bc22760340e6e28bbe467949a83cf3a620329417c7718f89e0f7c5?s=80\u0026d=identicon","web_url":"http://7b1d891ab6bb/admin-user","created_at":"2024-07-11T18:52:45.504Z","bio":"","location":"","public_email":null,"skype":"","linkedin":"","twitter":"","discord":"","website_url":"","organization":"","job_title":"","pronouns":null,"bot":false,"work_information":null,"local_time":null,"last_sign_in_at":null,"confirmed_at":"2024-07-11T18:52:45.443Z","last_activity_on":"2024-12-14","email":"admin@local","theme_id":3,"color_scheme_id":1,"projects_limit":100000,"current_sign_in_at":null,"identities":[],"can_create_group":true,"can_create_project":true,"two_factor_enabled":false,"external":false,"private_profile":false,"commit_email":"admin@local","is_admin":true,"note":null,"namespace_id":2,"created_by":null,"email_reset_offered_at":null,"highest_role":0,"current_sign_in_ip":null,"last_sign_in_ip":null,"sign_in_count":0}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -106,9 +106,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:28:03 GMT + - Sat, 14 Dec 2024 22:52:50 GMT Etag: - - W/"df1b03f2d052404f3bfbdb373ca82f49" + - W/"a5ebe426c9c75beba43d948c082aa341" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -123,14 +123,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK5ZW2GCJG9SXKXPGT4EQ","version":"1"}' + - '{"correlation_id":"01JF3NZS3YXBRBAB5ZKE9CRH1D","version":"1"}' X-Request-Id: - - 01JA2XK5ZW2GCJG9SXKXPGT4EQ + - 01JF3NZS3YXBRBAB5ZKE9CRH1D X-Runtime: - - "0.064715" + - "0.070966" status: 200 OK code: 200 - duration: 67.20075ms + duration: 74.456334ms - id: 2 request: proto: HTTP/1.1 @@ -142,7 +142,7 @@ interactions: host: localhost:8080 remote_addr: "" request_uri: "" - body: '{"expires_at":"2025-08-12"}' + body: '{"expires_at":"2025-12-12"}' form: {} headers: Accept: @@ -164,7 +164,7 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":46,"name":"Auto rotate token 1","revoked":false,"created_at":"2024-10-13T12:28:03.097Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":2,"last_used_at":null,"active":true,"expires_at":"2025-08-12","token":"glpat-Fmnvoj6H8eg7Re8TNztv"}' + body: '{"id":46,"name":"Auto rotate token 1","revoked":false,"created_at":"2024-12-14T22:52:50.864Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":2,"last_used_at":null,"active":true,"expires_at":"2025-12-12","token":"glpat-YzNhytivSqMLnp5gAaLo"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -173,9 +173,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:28:03 GMT + - Sat, 14 Dec 2024 22:52:50 GMT Etag: - - W/"4d284f8c8b8cff8e18635d469441a4b3" + - W/"d67f95cabac7cc876a5be307105f4188" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -190,11 +190,11 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2XK644KCGCM71XH7M7HRMS","version":"1"}' + - '{"correlation_id":"01JF3NZS8RBXQJWH8M92WZGAAE","version":"1"}' X-Request-Id: - - 01JA2XK644KCGCM71XH7M7HRMS + - 01JF3NZS8RBXQJWH8M92WZGAAE X-Runtime: - - "0.024732" + - "0.027937" status: 200 OK code: 200 - duration: 27.712458ms + duration: 31.469208ms diff --git a/testdata/fixtures/16.11.6/TestPathConfigList_empty_list.yaml b/testdata/unit/TestPathConfigList_empty_list.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestPathConfigList_empty_list.yaml rename to testdata/unit/TestPathConfigList_empty_list.yaml diff --git a/testdata/unit/TestPathConfigList_multiple_configs.yaml b/testdata/unit/TestPathConfigList_multiple_configs.yaml new file mode 100644 index 0000000..a6cc5f9 --- /dev/null +++ b/testdata/unit/TestPathConfigList_multiple_configs.yaml @@ -0,0 +1,393 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:50 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZSBARM9SZGSE4MW1243V","version":"1"}' + X-Request-Id: + - 01JF3NZSBARM9SZGSE4MW1243V + X-Runtime: + - "0.014097" + status: 200 OK + code: 200 + duration: 16.984625ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:50 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZSCE7Q9X618X8PTBC5ZV","version":"1"}' + X-Request-Id: + - 01JF3NZSCE7Q9X618X8PTBC5ZV + X-Runtime: + - "0.016635" + status: 200 OK + code: 200 + duration: 18.981042ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":2,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:46.924Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":2,"last_used_at":"2024-12-14T22:52:51.011Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:51 GMT + Etag: + - W/"294f5bcfa91aa421ae25d18cbc532b92" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZSDTDBT6SM4QGJY7RW1S","version":"1"}' + X-Request-Id: + - 01JF3NZSDTDBT6SM4QGJY7RW1S + X-Runtime: + - "0.013978" + status: 200 OK + code: 200 + duration: 16.760333ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:51 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZSEYR1RGGB1ETH7RT1AG","version":"1"}' + X-Request-Id: + - 01JF3NZSEYR1RGGB1ETH7RT1AG + X-Runtime: + - "0.016300" + status: 200 OK + code: 200 + duration: 18.918709ms + - id: 4 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":3,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:54:07.334Z","scopes":["api","read_api","read_user","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":3,"last_used_at":"2024-12-14T22:52:51.087Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:51 GMT + Etag: + - W/"8f85f2050c9c993f8120af90dfd869ae" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZSG831Q1M8B5VXJC1KQ8","version":"1"}' + X-Request-Id: + - 01JF3NZSG831Q1M8B5VXJC1KQ8 + X-Runtime: + - "0.026446" + status: 200 OK + code: 200 + duration: 29.155875ms + - id: 5 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:51 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZSJ4XWVHN3EP6CFNGJZM","version":"1"}' + X-Request-Id: + - 01JF3NZSJ4XWVHN3EP6CFNGJZM + X-Runtime: + - "0.011815" + status: 200 OK + code: 200 + duration: 14.182709ms diff --git a/testdata/fixtures/16.11.6/TestPathConfigRotate_initial_config_should_be_empty_fail_with_backend_not_configured.yaml b/testdata/unit/TestPathConfigRotate_initial_config_should_be_empty_fail_with_backend_not_configured.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestPathConfigRotate_initial_config_should_be_empty_fail_with_backend_not_configured.yaml rename to testdata/unit/TestPathConfigRotate_initial_config_should_be_empty_fail_with_backend_not_configured.yaml diff --git a/testdata/fixtures/16.11.6/TestPathConfig_AutoRotateToken_call_auto_rotate_the_main_token_and_rotate_the_token.yaml b/testdata/unit/TestPathConfig_AutoRotateToken_call_auto_rotate_the_main_token_and_rotate_the_token.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestPathConfig_AutoRotateToken_call_auto_rotate_the_main_token_and_rotate_the_token.yaml rename to testdata/unit/TestPathConfig_AutoRotateToken_call_auto_rotate_the_main_token_and_rotate_the_token.yaml diff --git a/testdata/fixtures/16.11.6/TestPathConfig_AutoRotateToken_call_auto_rotate_the_main_token_but_the_token_is_still_valid.yaml b/testdata/unit/TestPathConfig_AutoRotateToken_call_auto_rotate_the_main_token_but_the_token_is_still_valid.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestPathConfig_AutoRotateToken_call_auto_rotate_the_main_token_but_the_token_is_still_valid.yaml rename to testdata/unit/TestPathConfig_AutoRotateToken_call_auto_rotate_the_main_token_but_the_token_is_still_valid.yaml diff --git a/testdata/fixtures/16.11.6/TestPathConfig_AutoRotateToken_no_error_when_auto_rotate_is_disabled_and_config_is_not_set.yaml b/testdata/unit/TestPathConfig_AutoRotateToken_no_error_when_auto_rotate_is_disabled_and_config_is_not_set.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestPathConfig_AutoRotateToken_no_error_when_auto_rotate_is_disabled_and_config_is_not_set.yaml rename to testdata/unit/TestPathConfig_AutoRotateToken_no_error_when_auto_rotate_is_disabled_and_config_is_not_set.yaml diff --git a/testdata/fixtures/16.11.6/TestPathConfig_AutoRotateToken_no_error_when_auto_rotate_is_disabled_and_config_is_set.yaml b/testdata/unit/TestPathConfig_AutoRotateToken_no_error_when_auto_rotate_is_disabled_and_config_is_set.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestPathConfig_AutoRotateToken_no_error_when_auto_rotate_is_disabled_and_config_is_set.yaml rename to testdata/unit/TestPathConfig_AutoRotateToken_no_error_when_auto_rotate_is_disabled_and_config_is_set.yaml diff --git a/testdata/fixtures/16.11.6/TestPathConfig_AutoRotate_auto_rotate_before_cannot_be_more_than_the_minimal_value.yaml b/testdata/unit/TestPathConfig_AutoRotate_auto_rotate_before_cannot_be_more_than_the_minimal_value.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestPathConfig_AutoRotate_auto_rotate_before_cannot_be_more_than_the_minimal_value.yaml rename to testdata/unit/TestPathConfig_AutoRotate_auto_rotate_before_cannot_be_more_than_the_minimal_value.yaml diff --git a/testdata/fixtures/16.11.6/TestPathConfig_AutoRotate_auto_rotate_before_should_be_between_the_min_and_max_value.yaml b/testdata/unit/TestPathConfig_AutoRotate_auto_rotate_before_should_be_between_the_min_and_max_value.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestPathConfig_AutoRotate_auto_rotate_before_should_be_between_the_min_and_max_value.yaml rename to testdata/unit/TestPathConfig_AutoRotate_auto_rotate_before_should_be_between_the_min_and_max_value.yaml diff --git a/testdata/fixtures/16.11.6/TestPathConfig_AutoRotate_auto_rotate_before_should_be_less_than_the_maximal_limit.yaml b/testdata/unit/TestPathConfig_AutoRotate_auto_rotate_before_should_be_less_than_the_maximal_limit.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestPathConfig_AutoRotate_auto_rotate_before_should_be_less_than_the_maximal_limit.yaml rename to testdata/unit/TestPathConfig_AutoRotate_auto_rotate_before_should_be_less_than_the_maximal_limit.yaml diff --git a/testdata/fixtures/16.11.6/TestPathConfig_AutoRotate_auto_rotate_before_should_be_more_than_the_minimal_limit.yaml b/testdata/unit/TestPathConfig_AutoRotate_auto_rotate_before_should_be_more_than_the_minimal_limit.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestPathConfig_AutoRotate_auto_rotate_before_should_be_more_than_the_minimal_limit.yaml rename to testdata/unit/TestPathConfig_AutoRotate_auto_rotate_before_should_be_more_than_the_minimal_limit.yaml diff --git a/testdata/fixtures/16.11.6/TestSecretAccessTokenRevokeToken.yaml b/testdata/unit/TestPathConfig_AutoRotate_auto_rotate_before_should_be_set_to_correct_value.yaml similarity index 73% rename from testdata/fixtures/16.11.6/TestSecretAccessTokenRevokeToken.yaml rename to testdata/unit/TestPathConfig_AutoRotate_auto_rotate_before_should_be_set_to_correct_value.yaml index 9a8c424..efe187c 100644 --- a/testdata/fixtures/16.11.6/TestSecretAccessTokenRevokeToken.yaml +++ b/testdata/unit/TestPathConfig_AutoRotate_auto_rotate_before_should_be_set_to_correct_value.yaml @@ -32,7 +32,7 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -41,9 +41,9 @@ interactions: Content-Type: - application/json Date: - - Fri, 11 Oct 2024 09:11:11 GMT + - Sat, 14 Dec 2024 22:52:51 GMT Etag: - - W/"86a012f2542444285d00a390ed234220" + - W/"d0f486f8d8a3d398674f9cd0e555862f" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -58,14 +58,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH96X6XNMGMHM7JTAENPS","version":"1"}' + - '{"correlation_id":"01JF3NZSZFTRX937BGGEPF73H1","version":"1"}' X-Request-Id: - - 01J9XDH96X6XNMGMHM7JTAENPS + - 01JF3NZSZFTRX937BGGEPF73H1 X-Runtime: - - "0.013924" + - "0.011970" status: 200 OK code: 200 - duration: 17.6015ms + duration: 14.798125ms - id: 1 request: proto: HTTP/1.1 @@ -86,29 +86,30 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self + url: http://localhost:8080/api/v4/metadata method: GET response: proto: HTTP/1.1 proto_major: 1 proto_minor: 1 - transfer_encoding: - - chunked + transfer_encoding: [] trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T09:11:05.898Z","active":true,"expires_at":"2025-07-11"}' + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' headers: Cache-Control: - max-age=0, private, must-revalidate Connection: - keep-alive + Content-Length: + - "162" Content-Type: - application/json Date: - - Fri, 11 Oct 2024 09:11:11 GMT + - Sat, 14 Dec 2024 22:52:51 GMT Etag: - - W/"86a012f2542444285d00a390ed234220" + - W/"a29dcadce9c4771a1b7b66cc326f6617" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -116,18 +117,17 @@ interactions: Strict-Transport-Security: - max-age=63072000 Vary: - - Accept-Encoding - Origin X-Content-Type-Options: - nosniff X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01J9XDH983MVFPZVMYR2S50JWR","version":"1"}' + - '{"correlation_id":"01JF3NZT0GW5REHMWYN7H1FWYG","version":"1"}' X-Request-Id: - - 01J9XDH983MVFPZVMYR2S50JWR + - 01JF3NZT0GW5REHMWYN7H1FWYG X-Runtime: - - "0.011676" + - "0.024121" status: 200 OK code: 200 - duration: 14.349375ms + duration: 27.274042ms diff --git a/testdata/fixtures/16.11.6/TestPathConfig_patch_a_config.yaml b/testdata/unit/TestPathConfig_AutoRotate_auto_rotate_before_should_be_set_to_min_if_not_specified.yaml similarity index 73% rename from testdata/fixtures/16.11.6/TestPathConfig_patch_a_config.yaml rename to testdata/unit/TestPathConfig_AutoRotate_auto_rotate_before_should_be_set_to_min_if_not_specified.yaml index 72fc53b..ad84d57 100644 --- a/testdata/fixtures/16.11.6/TestPathConfig_patch_a_config.yaml +++ b/testdata/unit/TestPathConfig_AutoRotate_auto_rotate_before_should_be_set_to_min_if_not_specified.yaml @@ -32,7 +32,7 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-11T21:24:01.214Z","active":true,"expires_at":"2025-07-11"}' + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -41,9 +41,9 @@ interactions: Content-Type: - application/json Date: - - Fri, 11 Oct 2024 21:29:41 GMT + - Sat, 14 Dec 2024 22:52:51 GMT Etag: - - W/"083925b09d4956ac797ea0970dfc7f50" + - W/"d0f486f8d8a3d398674f9cd0e555862f" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -58,14 +58,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01J9YQSGDQPHF7WDQDZCRGN8PD","version":"1"}' + - '{"correlation_id":"01JF3NZT2PAFJB8KCN0JA31XHT","version":"1"}' X-Request-Id: - - 01J9YQSGDQPHF7WDQDZCRGN8PD + - 01JF3NZT2PAFJB8KCN0JA31XHT X-Runtime: - - "0.028470" + - "0.012743" status: 200 OK code: 200 - duration: 36.183166ms + duration: 15.592125ms - id: 1 request: proto: HTTP/1.1 @@ -86,29 +86,30 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self + url: http://localhost:8080/api/v4/metadata method: GET response: proto: HTTP/1.1 proto_major: 1 proto_minor: 1 - transfer_encoding: - - chunked + transfer_encoding: [] trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":2,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:46.924Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":2,"last_used_at":"2024-10-11T21:27:47.430Z","active":true,"expires_at":"2025-07-11"}' + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' headers: Cache-Control: - max-age=0, private, must-revalidate Connection: - keep-alive + Content-Length: + - "162" Content-Type: - application/json Date: - - Fri, 11 Oct 2024 21:29:41 GMT + - Sat, 14 Dec 2024 22:52:51 GMT Etag: - - W/"63975863f113ecc7a6091cb11877af93" + - W/"a29dcadce9c4771a1b7b66cc326f6617" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -116,18 +117,17 @@ interactions: Strict-Transport-Security: - max-age=63072000 Vary: - - Accept-Encoding - Origin X-Content-Type-Options: - nosniff X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01J9YQSGFZ23C14W5MYJ6R3RHB","version":"1"}' + - '{"correlation_id":"01JF3NZT3RBFDRW8F8BRAC37TM","version":"1"}' X-Request-Id: - - 01J9YQSGFZ23C14W5MYJ6R3RHB + - 01JF3NZT3RBFDRW8F8BRAC37TM X-Runtime: - - "0.011879" + - "0.014033" status: 200 OK code: 200 - duration: 14.551916ms + duration: 16.534084ms diff --git a/testdata/unit/TestPathConfig_AutoRotate_auto_rotate_token_should_be_false_if_not_specified.yaml b/testdata/unit/TestPathConfig_AutoRotate_auto_rotate_token_should_be_false_if_not_specified.yaml new file mode 100644 index 0000000..01cdc55 --- /dev/null +++ b/testdata/unit/TestPathConfig_AutoRotate_auto_rotate_token_should_be_false_if_not_specified.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:51 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZSWZE75TP04MXB3H1GGW","version":"1"}' + X-Request-Id: + - 01JF3NZSWZE75TP04MXB3H1GGW + X-Runtime: + - "0.011048" + status: 200 OK + code: 200 + duration: 13.485083ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:51 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZSXX5C4YXYQ4B3W8RF66","version":"1"}' + X-Request-Id: + - 01JF3NZSXX5C4YXYQ4B3W8RF66 + X-Runtime: + - "0.013622" + status: 200 OK + code: 200 + duration: 16.376208ms diff --git a/testdata/fixtures/16.11.6/TestPathConfig_deleting_uninitialized_config_should_fail_with_backend_not_configured.yaml b/testdata/unit/TestPathConfig_deleting_uninitialized_config_should_fail_with_backend_not_configured.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestPathConfig_deleting_uninitialized_config_should_fail_with_backend_not_configured.yaml rename to testdata/unit/TestPathConfig_deleting_uninitialized_config_should_fail_with_backend_not_configured.yaml diff --git a/testdata/fixtures/16.11.6/TestPathConfig_initial_config_should_be_empty_fail_with_backend_not_configured.yaml b/testdata/unit/TestPathConfig_initial_config_should_be_empty_fail_with_backend_not_configured.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestPathConfig_initial_config_should_be_empty_fail_with_backend_not_configured.yaml rename to testdata/unit/TestPathConfig_initial_config_should_be_empty_fail_with_backend_not_configured.yaml diff --git a/testdata/fixtures/16.11.6/TestPathConfig_invalid_token.yaml b/testdata/unit/TestPathConfig_invalid_token.yaml similarity index 86% rename from testdata/fixtures/16.11.6/TestPathConfig_invalid_token.yaml rename to testdata/unit/TestPathConfig_invalid_token.yaml index 6477852..fbefa78 100644 --- a/testdata/fixtures/16.11.6/TestPathConfig_invalid_token.yaml +++ b/testdata/unit/TestPathConfig_invalid_token.yaml @@ -42,7 +42,7 @@ interactions: Content-Type: - application/json Date: - - Fri, 11 Oct 2024 20:05:33 GMT + - Sat, 14 Dec 2024 22:52:51 GMT Server: - nginx Vary: @@ -52,11 +52,11 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01J9YJZF6AR8JEMZ5QHRQE3YHJ","version":"1"}' + - '{"correlation_id":"01JF3NZSPMX1T2Z2893ZJYXDE2","version":"1"}' X-Request-Id: - - 01J9YJZF6AR8JEMZ5QHRQE3YHJ + - 01JF3NZSPMX1T2Z2893ZJYXDE2 X-Runtime: - - "0.071607" + - "0.011889" status: 401 Unauthorized code: 401 - duration: 92.349083ms + duration: 14.563917ms diff --git a/testdata/fixtures/16.11.6/TestPathConfig_missing_token_from_the_request.yaml b/testdata/unit/TestPathConfig_missing_token_from_the_request.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestPathConfig_missing_token_from_the_request.yaml rename to testdata/unit/TestPathConfig_missing_token_from_the_request.yaml diff --git a/testdata/fixtures/16.11.6/TestPathConfigList_multiple_configs.yaml b/testdata/unit/TestPathConfig_patch_a_config.yaml similarity index 60% rename from testdata/fixtures/16.11.6/TestPathConfigList_multiple_configs.yaml rename to testdata/unit/TestPathConfig_patch_a_config.yaml index ee4c79d..9df44c8 100644 --- a/testdata/fixtures/16.11.6/TestPathConfigList_multiple_configs.yaml +++ b/testdata/unit/TestPathConfig_patch_a_config.yaml @@ -32,7 +32,7 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-12T16:49:35.175Z","active":true,"expires_at":"2025-07-11"}' + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -41,9 +41,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 12 Oct 2024 16:49:35 GMT + - Sat, 14 Dec 2024 22:52:51 GMT Etag: - - W/"99f9feb16bf70d50ab5be806605fdb66" + - W/"d0f486f8d8a3d398674f9cd0e555862f" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -58,14 +58,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA0T5BBGA18T24N90K9BNJFH","version":"1"}' + - '{"correlation_id":"01JF3NZSR1Z188E5YQQW68118Z","version":"1"}' X-Request-Id: - - 01JA0T5BBGA18T24N90K9BNJFH + - 01JF3NZSR1Z188E5YQQW68118Z X-Runtime: - - "0.101018" + - "0.011715" status: 200 OK code: 200 - duration: 112.323042ms + duration: 14.52125ms - id: 1 request: proto: HTTP/1.1 @@ -86,29 +86,30 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self + url: http://localhost:8080/api/v4/metadata method: GET response: proto: HTTP/1.1 proto_major: 1 proto_minor: 1 - transfer_encoding: - - chunked + transfer_encoding: [] trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":2,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:46.924Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":2,"last_used_at":"2024-10-12T16:49:35.322Z","active":true,"expires_at":"2025-07-11"}' + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' headers: Cache-Control: - max-age=0, private, must-revalidate Connection: - keep-alive + Content-Length: + - "162" Content-Type: - application/json Date: - - Sat, 12 Oct 2024 16:49:35 GMT + - Sat, 14 Dec 2024 22:52:51 GMT Etag: - - W/"94180e5a4364d99a3347ed7e29ce0322" + - W/"a29dcadce9c4771a1b7b66cc326f6617" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -116,21 +117,20 @@ interactions: Strict-Transport-Security: - max-age=63072000 Vary: - - Accept-Encoding - Origin X-Content-Type-Options: - nosniff X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA0T5BJE68NQEBGMS0NCFX1N","version":"1"}' + - '{"correlation_id":"01JF3NZSS1SG7EMV44KN8D2P34","version":"1"}' X-Request-Id: - - 01JA0T5BJE68NQEBGMS0NCFX1N + - 01JF3NZSS1SG7EMV44KN8D2P34 X-Runtime: - - "0.016684" + - "0.018691" status: 200 OK code: 200 - duration: 20.2595ms + duration: 21.31075ms - id: 2 request: proto: HTTP/1.1 @@ -162,7 +162,7 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":3,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:54:07.334Z","scopes":["api","read_api","read_user","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":3,"last_used_at":"2024-10-12T16:49:35.451Z","active":true,"expires_at":"2025-07-11"}' + body: '{"id":2,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:46.924Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":2,"last_used_at":"2024-12-14T22:52:51.011Z","active":true,"expires_at":"2025-07-11"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -171,9 +171,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 12 Oct 2024 16:49:35 GMT + - Sat, 14 Dec 2024 22:52:51 GMT Etag: - - W/"5f0a9ca1c9939def28b759b58bc0319c" + - W/"294f5bcfa91aa421ae25d18cbc532b92" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -188,11 +188,76 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA0T5BKRFT4WZN1QHVBQEDGG","version":"1"}' + - '{"correlation_id":"01JF3NZSTH1AAH2MXZTKEKBS8H","version":"1"}' + X-Request-Id: + - 01JF3NZSTH1AAH2MXZTKEKBS8H + X-Runtime: + - "0.011168" + status: 200 OK + code: 200 + duration: 14.079958ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:51 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZSVGN0CWB3DY4SRN5G8T","version":"1"}' X-Request-Id: - - 01JA0T5BKRFT4WZN1QHVBQEDGG + - 01JF3NZSVGN0CWB3DY4SRN5G8T X-Runtime: - - "0.200017" + - "0.013189" status: 200 OK code: 200 - duration: 202.894ms + duration: 15.497917ms diff --git a/testdata/fixtures/16.11.6/TestPathConfig_patch_a_config_no_backend.yaml b/testdata/unit/TestPathConfig_patch_a_config_no_backend.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestPathConfig_patch_a_config_no_backend.yaml rename to testdata/unit/TestPathConfig_patch_a_config_no_backend.yaml diff --git a/testdata/fixtures/16.11.6/TestPathConfig_patch_a_config_with_no_storage.yaml b/testdata/unit/TestPathConfig_patch_a_config_with_no_storage.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestPathConfig_patch_a_config_with_no_storage.yaml rename to testdata/unit/TestPathConfig_patch_a_config_with_no_storage.yaml diff --git a/testdata/unit/TestPathConfig_write_read_delete_and_read_config.yaml b/testdata/unit/TestPathConfig_write_read_delete_and_read_config.yaml new file mode 100644 index 0000000..3372273 --- /dev/null +++ b/testdata/unit/TestPathConfig_write_read_delete_and_read_config.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:51 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZSKYGZEE33KZ7H81F52E","version":"1"}' + X-Request-Id: + - 01JF3NZSKYGZEE33KZ7H81F52E + X-Runtime: + - "0.011814" + status: 200 OK + code: 200 + duration: 14.264125ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:51 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZSMXEA3BW1J2RZN4AVKK","version":"1"}' + X-Request-Id: + - 01JF3NZSMXEA3BW1J2RZN4AVKK + X-Runtime: + - "0.017671" + status: 200 OK + code: 200 + duration: 20.426875ms diff --git a/testdata/unit/TestPathRolesDeployTokens_group_deploy_fail_to_create_role_due_to_missing_scopes_and_wrong_access_level.yaml b/testdata/unit/TestPathRolesDeployTokens_group_deploy_fail_to_create_role_due_to_missing_scopes_and_wrong_access_level.yaml new file mode 100644 index 0000000..0f59193 --- /dev/null +++ b/testdata/unit/TestPathRolesDeployTokens_group_deploy_fail_to_create_role_due_to_missing_scopes_and_wrong_access_level.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-18T22:21:19.851Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Wed, 18 Dec 2024 22:21:20 GMT + Etag: + - W/"732970146b4df129354958d2506d094d" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFDXRYVW41QQVHGFSX3A6MGY","version":"1"}' + X-Request-Id: + - 01JFDXRYVW41QQVHGFSX3A6MGY + X-Runtime: + - "0.010051" + status: 200 OK + code: 200 + duration: 12.846583ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Wed, 18 Dec 2024 22:21:20 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFDXRYWPSDWY30AWA6N8JV8R","version":"1"}' + X-Request-Id: + - 01JFDXRYWPSDWY30AWA6N8JV8R + X-Runtime: + - "0.011962" + status: 200 OK + code: 200 + duration: 14.395541ms diff --git a/testdata/unit/TestPathRolesDeployTokens_group_deploy_should_create_role_successfully.yaml b/testdata/unit/TestPathRolesDeployTokens_group_deploy_should_create_role_successfully.yaml new file mode 100644 index 0000000..ed66b50 --- /dev/null +++ b/testdata/unit/TestPathRolesDeployTokens_group_deploy_should_create_role_successfully.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-16T22:57:44.821Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Mon, 16 Dec 2024 22:57:45 GMT + Etag: + - W/"2b25f9ca291790ec016611211a903cff" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF8V26GX7XT6ZZQXJZXBN7KB","version":"1"}' + X-Request-Id: + - 01JF8V26GX7XT6ZZQXJZXBN7KB + X-Runtime: + - "0.012816" + status: 200 OK + code: 200 + duration: 15.373708ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Mon, 16 Dec 2024 22:57:45 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF8V26HXG3NQ965QJBK9537J","version":"1"}' + X-Request-Id: + - 01JF8V26HXG3NQ965QJBK9537J + X-Runtime: + - "0.046869" + status: 200 OK + code: 200 + duration: 49.6635ms diff --git a/testdata/unit/TestPathRolesDeployTokens_project_deploy_fail_to_create_role_due_to_missing_scopes_and_wrong_access_level.yaml b/testdata/unit/TestPathRolesDeployTokens_project_deploy_fail_to_create_role_due_to_missing_scopes_and_wrong_access_level.yaml new file mode 100644 index 0000000..4453d01 --- /dev/null +++ b/testdata/unit/TestPathRolesDeployTokens_project_deploy_fail_to_create_role_due_to_missing_scopes_and_wrong_access_level.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-18T22:21:19.851Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Wed, 18 Dec 2024 22:21:19 GMT + Etag: + - W/"732970146b4df129354958d2506d094d" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFDXRYJ3AYW7PJVS8R276WVY","version":"1"}' + X-Request-Id: + - 01JFDXRYJ3AYW7PJVS8R276WVY + X-Runtime: + - "0.089960" + status: 200 OK + code: 200 + duration: 101.010583ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Wed, 18 Dec 2024 22:21:20 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JFDXRYR7JZEM9JWY5DPKH81A","version":"1"}' + X-Request-Id: + - 01JFDXRYR7JZEM9JWY5DPKH81A + X-Runtime: + - "0.019481" + status: 200 OK + code: 200 + duration: 22.080833ms diff --git a/testdata/unit/TestPathRolesDeployTokens_project_deploy_should_create_role_successfully.yaml b/testdata/unit/TestPathRolesDeployTokens_project_deploy_should_create_role_successfully.yaml new file mode 100644 index 0000000..7497d15 --- /dev/null +++ b/testdata/unit/TestPathRolesDeployTokens_project_deploy_should_create_role_successfully.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-16T22:57:44.821Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Mon, 16 Dec 2024 22:57:44 GMT + Etag: + - W/"2b25f9ca291790ec016611211a903cff" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF8V269H0K89TYJMXT6WZ632","version":"1"}' + X-Request-Id: + - 01JF8V269H0K89TYJMXT6WZ632 + X-Runtime: + - "0.082209" + status: 200 OK + code: 200 + duration: 94.892334ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Mon, 16 Dec 2024 22:57:44 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF8V26FBHZF3F0FZ4R1X3GGQ","version":"1"}' + X-Request-Id: + - 01JF8V26FBHZF3F0FZ4R1X3GGQ + X-Runtime: + - "0.019510" + status: 200 OK + code: 200 + duration: 22.600709ms diff --git a/testdata/fixtures/16.11.6/TestPathRolesList_empty_list.yaml b/testdata/unit/TestPathRolesList_empty_list.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestPathRolesList_empty_list.yaml rename to testdata/unit/TestPathRolesList_empty_list.yaml diff --git a/testdata/fixtures/16.11.6/TestWithServiceAccountUserFail_dedicated.yaml b/testdata/unit/TestPathRolesPipelineProjectTrigger_should_fail_if_have_defined_scopes_or_access_level.yaml similarity index 50% rename from testdata/fixtures/16.11.6/TestWithServiceAccountUserFail_dedicated.yaml rename to testdata/unit/TestPathRolesPipelineProjectTrigger_should_fail_if_have_defined_scopes_or_access_level.yaml index f4e203a..8496d56 100644 --- a/testdata/fixtures/16.11.6/TestWithServiceAccountUserFail_dedicated.yaml +++ b/testdata/unit/TestPathRolesPipelineProjectTrigger_should_fail_if_have_defined_scopes_or_access_level.yaml @@ -9,7 +9,7 @@ interactions: content_length: 0 transfer_encoding: [] trailer: {} - host: git.matoski.com + host: localhost:8080 remote_addr: "" request_uri: "" body: "" @@ -21,45 +21,51 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: https://git.matoski.com/api/v4/personal_access_tokens/self + url: http://localhost:8080/api/v4/personal_access_tokens/self method: GET response: - proto: HTTP/2.0 - proto_major: 2 - proto_minor: 0 - transfer_encoding: [] + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked trailer: {} - content_length: 222 - uncompressed: false - body: '{"id":63,"name":"vault-plugin-test-token","revoked":false,"created_at":"2024-10-11T10:43:15.997Z","scopes":["api","admin_mode"],"user_id":2,"last_used_at":"2024-10-11T10:43:27.899Z","active":true,"expires_at":"2024-11-10"}' + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-16T22:16:28.989Z","active":true,"expires_at":"2025-07-11"}' headers: Cache-Control: - max-age=0, private, must-revalidate - Content-Length: - - "222" + Connection: + - keep-alive Content-Type: - application/json Date: - - Fri, 11 Oct 2024 10:44:57 GMT + - Mon, 16 Dec 2024 22:16:29 GMT Etag: - - W/"832ec4c6e9bc777be3e994cf14996de4" + - W/"e1aafb8f3818f86c86de0802724ad3c3" + Referrer-Policy: + - strict-origin-when-cross-origin Server: - nginx + Strict-Transport-Security: + - max-age=63072000 Vary: + - Accept-Encoding - Origin X-Content-Type-Options: - nosniff X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01J9XJWZ5JJBRVZRNHWTG7D8W5","version":"1"}' + - '{"correlation_id":"01JF8RPMG0EYKEXHHZVQPCFX70","version":"1"}' X-Request-Id: - - 01J9XJWZ5JJBRVZRNHWTG7D8W5 + - 01JF8RPMG0EYKEXHHZVQPCFX70 X-Runtime: - - "0.024335" + - "0.163519" status: 200 OK code: 200 - duration: 48.869458ms + duration: 175.04ms - id: 1 request: proto: HTTP/1.1 @@ -68,7 +74,7 @@ interactions: content_length: 0 transfer_encoding: [] trailer: {} - host: git.matoski.com + host: localhost:8080 remote_addr: "" request_uri: "" body: "" @@ -76,36 +82,40 @@ interactions: headers: Accept: - application/json - Content-Type: - - application/json Private-Token: - REPLACED-TOKEN User-Agent: - go-gitlab - url: https://git.matoski.com/api/v4/service_accounts - method: POST + url: http://localhost:8080/api/v4/metadata + method: GET response: - proto: HTTP/2.0 - proto_major: 2 - proto_minor: 0 + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 transfer_encoding: [] trailer: {} - content_length: 102 + content_length: 162 uncompressed: false - body: '{"id":118,"username":"service_account_26e81975eb5ee639c3c9f9f08a31db41","name":"Service account user"}' + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' headers: Cache-Control: - max-age=0, private, must-revalidate + Connection: + - keep-alive Content-Length: - - "102" + - "162" Content-Type: - application/json Date: - - Fri, 11 Oct 2024 10:44:57 GMT + - Mon, 16 Dec 2024 22:16:29 GMT Etag: - - W/"eea68883719d47df4c07df3a7492d32e" + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin Server: - nginx + Strict-Transport-Security: + - max-age=63072000 Vary: - Origin X-Content-Type-Options: @@ -113,11 +123,11 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01J9XJWZ8M5DARCC889BQV919G","version":"1"}' + - '{"correlation_id":"01JF8RPMTT6268RJVYWCBNSGMF","version":"1"}' X-Request-Id: - - 01J9XJWZ8M5DARCC889BQV919G + - 01JF8RPMTT6268RJVYWCBNSGMF X-Runtime: - - "0.125487" - status: 201 Created - code: 201 - duration: 149.508666ms + - "0.035333" + status: 200 OK + code: 200 + duration: 41.311625ms diff --git a/testdata/unit/TestPathRolesPipelineProjectTrigger_ttl_is_optional.yaml b/testdata/unit/TestPathRolesPipelineProjectTrigger_ttl_is_optional.yaml new file mode 100644 index 0000000..51e560e --- /dev/null +++ b/testdata/unit/TestPathRolesPipelineProjectTrigger_ttl_is_optional.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-16T22:30:54.984Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Mon, 16 Dec 2024 22:30:55 GMT + Etag: + - W/"0056e8a2902537f04ebe716f880ea327" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF8SH25Y609ZD6ECMVK9GX7Z","version":"1"}' + X-Request-Id: + - 01JF8SH25Y609ZD6ECMVK9GX7Z + X-Runtime: + - "0.121462" + status: 200 OK + code: 200 + duration: 139.540875ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Mon, 16 Dec 2024 22:30:55 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF8SH2ECDFS4RQ5S4JGMV13Y","version":"1"}' + X-Request-Id: + - 01JF8SH2ECDFS4RQ5S4JGMV13Y + X-Runtime: + - "0.026525" + status: 200 OK + code: 200 + duration: 30.775ms diff --git a/testdata/unit/TestPathRolesPipelineProjectTrigger_ttl_is_set.yaml b/testdata/unit/TestPathRolesPipelineProjectTrigger_ttl_is_set.yaml new file mode 100644 index 0000000..add2ab4 --- /dev/null +++ b/testdata/unit/TestPathRolesPipelineProjectTrigger_ttl_is_set.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-16T22:30:54.984Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Mon, 16 Dec 2024 22:32:36 GMT + Etag: + - W/"0056e8a2902537f04ebe716f880ea327" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF8SM507DZ2N9ZWACW0TX0DQ","version":"1"}' + X-Request-Id: + - 01JF8SM507DZ2N9ZWACW0TX0DQ + X-Runtime: + - "0.026561" + status: 200 OK + code: 200 + duration: 34.512917ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Mon, 16 Dec 2024 22:32:36 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF8SM529VJHYKX7VRVDFG5BD","version":"1"}' + X-Request-Id: + - 01JF8SM529VJHYKX7VRVDFG5BD + X-Runtime: + - "0.010416" + status: 200 OK + code: 200 + duration: 12.684375ms diff --git a/testdata/unit/TestPathRolesTTL_general_ttl_limits_role_TTL__DefaultAccessTokenMaxPossibleTTL.yaml b/testdata/unit/TestPathRolesTTL_general_ttl_limits_role_TTL__DefaultAccessTokenMaxPossibleTTL.yaml new file mode 100644 index 0000000..e2cec89 --- /dev/null +++ b/testdata/unit/TestPathRolesTTL_general_ttl_limits_role_TTL__DefaultAccessTokenMaxPossibleTTL.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZVB8B2YYZ4PNAAT05B5A","version":"1"}' + X-Request-Id: + - 01JF3NZVB8B2YYZ4PNAAT05B5A + X-Runtime: + - "0.010354" + status: 200 OK + code: 200 + duration: 12.631416ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:53 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZVC4VB8W7E3RGP7992XN","version":"1"}' + X-Request-Id: + - 01JF3NZVC4VB8W7E3RGP7992XN + X-Runtime: + - "0.011492" + status: 200 OK + code: 200 + duration: 13.75175ms diff --git a/testdata/unit/TestPathRolesTTL_general_ttl_limits_ttl__maxTTL.yaml b/testdata/unit/TestPathRolesTTL_general_ttl_limits_ttl__maxTTL.yaml new file mode 100644 index 0000000..616d652 --- /dev/null +++ b/testdata/unit/TestPathRolesTTL_general_ttl_limits_ttl__maxTTL.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:53 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZVDFD5E5JJR5PGVQSXGT","version":"1"}' + X-Request-Id: + - 01JF3NZVDFD5E5JJR5PGVQSXGT + X-Runtime: + - "0.010038" + status: 200 OK + code: 200 + duration: 12.279416ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:53 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZVEAD0F0QZYHPVHQNYHG","version":"1"}' + X-Request-Id: + - 01JF3NZVEAD0F0QZYHPVHQNYHG + X-Runtime: + - "0.016740" + status: 200 OK + code: 200 + duration: 19.106875ms diff --git a/testdata/unit/TestPathRolesTTL_gitlab_revokes_the_tokens_ttl__24h.yaml b/testdata/unit/TestPathRolesTTL_gitlab_revokes_the_tokens_ttl__24h.yaml new file mode 100644 index 0000000..5310b39 --- /dev/null +++ b/testdata/unit/TestPathRolesTTL_gitlab_revokes_the_tokens_ttl__24h.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:53 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZVN88T3BEQM4A50YCB2Q","version":"1"}' + X-Request-Id: + - 01JF3NZVN88T3BEQM4A50YCB2Q + X-Runtime: + - "0.012046" + status: 200 OK + code: 200 + duration: 14.647583ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:53 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZVP8RKWG9QGZSGKY25K7","version":"1"}' + X-Request-Id: + - 01JF3NZVP8RKWG9QGZSGKY25K7 + X-Runtime: + - "0.015062" + status: 200 OK + code: 200 + duration: 17.747041ms diff --git a/testdata/fixtures/16.11.6/TestWithServiceAccountUserFail_saas.yaml b/testdata/unit/TestPathRolesTTL_gitlab_revokes_the_tokens_ttl__24h__ttl__DefaultAccessTokenMaxPossibleTTL.yaml similarity index 50% rename from testdata/fixtures/16.11.6/TestWithServiceAccountUserFail_saas.yaml rename to testdata/unit/TestPathRolesTTL_gitlab_revokes_the_tokens_ttl__24h__ttl__DefaultAccessTokenMaxPossibleTTL.yaml index 8601a27..720a6dc 100644 --- a/testdata/fixtures/16.11.6/TestWithServiceAccountUserFail_saas.yaml +++ b/testdata/unit/TestPathRolesTTL_gitlab_revokes_the_tokens_ttl__24h__ttl__DefaultAccessTokenMaxPossibleTTL.yaml @@ -9,7 +9,7 @@ interactions: content_length: 0 transfer_encoding: [] trailer: {} - host: git.matoski.com + host: localhost:8080 remote_addr: "" request_uri: "" body: "" @@ -21,45 +21,51 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: https://git.matoski.com/api/v4/personal_access_tokens/self + url: http://localhost:8080/api/v4/personal_access_tokens/self method: GET response: - proto: HTTP/2.0 - proto_major: 2 - proto_minor: 0 - transfer_encoding: [] + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked trailer: {} - content_length: 222 - uncompressed: false - body: '{"id":63,"name":"vault-plugin-test-token","revoked":false,"created_at":"2024-10-11T10:43:15.997Z","scopes":["api","admin_mode"],"user_id":2,"last_used_at":"2024-10-11T10:43:27.899Z","active":true,"expires_at":"2024-11-10"}' + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' headers: Cache-Control: - max-age=0, private, must-revalidate - Content-Length: - - "222" + Connection: + - keep-alive Content-Type: - application/json Date: - - Fri, 11 Oct 2024 10:44:56 GMT + - Sat, 14 Dec 2024 22:52:53 GMT Etag: - - W/"832ec4c6e9bc777be3e994cf14996de4" + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin Server: - nginx + Strict-Transport-Security: + - max-age=63072000 Vary: + - Accept-Encoding - Origin X-Content-Type-Options: - nosniff X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01J9XJWYNA58ERPX0TND5NXWMW","version":"1"}' + - '{"correlation_id":"01JF3NZVQVR5DD5H7CEHRC0HPF","version":"1"}' X-Request-Id: - - 01J9XJWYNA58ERPX0TND5NXWMW + - 01JF3NZVQVR5DD5H7CEHRC0HPF X-Runtime: - - "0.016153" + - "0.012997" status: 200 OK code: 200 - duration: 125.932083ms + duration: 15.91ms - id: 1 request: proto: HTTP/1.1 @@ -68,7 +74,7 @@ interactions: content_length: 0 transfer_encoding: [] trailer: {} - host: git.matoski.com + host: localhost:8080 remote_addr: "" request_uri: "" body: "" @@ -76,36 +82,40 @@ interactions: headers: Accept: - application/json - Content-Type: - - application/json Private-Token: - REPLACED-TOKEN User-Agent: - go-gitlab - url: https://git.matoski.com/api/v4/service_accounts - method: POST + url: http://localhost:8080/api/v4/metadata + method: GET response: - proto: HTTP/2.0 - proto_major: 2 - proto_minor: 0 + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 transfer_encoding: [] trailer: {} - content_length: 102 + content_length: 162 uncompressed: false - body: '{"id":117,"username":"service_account_856c5b8171b8030d7f71a96cbfdf83ed","name":"Service account user"}' + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' headers: Cache-Control: - max-age=0, private, must-revalidate + Connection: + - keep-alive Content-Length: - - "102" + - "162" Content-Type: - application/json Date: - - Fri, 11 Oct 2024 10:44:56 GMT + - Sat, 14 Dec 2024 22:52:53 GMT Etag: - - W/"863380c54a81dcc6f0cd3ec055c6a403" + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin Server: - nginx + Strict-Transport-Security: + - max-age=63072000 Vary: - Origin X-Content-Type-Options: @@ -113,11 +123,11 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01J9XJWYTJ7B504DWMY5D86JBD","version":"1"}' + - '{"correlation_id":"01JF3NZVS028Q3PFC94X82R60R","version":"1"}' X-Request-Id: - - 01J9XJWYTJ7B504DWMY5D86JBD + - 01JF3NZVS028Q3PFC94X82R60R X-Runtime: - - "0.149888" - status: 201 Created - code: 201 - duration: 173.424125ms + - "0.015841" + status: 200 OK + code: 200 + duration: 19.165833ms diff --git a/testdata/unit/TestPathRolesTTL_vault_revokes_the_token_ttl__1h.yaml b/testdata/unit/TestPathRolesTTL_vault_revokes_the_token_ttl__1h.yaml new file mode 100644 index 0000000..b84108c --- /dev/null +++ b/testdata/unit/TestPathRolesTTL_vault_revokes_the_token_ttl__1h.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:53 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZVJR81E459C844ZBVCQ5","version":"1"}' + X-Request-Id: + - 01JF3NZVJR81E459C844ZBVCQ5 + X-Runtime: + - "0.012204" + status: 200 OK + code: 200 + duration: 14.884125ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:53 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZVKSEJTN3BR31CRX4C79","version":"1"}' + X-Request-Id: + - 01JF3NZVKSEJTN3BR31CRX4C79 + X-Runtime: + - "0.013335" + status: 200 OK + code: 200 + duration: 16.075209ms diff --git a/testdata/unit/TestPathRolesTTL_vault_revokes_the_token_ttl__1h__ttl__DefaultAccessTokenMaxPossibleTTL.yaml b/testdata/unit/TestPathRolesTTL_vault_revokes_the_token_ttl__1h__ttl__DefaultAccessTokenMaxPossibleTTL.yaml new file mode 100644 index 0000000..1f249df --- /dev/null +++ b/testdata/unit/TestPathRolesTTL_vault_revokes_the_token_ttl__1h__ttl__DefaultAccessTokenMaxPossibleTTL.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:53 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZVFZVA388Z5ZVDEYH2A4","version":"1"}' + X-Request-Id: + - 01JF3NZVFZVA388Z5ZVDEYH2A4 + X-Runtime: + - "0.012100" + status: 200 OK + code: 200 + duration: 14.846709ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:53 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZVH1351W262FSFQ1FHE7","version":"1"}' + X-Request-Id: + - 01JF3NZVH1351W262FSFQ1FHE7 + X-Runtime: + - "0.018403" + status: 200 OK + code: 200 + duration: 21.266542ms diff --git a/testdata/unit/TestPathRoles_Group_token_scopes_invalid_scopes.yaml b/testdata/unit/TestPathRoles_Group_token_scopes_invalid_scopes.yaml new file mode 100644 index 0000000..6956de7 --- /dev/null +++ b/testdata/unit/TestPathRoles_Group_token_scopes_invalid_scopes.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZV638MHRTP8S5JH4N81R","version":"1"}' + X-Request-Id: + - 01JF3NZV638MHRTP8S5JH4N81R + X-Runtime: + - "0.011884" + status: 200 OK + code: 200 + duration: 14.63075ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZV73JFV0DP50DYN21H36","version":"1"}' + X-Request-Id: + - 01JF3NZV73JFV0DP50DYN21H36 + X-Runtime: + - "0.013226" + status: 200 OK + code: 200 + duration: 15.815708ms diff --git a/testdata/unit/TestPathRoles_Group_token_scopes_valid_scopes.yaml b/testdata/unit/TestPathRoles_Group_token_scopes_valid_scopes.yaml new file mode 100644 index 0000000..a9fd39a --- /dev/null +++ b/testdata/unit/TestPathRoles_Group_token_scopes_valid_scopes.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZV3H2XDBS7VG6HGPM11S","version":"1"}' + X-Request-Id: + - 01JF3NZV3H2XDBS7VG6HGPM11S + X-Runtime: + - "0.012129" + status: 200 OK + code: 200 + duration: 14.997125ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZV4J7G0H2FZ8PFJFXVDV","version":"1"}' + X-Request-Id: + - 01JF3NZV4J7G0H2FZ8PFJFXVDV + X-Runtime: + - "0.014567" + status: 200 OK + code: 200 + duration: 17.061625ms diff --git a/testdata/unit/TestPathRoles_Personal_token_scopes_invalid_scopes.yaml b/testdata/unit/TestPathRoles_Personal_token_scopes_invalid_scopes.yaml new file mode 100644 index 0000000..6ad2f87 --- /dev/null +++ b/testdata/unit/TestPathRoles_Personal_token_scopes_invalid_scopes.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZV15HV6ZJC1B7R0TEXRY","version":"1"}' + X-Request-Id: + - 01JF3NZV15HV6ZJC1B7R0TEXRY + X-Runtime: + - "0.011040" + status: 200 OK + code: 200 + duration: 13.677584ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZV252JRYQHBZSJEGJMJH","version":"1"}' + X-Request-Id: + - 01JF3NZV252JRYQHBZSJEGJMJH + X-Runtime: + - "0.013123" + status: 200 OK + code: 200 + duration: 15.409417ms diff --git a/testdata/unit/TestPathRoles_Personal_token_scopes_valid_scopes.yaml b/testdata/unit/TestPathRoles_Personal_token_scopes_valid_scopes.yaml new file mode 100644 index 0000000..64b0c60 --- /dev/null +++ b/testdata/unit/TestPathRoles_Personal_token_scopes_valid_scopes.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZTYM09YBCAGV1YTHWCW4","version":"1"}' + X-Request-Id: + - 01JF3NZTYM09YBCAGV1YTHWCW4 + X-Runtime: + - "0.013098" + status: 200 OK + code: 200 + duration: 15.776375ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZTZPJ6NZ5TKWCWN6TB5D","version":"1"}' + X-Request-Id: + - 01JF3NZTZPJ6NZ5TKWCWN6TB5D + X-Runtime: + - "0.014053" + status: 200 OK + code: 200 + duration: 16.808166ms diff --git a/testdata/unit/TestPathRoles_Project_token_scopes_invalid_scopes.yaml b/testdata/unit/TestPathRoles_Project_token_scopes_invalid_scopes.yaml new file mode 100644 index 0000000..e6fc419 --- /dev/null +++ b/testdata/unit/TestPathRoles_Project_token_scopes_invalid_scopes.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZTW7Y15YAXW276FAHW72","version":"1"}' + X-Request-Id: + - 01JF3NZTW7Y15YAXW276FAHW72 + X-Runtime: + - "0.011259" + status: 200 OK + code: 200 + duration: 13.715708ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZTX5GWADK8GDXHPQDSF2","version":"1"}' + X-Request-Id: + - 01JF3NZTX5GWADK8GDXHPQDSF2 + X-Runtime: + - "0.014015" + status: 200 OK + code: 200 + duration: 16.595292ms diff --git a/testdata/unit/TestPathRoles_Project_token_scopes_valid_scopes.yaml b/testdata/unit/TestPathRoles_Project_token_scopes_valid_scopes.yaml new file mode 100644 index 0000000..24e17d6 --- /dev/null +++ b/testdata/unit/TestPathRoles_Project_token_scopes_valid_scopes.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZTT1SW0J07P0J6M0Q6XK","version":"1"}' + X-Request-Id: + - 01JF3NZTT1SW0J07P0J6M0Q6XK + X-Runtime: + - "0.010939" + status: 200 OK + code: 200 + duration: 13.571125ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZTTZSNSB6N2YWTRPW4J1","version":"1"}' + X-Request-Id: + - 01JF3NZTTZSNSB6N2YWTRPW4J1 + X-Runtime: + - "0.012480" + status: 200 OK + code: 200 + duration: 14.846458ms diff --git a/testdata/unit/TestPathRoles_access_level_group_no_access_level_defined.yaml b/testdata/unit/TestPathRoles_access_level_group_no_access_level_defined.yaml new file mode 100644 index 0000000..81a4994 --- /dev/null +++ b/testdata/unit/TestPathRoles_access_level_group_no_access_level_defined.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZTG3DRPQPYMN1V1KJ4VP","version":"1"}' + X-Request-Id: + - 01JF3NZTG3DRPQPYMN1V1KJ4VP + X-Runtime: + - "0.012656" + status: 200 OK + code: 200 + duration: 15.424666ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZTH501WVBRCXGWA00TM8","version":"1"}' + X-Request-Id: + - 01JF3NZTH501WVBRCXGWA00TM8 + X-Runtime: + - "0.014835" + status: 200 OK + code: 200 + duration: 17.763416ms diff --git a/testdata/unit/TestPathRoles_access_level_group_with_access_level_defined.yaml b/testdata/unit/TestPathRoles_access_level_group_with_access_level_defined.yaml new file mode 100644 index 0000000..8ae8c42 --- /dev/null +++ b/testdata/unit/TestPathRoles_access_level_group_with_access_level_defined.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZTJRBHDDVC03RT2G0PW4","version":"1"}' + X-Request-Id: + - 01JF3NZTJRBHDDVC03RT2G0PW4 + X-Runtime: + - "0.011630" + status: 200 OK + code: 200 + duration: 15.108083ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZTKSD2802AE4GC5TQ9MM","version":"1"}' + X-Request-Id: + - 01JF3NZTKSD2802AE4GC5TQ9MM + X-Runtime: + - "0.012759" + status: 200 OK + code: 200 + duration: 15.220083ms diff --git a/testdata/unit/TestPathRoles_access_level_personal_no_access_level_defined.yaml b/testdata/unit/TestPathRoles_access_level_personal_no_access_level_defined.yaml new file mode 100644 index 0000000..d34ff36 --- /dev/null +++ b/testdata/unit/TestPathRoles_access_level_personal_no_access_level_defined.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:51 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZT5TBKKA1CBJ6MTXBJMR","version":"1"}' + X-Request-Id: + - 01JF3NZT5TBKKA1CBJ6MTXBJMR + X-Runtime: + - "0.012765" + status: 200 OK + code: 200 + duration: 15.37775ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:51 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZT6V7BWTFZBPQJB01YRY","version":"1"}' + X-Request-Id: + - 01JF3NZT6V7BWTFZBPQJB01YRY + X-Runtime: + - "0.014215" + status: 200 OK + code: 200 + duration: 16.632291ms diff --git a/testdata/unit/TestPathRoles_access_level_personal_with_access_level_defined.yaml b/testdata/unit/TestPathRoles_access_level_personal_with_access_level_defined.yaml new file mode 100644 index 0000000..d241b63 --- /dev/null +++ b/testdata/unit/TestPathRoles_access_level_personal_with_access_level_defined.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:51 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZT8A79AJ1TQPJA2X14T9","version":"1"}' + X-Request-Id: + - 01JF3NZT8A79AJ1TQPJA2X14T9 + X-Runtime: + - "0.016158" + status: 200 OK + code: 200 + duration: 19.0705ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:51 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZT9KSVJ1Z7TX6SCSTJ3G","version":"1"}' + X-Request-Id: + - 01JF3NZT9KSVJ1Z7TX6SCSTJ3G + X-Runtime: + - "0.014103" + status: 200 OK + code: 200 + duration: 17.147833ms diff --git a/testdata/unit/TestPathRoles_access_level_project_no_access_level_defined.yaml b/testdata/unit/TestPathRoles_access_level_project_no_access_level_defined.yaml new file mode 100644 index 0000000..7b92de8 --- /dev/null +++ b/testdata/unit/TestPathRoles_access_level_project_no_access_level_defined.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:51 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZTB4WKDQ9F9J4VNDXNW5","version":"1"}' + X-Request-Id: + - 01JF3NZTB4WKDQ9F9J4VNDXNW5 + X-Runtime: + - "0.011550" + status: 200 OK + code: 200 + duration: 14.314667ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:51 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZTC3R962QCFCH6ATZ06J","version":"1"}' + X-Request-Id: + - 01JF3NZTC3R962QCFCH6ATZ06J + X-Runtime: + - "0.015101" + status: 200 OK + code: 200 + duration: 17.567375ms diff --git a/testdata/unit/TestPathRoles_access_level_project_with_access_level_defined.yaml b/testdata/unit/TestPathRoles_access_level_project_with_access_level_defined.yaml new file mode 100644 index 0000000..9337e85 --- /dev/null +++ b/testdata/unit/TestPathRoles_access_level_project_with_access_level_defined.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZTDJTPH7BNB430VSZSP7","version":"1"}' + X-Request-Id: + - 01JF3NZTDJTPH7BNB430VSZSP7 + X-Runtime: + - "0.012251" + status: 200 OK + code: 200 + duration: 14.940792ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZTEJGEHJGSCH2GD1KDAD","version":"1"}' + X-Request-Id: + - 01JF3NZTEJGEHJGSCH2GD1KDAD + X-Runtime: + - "0.013922" + status: 200 OK + code: 200 + duration: 16.585125ms diff --git a/testdata/unit/TestPathRoles_create_with_missing_parameters.yaml b/testdata/unit/TestPathRoles_create_with_missing_parameters.yaml new file mode 100644 index 0000000..4b0578f --- /dev/null +++ b/testdata/unit/TestPathRoles_create_with_missing_parameters.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZTN6THBMV8SWHWWB2NA9","version":"1"}' + X-Request-Id: + - 01JF3NZTN6THBMV8SWHWWB2NA9 + X-Runtime: + - "0.010895" + status: 200 OK + code: 200 + duration: 13.1345ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZTP30CDRDYD2KPFGMYF6","version":"1"}' + X-Request-Id: + - 01JF3NZTP30CDRDYD2KPFGMYF6 + X-Runtime: + - "0.013315" + status: 200 OK + code: 200 + duration: 15.925958ms diff --git a/testdata/fixtures/16.11.6/TestPathRoles_delete_non_existing_role.yaml b/testdata/unit/TestPathRoles_delete_non_existing_role.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestPathRoles_delete_non_existing_role.yaml rename to testdata/unit/TestPathRoles_delete_non_existing_role.yaml diff --git a/testdata/unit/TestPathRoles_full_flow_check_roles.yaml b/testdata/unit/TestPathRoles_full_flow_check_roles.yaml new file mode 100644 index 0000000..6211bf3 --- /dev/null +++ b/testdata/unit/TestPathRoles_full_flow_check_roles.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZV8KGCYK10A72DKF9A6K","version":"1"}' + X-Request-Id: + - 01JF3NZV8KGCYK10A72DKF9A6K + X-Runtime: + - "0.013757" + status: 200 OK + code: 200 + duration: 16.588709ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZV9Q0FDAT6B8ACCS8QCX","version":"1"}' + X-Request-Id: + - 01JF3NZV9Q0FDAT6B8ACCS8QCX + X-Runtime: + - "0.014493" + status: 200 OK + code: 200 + duration: 17.193583ms diff --git a/testdata/unit/TestPathRoles_invalid_name_template.yaml b/testdata/unit/TestPathRoles_invalid_name_template.yaml new file mode 100644 index 0000000..b96f55f --- /dev/null +++ b/testdata/unit/TestPathRoles_invalid_name_template.yaml @@ -0,0 +1,133 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZTQHQPGT46K12RFTW7YC","version":"1"}' + X-Request-Id: + - 01JF3NZTQHQPGT46K12RFTW7YC + X-Runtime: + - "0.011644" + status: 200 OK + code: 200 + duration: 14.367375ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:52 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZTRGK3JJT61E5C9EGBD3","version":"1"}' + X-Request-Id: + - 01JF3NZTRGK3JJT61E5C9EGBD3 + X-Runtime: + - "0.013846" + status: 200 OK + code: 200 + duration: 16.573708ms diff --git a/testdata/fixtures/16.11.6/TestPathRoles_update_handler_existence_check.yaml b/testdata/unit/TestPathRoles_update_handler_existence_check.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestPathRoles_update_handler_existence_check.yaml rename to testdata/unit/TestPathRoles_update_handler_existence_check.yaml diff --git a/testdata/fixtures/16.11.6/TestPathRoles_we_get_error_if_backend_is_not_set_up_during_role_write.yaml b/testdata/unit/TestPathRoles_we_get_error_if_backend_is_not_set_up_during_role_write.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestPathRoles_we_get_error_if_backend_is_not_set_up_during_role_write.yaml rename to testdata/unit/TestPathRoles_we_get_error_if_backend_is_not_set_up_during_role_write.yaml diff --git a/testdata/fixtures/16.11.6/TestPathTokenRolesMultipleConfigs.yaml b/testdata/unit/TestPathTokenRolesMultipleConfigs.yaml similarity index 69% rename from testdata/fixtures/16.11.6/TestPathTokenRolesMultipleConfigs.yaml rename to testdata/unit/TestPathTokenRolesMultipleConfigs.yaml index 57d019f..1183e04 100644 --- a/testdata/fixtures/16.11.6/TestPathTokenRolesMultipleConfigs.yaml +++ b/testdata/unit/TestPathTokenRolesMultipleConfigs.yaml @@ -32,7 +32,7 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-10-13T12:43:40.595Z","active":true,"expires_at":"2025-07-11"}' + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -41,9 +41,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:43:40 GMT + - Sat, 14 Dec 2024 22:52:53 GMT Etag: - - W/"a2681e49606401ce3a486f2f48b5afd3" + - W/"d0f486f8d8a3d398674f9cd0e555862f" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -58,14 +58,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YFSMC2PQ4AM9T2KZ2C0ZS","version":"1"}' + - '{"correlation_id":"01JF3NZVTMVEQD51EJXHEMD629","version":"1"}' X-Request-Id: - - 01JA2YFSMC2PQ4AM9T2KZ2C0ZS + - 01JF3NZVTMVEQD51EJXHEMD629 X-Runtime: - - "0.045528" + - "0.013731" status: 200 OK code: 200 - duration: 54.092166ms + duration: 17.6165ms - id: 1 request: proto: HTTP/1.1 @@ -86,29 +86,30 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/self + url: http://localhost:8080/api/v4/metadata method: GET response: proto: HTTP/1.1 proto_major: 1 proto_minor: 1 - transfer_encoding: - - chunked + transfer_encoding: [] trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":2,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:46.924Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":2,"last_used_at":"2024-10-13T12:38:35.438Z","active":true,"expires_at":"2025-07-11"}' + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' headers: Cache-Control: - max-age=0, private, must-revalidate Connection: - keep-alive + Content-Length: + - "162" Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:43:40 GMT + - Sat, 14 Dec 2024 22:52:53 GMT Etag: - - W/"c622b38f506045ed3c55134cf337e4f5" + - W/"a29dcadce9c4771a1b7b66cc326f6617" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -116,21 +117,20 @@ interactions: Strict-Transport-Security: - max-age=63072000 Vary: - - Accept-Encoding - Origin X-Content-Type-Options: - nosniff X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YFSQQCVGM4EYP7Q5JGZWD","version":"1"}' + - '{"correlation_id":"01JF3NZVVTSTRKFSDHHGS7GD7Y","version":"1"}' X-Request-Id: - - 01JA2YFSQQCVGM4EYP7Q5JGZWD + - 01JF3NZVVTSTRKFSDHHGS7GD7Y X-Runtime: - - "0.016065" + - "0.015178" status: 200 OK code: 200 - duration: 19.878375ms + duration: 18.554541ms - id: 2 request: proto: HTTP/1.1 @@ -162,7 +162,7 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":3,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:54:07.334Z","scopes":["api","read_api","read_user","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":3,"last_used_at":"2024-10-13T12:38:38.421Z","active":true,"expires_at":"2025-07-11"}' + body: '{"id":2,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:46.924Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":2,"last_used_at":"2024-12-14T22:52:51.011Z","active":true,"expires_at":"2025-07-11"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -171,9 +171,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:43:40 GMT + - Sat, 14 Dec 2024 22:52:53 GMT Etag: - - W/"cc5eb58605b15a9d07c4de17559ec98c" + - W/"294f5bcfa91aa421ae25d18cbc532b92" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -188,14 +188,14 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YFSS1HZRQYN48KGDZXHPH","version":"1"}' + - '{"correlation_id":"01JF3NZVX26DD4XQDSGXSMXC26","version":"1"}' X-Request-Id: - - 01JA2YFSS1HZRQYN48KGDZXHPH + - 01JF3NZVX26DD4XQDSGXSMXC26 X-Runtime: - - "0.012770" + - "0.012803" status: 200 OK code: 200 - duration: 15.69025ms + duration: 15.998083ms - id: 3 request: proto: HTTP/1.1 @@ -216,7 +216,72 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: http://localhost:8080/api/v4/users?username=root + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:53 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZVY5HFHZVB8V0V27ZR68","version":"1"}' + X-Request-Id: + - 01JF3NZVY5HFHZVB8V0V27ZR68 + X-Runtime: + - "0.014473" + status: 200 OK + code: 200 + duration: 16.987625ms + - id: 4 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self method: GET response: proto: HTTP/1.1 @@ -227,7 +292,7 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '[{"id":1,"username":"root","name":"Administrator","state":"active","locked":false,"avatar_url":"https://www.gravatar.com/avatar/258d8dc916db8cea2cafb6c3cd0cb0246efe061421dbd83ec3a350428cabda4f?s=80\u0026d=identicon","web_url":"http://1b25ef517b98/root","created_at":"2024-07-11T18:51:40.925Z","bio":"","location":"","public_email":null,"skype":"","linkedin":"","twitter":"","discord":"","website_url":"","organization":"","job_title":"","pronouns":null,"bot":false,"work_information":null,"local_time":null,"last_sign_in_at":"2024-07-11T18:54:22.894Z","confirmed_at":"2024-07-11T18:51:40.831Z","last_activity_on":"2024-10-13","email":"admin@example.com","theme_id":3,"color_scheme_id":1,"projects_limit":100000,"current_sign_in_at":"2024-10-11T07:48:06.781Z","identities":[],"can_create_group":true,"can_create_project":true,"two_factor_enabled":false,"external":false,"private_profile":false,"commit_email":"admin@example.com","is_admin":true,"note":null,"namespace_id":1,"created_by":null,"email_reset_offered_at":null}]' + body: '{"id":3,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:54:07.334Z","scopes":["api","read_api","read_user","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":3,"last_used_at":"2024-12-14T22:52:51.087Z","active":true,"expires_at":"2025-07-11"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -236,11 +301,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:43:40 GMT + - Sat, 14 Dec 2024 22:52:53 GMT Etag: - - W/"ff413862d7bbfd875444c622c4921e00" - Link: - - ; rel="first", ; rel="last" + - W/"8f85f2050c9c993f8120af90dfd869ae" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -255,38 +318,91 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YFST3PJY4P71HZHAMSM80","version":"1"}' - X-Next-Page: - - "" - X-Page: - - "1" - X-Per-Page: - - "20" - X-Prev-Page: - - "" + - '{"correlation_id":"01JF3NZVZ993GSPV5V8H7FYHYZ","version":"1"}' X-Request-Id: - - 01JA2YFST3PJY4P71HZHAMSM80 + - 01JF3NZVZ993GSPV5V8H7FYHYZ X-Runtime: - - "0.084888" - X-Total: - - "1" - X-Total-Pages: - - "1" + - "0.010777" status: 200 OK code: 200 - duration: 87.534208ms - - id: 4 + duration: 13.27475ms + - id: 5 request: proto: HTTP/1.1 proto_major: 1 proto_minor: 1 - content_length: 128 + content_length: 0 transfer_encoding: [] trailer: {} host: localhost:8080 remote_addr: "" request_uri: "" - body: '{"name":"root-root-root-root-personal","expires_at":"2024-12-14","scopes":["read_service_ping","read_user","sudo","admin_mode"]}' + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:53 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZW071YBGWGDTDJ82694F","version":"1"}' + X-Request-Id: + - 01JF3NZW071YBGWGDTDJ82694F + X-Runtime: + - "0.012443" + status: 200 OK + code: 200 + duration: 14.775041ms + - id: 6 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 107 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: '{"name":"example-normal-example-normal-group","scopes":["api"],"access_level":10,"expires_at":"2025-03-14"}' form: {} headers: Accept: @@ -297,7 +413,7 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: http://localhost:8080/api/v4/users/1/personal_access_tokens + url: http://localhost:8080/api/v4/groups/example/access_tokens method: POST response: proto: HTTP/1.1 @@ -305,22 +421,22 @@ interactions: proto_minor: 1 transfer_encoding: [] trailer: {} - content_length: 275 + content_length: 254 uncompressed: false - body: '{"id":51,"name":"root-root-root-root-personal","revoked":false,"created_at":"2024-10-13T12:43:40.941Z","scopes":["read_service_ping","read_user","sudo","admin_mode"],"user_id":1,"last_used_at":null,"active":true,"expires_at":"2024-12-14","token":"glpat-MntUZ7te5Ef_xqsBsNkP"}' + body: '{"id":47,"name":"example-normal-example-normal-group","revoked":false,"created_at":"2024-12-14T22:52:53.913Z","scopes":["api"],"user_id":6,"last_used_at":null,"active":true,"expires_at":"2025-03-14","access_level":10,"token":"glpat-yUrZQ3oc5RDDPwVVJ-i5"}' headers: Cache-Control: - max-age=0, private, must-revalidate Connection: - keep-alive Content-Length: - - "275" + - "254" Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:43:40 GMT + - Sat, 14 Dec 2024 22:52:53 GMT Etag: - - W/"801bb4a332e474e763b05d14d269765b" + - W/"7ff887e8a30d51e6d477d9923990b253" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -334,15 +450,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YFSZP6CBNZV6REZAF02AP","version":"1"}' + - '{"correlation_id":"01JF3NZW19N3W2C556VJ6SQ2N7","version":"1"}' X-Request-Id: - - 01JA2YFSZP6CBNZV6REZAF02AP + - 01JF3NZW19N3W2C556VJ6SQ2N7 X-Runtime: - - "0.071790" + - "0.245098" status: 201 Created code: 201 - duration: 75.007333ms - - id: 5 + duration: 247.793917ms + - id: 7 request: proto: HTTP/1.1 proto_major: 1 @@ -368,23 +484,24 @@ interactions: proto: HTTP/1.1 proto_major: 1 proto_minor: 1 - transfer_encoding: - - chunked + transfer_encoding: [] trailer: {} - content_length: -1 - uncompressed: true - body: '{"id":51,"name":"root-root-root-root-personal","revoked":false,"created_at":"2024-10-13T12:43:40.941Z","scopes":["read_service_ping","read_user","sudo","admin_mode"],"user_id":1,"last_used_at":"2024-10-13T12:43:41.078Z","active":true,"expires_at":"2024-12-14"}' + content_length: 221 + uncompressed: false + body: '{"id":47,"name":"example-normal-example-normal-group","revoked":false,"created_at":"2024-12-14T22:52:53.913Z","scopes":["api"],"user_id":6,"last_used_at":"2024-12-14T22:52:54.199Z","active":true,"expires_at":"2025-03-14"}' headers: Cache-Control: - max-age=0, private, must-revalidate Connection: - keep-alive + Content-Length: + - "221" Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:43:41 GMT + - Sat, 14 Dec 2024 22:52:54 GMT Etag: - - W/"298da0a0f31fe9fd40c613ce3b5ff013" + - W/"a32b90dd526631164290a3b2d19a0ef9" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -392,22 +509,21 @@ interactions: Strict-Transport-Security: - max-age=63072000 Vary: - - Accept-Encoding - Origin X-Content-Type-Options: - nosniff X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YFT4EH2GXXBQPDZ0422KW","version":"1"}' + - '{"correlation_id":"01JF3NZWGZJKDCRNMAAXWGEPSF","version":"1"}' X-Request-Id: - - 01JA2YFT4EH2GXXBQPDZ0422KW + - 01JF3NZWGZJKDCRNMAAXWGEPSF X-Runtime: - - "0.013352" + - "0.048140" status: 200 OK code: 200 - duration: 16.235708ms - - id: 6 + duration: 56.611458ms + - id: 8 request: proto: HTTP/1.1 proto_major: 1 @@ -427,7 +543,7 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/51 + url: http://localhost:8080/api/v4/groups/example/access_tokens/47 method: DELETE response: proto: HTTP/1.1 @@ -444,7 +560,7 @@ interactions: Connection: - keep-alive Date: - - Sun, 13 Oct 2024 12:43:41 GMT + - Sat, 14 Dec 2024 22:52:54 GMT Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -458,15 +574,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YFT5F783F5XBTPV0J67GQ","version":"1"}' + - '{"correlation_id":"01JF3NZWMGJP820EZKX4FFCZW9","version":"1"}' X-Request-Id: - - 01JA2YFT5F783F5XBTPV0J67GQ + - 01JF3NZWMGJP820EZKX4FFCZW9 X-Runtime: - - "0.028244" + - "0.079417" status: 204 No Content code: 204 - duration: 30.500625ms - - id: 7 + duration: 82.586209ms + - id: 9 request: proto: HTTP/1.1 proto_major: 1 @@ -486,7 +602,7 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: http://localhost:8080/api/v4/users?username=normal-user + url: http://localhost:8080/api/v4/users?username=root method: GET response: proto: HTTP/1.1 @@ -497,7 +613,7 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '[{"id":3,"username":"normal-user","name":"Normal User","state":"active","locked":false,"avatar_url":"https://www.gravatar.com/avatar/30ee3a8ed91c220db688a3bde115c203763b4281374c40835f69168786a590af?s=80\u0026d=identicon","web_url":"http://1b25ef517b98/normal-user","created_at":"2024-07-11T18:53:06.485Z","bio":"","location":"","public_email":null,"skype":"","linkedin":"","twitter":"","discord":"","website_url":"","organization":"","job_title":"","pronouns":null,"bot":false,"work_information":null,"followers":0,"following":0,"is_followed":false,"local_time":null,"last_sign_in_at":null,"confirmed_at":"2024-07-11T18:53:06.412Z","last_activity_on":"2024-10-13","email":"normal@local","theme_id":3,"color_scheme_id":1,"projects_limit":100000,"current_sign_in_at":null,"identities":[],"can_create_group":true,"can_create_project":true,"two_factor_enabled":false,"external":false,"private_profile":false,"commit_email":"normal@local","is_admin":false,"note":null,"namespace_id":3,"created_by":null,"email_reset_offered_at":null}]' + body: '[{"id":1,"username":"root","name":"Administrator","state":"active","locked":false,"avatar_url":"https://www.gravatar.com/avatar/258d8dc916db8cea2cafb6c3cd0cb0246efe061421dbd83ec3a350428cabda4f?s=80\u0026d=identicon","web_url":"http://7b1d891ab6bb/root","created_at":"2024-07-11T18:51:40.925Z","bio":"","location":"","public_email":null,"skype":"","linkedin":"","twitter":"","discord":"","website_url":"","organization":"","job_title":"","pronouns":null,"bot":false,"work_information":null,"local_time":null,"last_sign_in_at":"2024-07-11T18:54:22.894Z","confirmed_at":"2024-07-11T18:51:40.831Z","last_activity_on":"2024-12-14","email":"admin@example.com","theme_id":3,"color_scheme_id":1,"projects_limit":100000,"current_sign_in_at":"2024-10-11T07:48:06.781Z","identities":[],"can_create_group":true,"can_create_project":true,"two_factor_enabled":false,"external":false,"private_profile":false,"commit_email":"admin@example.com","is_admin":true,"note":null,"namespace_id":1,"created_by":null,"email_reset_offered_at":null}]' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -506,11 +622,11 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:43:41 GMT + - Sat, 14 Dec 2024 22:52:54 GMT Etag: - - W/"b764e144f065825c8e49ce5dd2ae7cfd" + - W/"0b39ec89d1dbe684694e4d5520a69eca" Link: - - ; rel="first", ; rel="last" + - ; rel="first", ; rel="last" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -525,7 +641,7 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YFT7ETZWTFB1G30G713GD","version":"1"}' + - '{"correlation_id":"01JF3NZWSV8W4RKC6DPRBGQB1B","version":"1"}' X-Next-Page: - "" X-Page: @@ -535,28 +651,28 @@ interactions: X-Prev-Page: - "" X-Request-Id: - - 01JA2YFT7ETZWTFB1G30G713GD + - 01JF3NZWSV8W4RKC6DPRBGQB1B X-Runtime: - - "0.028064" + - "0.118617" X-Total: - "1" X-Total-Pages: - "1" status: 200 OK code: 200 - duration: 31.118833ms - - id: 8 + duration: 122.077ms + - id: 10 request: proto: HTTP/1.1 proto_major: 1 proto_minor: 1 - content_length: 142 + content_length: 128 transfer_encoding: [] trailer: {} host: localhost:8080 remote_addr: "" request_uri: "" - body: '{"name":"normal-user-root-normal-user-root-personal","expires_at":"2024-12-14","scopes":["read_service_ping","read_user","sudo","admin_mode"]}' + body: '{"name":"root-root-root-root-personal","expires_at":"2025-03-14","scopes":["read_service_ping","read_user","sudo","admin_mode"]}' form: {} headers: Accept: @@ -567,7 +683,7 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: http://localhost:8080/api/v4/users/3/personal_access_tokens + url: http://localhost:8080/api/v4/users/1/personal_access_tokens method: POST response: proto: HTTP/1.1 @@ -575,22 +691,22 @@ interactions: proto_minor: 1 transfer_encoding: [] trailer: {} - content_length: 289 + content_length: 275 uncompressed: false - body: '{"id":52,"name":"normal-user-root-normal-user-root-personal","revoked":false,"created_at":"2024-10-13T12:43:41.243Z","scopes":["read_service_ping","read_user","sudo","admin_mode"],"user_id":3,"last_used_at":null,"active":true,"expires_at":"2024-12-14","token":"glpat-mA7qejyEN4rHppGQzY1E"}' + body: '{"id":48,"name":"root-root-root-root-personal","revoked":false,"created_at":"2024-12-14T22:52:54.734Z","scopes":["read_service_ping","read_user","sudo","admin_mode"],"user_id":1,"last_used_at":null,"active":true,"expires_at":"2025-03-14","token":"glpat-keRGT2khRobRrzzTmL1F"}' headers: Cache-Control: - max-age=0, private, must-revalidate Connection: - keep-alive Content-Length: - - "289" + - "275" Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:43:41 GMT + - Sat, 14 Dec 2024 22:52:54 GMT Etag: - - W/"26606696492e05e6e81247d59bce2361" + - W/"c6a5250e7593bbabe88216e02354e1b4" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -604,15 +720,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YFT9EGVVA05A2MN5QFBAG","version":"1"}' + - '{"correlation_id":"01JF3NZX1MW4CKE6GHK68PA2MM","version":"1"}' X-Request-Id: - - 01JA2YFT9EGVVA05A2MN5QFBAG + - 01JF3NZX1MW4CKE6GHK68PA2MM X-Runtime: - - "0.021013" + - "0.032792" status: 201 Created code: 201 - duration: 23.434375ms - - id: 9 + duration: 36.39625ms + - id: 11 request: proto: HTTP/1.1 proto_major: 1 @@ -643,7 +759,7 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":52,"name":"normal-user-root-normal-user-root-personal","revoked":false,"created_at":"2024-10-13T12:43:41.243Z","scopes":["read_service_ping","read_user","sudo","admin_mode"],"user_id":3,"last_used_at":"2024-10-13T12:43:41.286Z","active":true,"expires_at":"2024-12-14"}' + body: '{"id":48,"name":"root-root-root-root-personal","revoked":false,"created_at":"2024-12-14T22:52:54.734Z","scopes":["read_service_ping","read_user","sudo","admin_mode"],"user_id":1,"last_used_at":"2024-12-14T22:52:54.791Z","active":true,"expires_at":"2025-03-14"}' headers: Cache-Control: - max-age=0, private, must-revalidate @@ -652,9 +768,9 @@ interactions: Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:43:41 GMT + - Sat, 14 Dec 2024 22:52:54 GMT Etag: - - W/"2c1b0be47cbc8c3a3e2eb8ef34054166" + - W/"9caf5c68580637662f6d96d2625c3cb7" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -669,15 +785,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YFTAYY77BCJBM0MTQMMQD","version":"1"}' + - '{"correlation_id":"01JF3NZX3ZWAP7J5V8D95RGZJA","version":"1"}' X-Request-Id: - - 01JA2YFTAYY77BCJBM0MTQMMQD + - 01JF3NZX3ZWAP7J5V8D95RGZJA X-Runtime: - - "0.012138" + - "0.012550" status: 200 OK code: 200 - duration: 14.382292ms - - id: 10 + duration: 15.235292ms + - id: 12 request: proto: HTTP/1.1 proto_major: 1 @@ -697,7 +813,7 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: http://localhost:8080/api/v4/personal_access_tokens/52 + url: http://localhost:8080/api/v4/personal_access_tokens/48 method: DELETE response: proto: HTTP/1.1 @@ -714,7 +830,7 @@ interactions: Connection: - keep-alive Date: - - Sun, 13 Oct 2024 12:43:41 GMT + - Sat, 14 Dec 2024 22:52:54 GMT Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -728,26 +844,105 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YFTBXZJTBPAAJD0BMAK74","version":"1"}' + - '{"correlation_id":"01JF3NZX501W716QW407R9FF6X","version":"1"}' X-Request-Id: - - 01JA2YFTBXZJTBPAAJD0BMAK74 + - 01JF3NZX501W716QW407R9FF6X X-Runtime: - - "0.034234" + - "0.055486" status: 204 No Content code: 204 - duration: 36.559459ms - - id: 11 + duration: 58.212334ms + - id: 13 request: proto: HTTP/1.1 proto_major: 1 proto_minor: 1 - content_length: 123 + content_length: 0 transfer_encoding: [] trailer: {} host: localhost:8080 remote_addr: "" request_uri: "" - body: '{"name":"example/example-admin-example-example-admin-project","scopes":["api"],"access_level":10,"expires_at":"2024-12-14"}' + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/users?username=normal-user + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '[{"id":3,"username":"normal-user","name":"Normal User","state":"active","locked":false,"avatar_url":"https://www.gravatar.com/avatar/30ee3a8ed91c220db688a3bde115c203763b4281374c40835f69168786a590af?s=80\u0026d=identicon","web_url":"http://7b1d891ab6bb/normal-user","created_at":"2024-07-11T18:53:06.485Z","bio":"","location":"","public_email":null,"skype":"","linkedin":"","twitter":"","discord":"","website_url":"","organization":"","job_title":"","pronouns":null,"bot":false,"work_information":null,"followers":0,"following":0,"is_followed":false,"local_time":null,"last_sign_in_at":null,"confirmed_at":"2024-07-11T18:53:06.412Z","last_activity_on":"2024-12-14","email":"normal@local","theme_id":3,"color_scheme_id":1,"projects_limit":100000,"current_sign_in_at":null,"identities":[],"can_create_group":true,"can_create_project":true,"two_factor_enabled":false,"external":false,"private_profile":false,"commit_email":"normal@local","is_admin":false,"note":null,"namespace_id":3,"created_by":null,"email_reset_offered_at":null}]' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:54 GMT + Etag: + - W/"c7beb2de3ce9e367a4275f072f8d6ae0" + Link: + - ; rel="first", ; rel="last" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZX8SAED022Q9NG4AR2Z0","version":"1"}' + X-Next-Page: + - "" + X-Page: + - "1" + X-Per-Page: + - "20" + X-Prev-Page: + - "" + X-Request-Id: + - 01JF3NZX8SAED022Q9NG4AR2Z0 + X-Runtime: + - "0.035013" + X-Total: + - "1" + X-Total-Pages: + - "1" + status: 200 OK + code: 200 + duration: 38.177417ms + - id: 14 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 142 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: '{"name":"normal-user-root-normal-user-root-personal","expires_at":"2025-03-14","scopes":["read_service_ping","read_user","sudo","admin_mode"]}' form: {} headers: Accept: @@ -758,7 +953,7 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: http://localhost:8080/api/v4/projects/example%2Fexample/access_tokens + url: http://localhost:8080/api/v4/users/3/personal_access_tokens method: POST response: proto: HTTP/1.1 @@ -766,22 +961,22 @@ interactions: proto_minor: 1 transfer_encoding: [] trailer: {} - content_length: 270 + content_length: 289 uncompressed: false - body: '{"id":53,"name":"example/example-admin-example-example-admin-project","revoked":false,"created_at":"2024-10-13T12:43:41.575Z","scopes":["api"],"user_id":9,"last_used_at":null,"active":true,"expires_at":"2024-12-14","access_level":10,"token":"glpat-FrWUFNyF4B2CN661jY7P"}' + body: '{"id":49,"name":"normal-user-root-normal-user-root-personal","revoked":false,"created_at":"2024-12-14T22:52:55.031Z","scopes":["read_service_ping","read_user","sudo","admin_mode"],"user_id":3,"last_used_at":null,"active":true,"expires_at":"2025-03-14","token":"glpat-L9JVkqyNfHssXtKH4mEc"}' headers: Cache-Control: - max-age=0, private, must-revalidate Connection: - keep-alive Content-Length: - - "270" + - "289" Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:43:41 GMT + - Sat, 14 Dec 2024 22:52:55 GMT Etag: - - W/"c2e29e7aa015f424184f0d99ecee5ee3" + - W/"9aba188b25fa34b5cd3ca01bf898bad9" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -795,15 +990,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YFTE8CGGN8RERAARGQGYY","version":"1"}' + - '{"correlation_id":"01JF3NZXB95YB2KMQZRW66TNPW","version":"1"}' X-Request-Id: - - 01JA2YFTE8CGGN8RERAARGQGYY + - 01JF3NZXB95YB2KMQZRW66TNPW X-Runtime: - - "0.196413" + - "0.020598" status: 201 Created code: 201 - duration: 199.320125ms - - id: 12 + duration: 23.607167ms + - id: 15 request: proto: HTTP/1.1 proto_major: 1 @@ -829,24 +1024,23 @@ interactions: proto: HTTP/1.1 proto_major: 1 proto_minor: 1 - transfer_encoding: [] + transfer_encoding: + - chunked trailer: {} - content_length: 237 - uncompressed: false - body: '{"id":53,"name":"example/example-admin-example-example-admin-project","revoked":false,"created_at":"2024-10-13T12:43:41.575Z","scopes":["api"],"user_id":9,"last_used_at":"2024-10-13T12:43:41.819Z","active":true,"expires_at":"2024-12-14"}' + content_length: -1 + uncompressed: true + body: '{"id":49,"name":"normal-user-root-normal-user-root-personal","revoked":false,"created_at":"2024-12-14T22:52:55.031Z","scopes":["read_service_ping","read_user","sudo","admin_mode"],"user_id":3,"last_used_at":"2024-12-14T22:52:55.075Z","active":true,"expires_at":"2025-03-14"}' headers: Cache-Control: - max-age=0, private, must-revalidate Connection: - keep-alive - Content-Length: - - "237" Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:43:41 GMT + - Sat, 14 Dec 2024 22:52:55 GMT Etag: - - W/"f75d0aea81e2726439d699b04edb6c44" + - W/"c6807f39fee9f2eead243d7723e82938" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -854,21 +1048,22 @@ interactions: Strict-Transport-Security: - max-age=63072000 Vary: + - Accept-Encoding - Origin X-Content-Type-Options: - nosniff X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YFTTSQN55R5X3X7Q3T6K3","version":"1"}' + - '{"correlation_id":"01JF3NZXCT3AZM4MG9MCMMASN8","version":"1"}' X-Request-Id: - - 01JA2YFTTSQN55R5X3X7Q3T6K3 + - 01JF3NZXCT3AZM4MG9MCMMASN8 X-Runtime: - - "0.045431" + - "0.012312" status: 200 OK code: 200 - duration: 50.847834ms - - id: 13 + duration: 14.982666ms + - id: 16 request: proto: HTTP/1.1 proto_major: 1 @@ -888,7 +1083,7 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: http://localhost:8080/api/v4/projects/example%2Fexample/access_tokens/53 + url: http://localhost:8080/api/v4/personal_access_tokens/49 method: DELETE response: proto: HTTP/1.1 @@ -905,7 +1100,7 @@ interactions: Connection: - keep-alive Date: - - Sun, 13 Oct 2024 12:43:41 GMT + - Sat, 14 Dec 2024 22:52:55 GMT Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -919,26 +1114,26 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YFTY0XC8SCA30GH8ATQZQ","version":"1"}' + - '{"correlation_id":"01JF3NZXDTB19HQEA3A7D1TH4E","version":"1"}' X-Request-Id: - - 01JA2YFTY0XC8SCA30GH8ATQZQ + - 01JF3NZXDTB19HQEA3A7D1TH4E X-Runtime: - - "0.072583" + - "0.017755" status: 204 No Content code: 204 - duration: 75.751292ms - - id: 14 + duration: 20.240834ms + - id: 17 request: proto: HTTP/1.1 proto_major: 1 proto_minor: 1 - content_length: 107 + content_length: 123 transfer_encoding: [] trailer: {} host: localhost:8080 remote_addr: "" request_uri: "" - body: '{"name":"example-normal-example-normal-group","scopes":["api"],"access_level":10,"expires_at":"2024-12-14"}' + body: '{"name":"example/example-admin-example-example-admin-project","scopes":["api"],"access_level":10,"expires_at":"2025-03-14"}' form: {} headers: Accept: @@ -949,7 +1144,7 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: http://localhost:8080/api/v4/groups/example/access_tokens + url: http://localhost:8080/api/v4/projects/example%2Fexample/access_tokens method: POST response: proto: HTTP/1.1 @@ -957,22 +1152,22 @@ interactions: proto_minor: 1 transfer_encoding: [] trailer: {} - content_length: 255 + content_length: 270 uncompressed: false - body: '{"id":54,"name":"example-normal-example-normal-group","revoked":false,"created_at":"2024-10-13T12:43:42.116Z","scopes":["api"],"user_id":10,"last_used_at":null,"active":true,"expires_at":"2024-12-14","access_level":10,"token":"glpat-qgb9kqvkzoHKdXcYxkRr"}' + body: '{"id":50,"name":"example/example-admin-example-example-admin-project","revoked":false,"created_at":"2024-12-14T22:52:55.269Z","scopes":["api"],"user_id":7,"last_used_at":null,"active":true,"expires_at":"2025-03-14","access_level":10,"token":"glpat-pn1RMx84w-2jsWEyQH1A"}' headers: Cache-Control: - max-age=0, private, must-revalidate Connection: - keep-alive Content-Length: - - "255" + - "270" Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:43:42 GMT + - Sat, 14 Dec 2024 22:52:55 GMT Etag: - - W/"57031c31769a9d05c4f1623e3c9cf89a" + - W/"6c96610f30ddd8ab2ae3e54c4adf620b" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -986,15 +1181,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YFV2S2ZD98XYCH77DNG1V","version":"1"}' + - '{"correlation_id":"01JF3NZXF69G3PBRXYCZVQNA05","version":"1"}' X-Request-Id: - - 01JA2YFV2S2ZD98XYCH77DNG1V + - 01JF3NZXF69G3PBRXYCZVQNA05 X-Runtime: - - "0.078965" + - "0.131199" status: 201 Created code: 201 - duration: 81.8985ms - - id: 15 + duration: 134.385333ms + - id: 18 request: proto: HTTP/1.1 proto_major: 1 @@ -1022,22 +1217,22 @@ interactions: proto_minor: 1 transfer_encoding: [] trailer: {} - content_length: 222 + content_length: 237 uncompressed: false - body: '{"id":54,"name":"example-normal-example-normal-group","revoked":false,"created_at":"2024-10-13T12:43:42.116Z","scopes":["api"],"user_id":10,"last_used_at":"2024-10-13T12:43:42.215Z","active":true,"expires_at":"2024-12-14"}' + body: '{"id":50,"name":"example/example-admin-example-example-admin-project","revoked":false,"created_at":"2024-12-14T22:52:55.269Z","scopes":["api"],"user_id":7,"last_used_at":"2024-12-14T22:52:55.427Z","active":true,"expires_at":"2025-03-14"}' headers: Cache-Control: - max-age=0, private, must-revalidate Connection: - keep-alive Content-Length: - - "222" + - "237" Content-Type: - application/json Date: - - Sun, 13 Oct 2024 12:43:42 GMT + - Sat, 14 Dec 2024 22:52:55 GMT Etag: - - W/"17a871b105c966d8372c214bd3f98bdd" + - W/"3d698c714cc8eacf82f2324d859542cf" Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -1051,15 +1246,15 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YFV7YTK5430JNCXN3ZM35","version":"1"}' + - '{"correlation_id":"01JF3NZXQP11PP4ZNYHBFP85GD","version":"1"}' X-Request-Id: - - 01JA2YFV7YTK5430JNCXN3ZM35 + - 01JF3NZXQP11PP4ZNYHBFP85GD X-Runtime: - - "0.054073" + - "0.026257" status: 200 OK code: 200 - duration: 56.774916ms - - id: 16 + duration: 31.610083ms + - id: 19 request: proto: HTTP/1.1 proto_major: 1 @@ -1079,7 +1274,7 @@ interactions: - REPLACED-TOKEN User-Agent: - go-gitlab - url: http://localhost:8080/api/v4/groups/example/access_tokens/54 + url: http://localhost:8080/api/v4/projects/example%2Fexample/access_tokens/50 method: DELETE response: proto: HTTP/1.1 @@ -1096,7 +1291,7 @@ interactions: Connection: - keep-alive Date: - - Sun, 13 Oct 2024 12:43:42 GMT + - Sat, 14 Dec 2024 22:52:55 GMT Referrer-Policy: - strict-origin-when-cross-origin Server: @@ -1110,11 +1305,11 @@ interactions: X-Frame-Options: - SAMEORIGIN X-Gitlab-Meta: - - '{"correlation_id":"01JA2YFVBH891EKBC0FNA0TX5R","version":"1"}' + - '{"correlation_id":"01JF3NZXSRDXA2Q0RVY8KCVQM2","version":"1"}' X-Request-Id: - - 01JA2YFVBH891EKBC0FNA0TX5R + - 01JF3NZXSRDXA2Q0RVY8KCVQM2 X-Runtime: - - "0.082464" + - "0.152752" status: 204 No Content code: 204 - duration: 85.187667ms + duration: 157.03225ms diff --git a/testdata/fixtures/16.11.6/TestPathTokenRoles_group_access_token.yaml b/testdata/unit/TestPathTokenRoles_group_access_token.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestPathTokenRoles_group_access_token.yaml rename to testdata/unit/TestPathTokenRoles_group_access_token.yaml diff --git a/testdata/fixtures/16.11.6/TestPathTokenRoles_personal_access_token.yaml b/testdata/unit/TestPathTokenRoles_personal_access_token.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestPathTokenRoles_personal_access_token.yaml rename to testdata/unit/TestPathTokenRoles_personal_access_token.yaml diff --git a/testdata/fixtures/16.11.6/TestPathTokenRoles_project_access_token.yaml b/testdata/unit/TestPathTokenRoles_project_access_token.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestPathTokenRoles_project_access_token.yaml rename to testdata/unit/TestPathTokenRoles_project_access_token.yaml diff --git a/testdata/fixtures/16.11.6/TestPathTokenRoles_role_not_found.yaml b/testdata/unit/TestPathTokenRoles_role_not_found.yaml similarity index 100% rename from testdata/fixtures/16.11.6/TestPathTokenRoles_role_not_found.yaml rename to testdata/unit/TestPathTokenRoles_role_not_found.yaml diff --git a/testdata/unit/TestSecretAccessTokenRevokeToken.yaml b/testdata/unit/TestSecretAccessTokenRevokeToken.yaml new file mode 100644 index 0000000..1223a04 --- /dev/null +++ b/testdata/unit/TestSecretAccessTokenRevokeToken.yaml @@ -0,0 +1,263 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:55 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZY5BRVT02DR0V46SZG97","version":"1"}' + X-Request-Id: + - 01JF3NZY5BRVT02DR0V46SZG97 + X-Runtime: + - "0.018351" + status: 200 OK + code: 200 + duration: 22.418166ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:55 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZY6SC2J871EPFECTPV13","version":"1"}' + X-Request-Id: + - 01JF3NZY6SC2J871EPFECTPV13 + X-Runtime: + - "0.019330" + status: 200 OK + code: 200 + duration: 22.767208ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/personal_access_tokens/self + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":1,"name":"Initial token","revoked":false,"created_at":"2024-07-11T18:53:26.792Z","scopes":["api","read_api","read_user","sudo","admin_mode","create_runner","k8s_proxy","read_repository","write_repository","ai_features","read_service_ping"],"user_id":1,"last_used_at":"2024-12-14T22:52:47.081Z","active":true,"expires_at":"2025-07-11"}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:55 GMT + Etag: + - W/"d0f486f8d8a3d398674f9cd0e555862f" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Accept-Encoding + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZY89WVEY8SJT9AGW37M7","version":"1"}' + X-Request-Id: + - 01JF3NZY89WVEY8SJT9AGW37M7 + X-Runtime: + - "0.012486" + status: 200 OK + code: 200 + duration: 15.534709ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: localhost:8080 + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + Private-Token: + - REPLACED-TOKEN + User-Agent: + - go-gitlab + url: http://localhost:8080/api/v4/metadata + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"version":"16.11.6","revision":"4684e042d0b","kas":{"enabled":true,"externalUrl":"ws://7b1d891ab6bb/-/kubernetes-agent/","version":"16.11.6"},"enterprise":false}' + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Sat, 14 Dec 2024 22:52:55 GMT + Etag: + - W/"a29dcadce9c4771a1b7b66cc326f6617" + Referrer-Policy: + - strict-origin-when-cross-origin + Server: + - nginx + Strict-Transport-Security: + - max-age=63072000 + Vary: + - Origin + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Gitlab-Meta: + - '{"correlation_id":"01JF3NZY9A0W6WEEZ9EQ3W2KJN","version":"1"}' + X-Request-Id: + - 01JF3NZY9A0W6WEEZ9EQ3W2KJN + X-Runtime: + - "0.015713" + status: 200 OK + code: 200 + duration: 18.640917ms diff --git a/type_access_level.go b/type_access_level.go index afef088..53e1d18 100644 --- a/type_access_level.go +++ b/type_access_level.go @@ -5,7 +5,7 @@ import ( "fmt" "slices" - "github.com/xanzy/go-gitlab" + g "gitlab.com/gitlab-org/api/client-go" ) type AccessLevel string @@ -57,6 +57,10 @@ var ( AccessLevelMaintainerPermissions.String(), AccessLevelOwnerPermissions.String(), } + + ValidPipelineProjectTriggerAccessLevels = []string{AccessLevelUnknown.String()} + ValidProjectDeployAccessLevels = []string{AccessLevelUnknown.String()} + ValidGroupDeployAccessLevels = []string{AccessLevelUnknown.String()} ) func (i AccessLevel) String() string { @@ -66,19 +70,19 @@ func (i AccessLevel) String() string { func (i AccessLevel) Value() int { switch i { case AccessLevelNoPermissions: - return int(gitlab.NoPermissions) + return int(g.NoPermissions) case AccessLevelMinimalAccessPermissions: - return int(gitlab.MinimalAccessPermissions) + return int(g.MinimalAccessPermissions) case AccessLevelGuestPermissions: - return int(gitlab.GuestPermissions) + return int(g.GuestPermissions) case AccessLevelReporterPermissions: - return int(gitlab.ReporterPermissions) + return int(g.ReporterPermissions) case AccessLevelDeveloperPermissions: - return int(gitlab.DeveloperPermissions) + return int(g.DeveloperPermissions) case AccessLevelMaintainerPermissions: - return int(gitlab.MaintainerPermissions) + return int(g.MaintainerPermissions) case AccessLevelOwnerPermissions: - return int(gitlab.OwnerPermissions) + return int(g.OwnerPermissions) } return -1 diff --git a/type_access_level_test.go b/type_access_level_test.go index 907c13e..d5cab4c 100644 --- a/type_access_level_test.go +++ b/type_access_level_test.go @@ -1,3 +1,5 @@ +//go:build unit + package gitlab_test import ( diff --git a/type_token_scope.go b/type_token_scope.go index 8c4228f..6675799 100644 --- a/type_token_scope.go +++ b/type_token_scope.go @@ -22,6 +22,11 @@ const ( // TokenScopeWriteRepository grants read and write access (pull and push) to all repositories within expected group TokenScopeWriteRepository = TokenScope("write_repository") + // TokenScopeReadPackageRegistry Allows read-only access to the package registry. + TokenScopeReadPackageRegistry = TokenScope("read_package_registry") + // TokenScopeWritePackageRegistry Allows read and write access to the package registry. + TokenScopeWritePackageRegistry = TokenScope("write_package_registry") + // TokenScopeCreateRunner grants permission to create runners in expected group TokenScopeCreateRunner = TokenScope("create_runner") // TokenScopeManageRunner grants permission to manage runners in expected group @@ -60,8 +65,25 @@ var ( TokenScopeK8SProxy.String(), } - ValidGroupTokenScopes = validTokenScopes - ValidProjectTokenScopes = validTokenScopes + ValidPipelineProjectTokenScopes []string + ValidGroupTokenScopes = validTokenScopes + ValidProjectTokenScopes = validTokenScopes + + ValidProjectDeployTokenScopes = []string{ + TokenScopeReadRepository.String(), + TokenScopeReadRepository.String(), + TokenScopeWriteRegistry.String(), + TokenScopeReadPackageRegistry.String(), + TokenScopeWritePackageRegistry.String(), + } + + ValidGroupDeployTokenScopes = []string{ + TokenScopeReadRepository.String(), + TokenScopeReadRepository.String(), + TokenScopeWriteRegistry.String(), + TokenScopeReadPackageRegistry.String(), + TokenScopeWritePackageRegistry.String(), + } ValidPersonalTokenScopes = []string{ TokenScopeReadServicePing.String(), @@ -95,6 +117,9 @@ func (i TokenScope) Value() string { func TokenScopeParse(value string) (TokenScope, error) { if slices.Contains(ValidGroupTokenScopes, value) || + slices.Contains(ValidPipelineProjectTokenScopes, value) || + slices.Contains(ValidGroupDeployTokenScopes, value) || + slices.Contains(ValidProjectDeployTokenScopes, value) || slices.Contains(ValidPersonalTokenScopes, value) || slices.Contains(ValidProjectTokenScopes, value) || slices.Contains(ValidUserServiceAccountTokenScopes, value) || diff --git a/type_token_scope_test.go b/type_token_scope_test.go index 45f0854..fa0614c 100644 --- a/type_token_scope_test.go +++ b/type_token_scope_test.go @@ -1,3 +1,5 @@ +//go:build unit + package gitlab_test import ( @@ -54,6 +56,14 @@ func TestTokenScope(t *testing.T) { expected: gitlab.TokenScopeAdminMode, input: gitlab.TokenScopeAdminMode.String(), }, + { + expected: gitlab.TokenScopeReadPackageRegistry, + input: gitlab.TokenScopeReadPackageRegistry.String(), + }, + { + expected: gitlab.TokenScopeWritePackageRegistry, + input: gitlab.TokenScopeWritePackageRegistry.String(), + }, { expected: gitlab.TokenScopeUnknown, input: "what", diff --git a/type_token_type.go b/type_token_type.go index 4370329..315e029 100644 --- a/type_token_type.go +++ b/type_token_type.go @@ -9,11 +9,14 @@ import ( type TokenType string const ( - TokenTypePersonal = TokenType("personal") - TokenTypeProject = TokenType("project") - TokenTypeGroup = TokenType("group") - TokenTypeUserServiceAccount = TokenType("user-service-account") - TokenTypeGroupServiceAccount = TokenType("group-service-account") + TokenTypePersonal = TokenType("personal") + TokenTypeProject = TokenType("project") + TokenTypeGroup = TokenType("group") + TokenTypeUserServiceAccount = TokenType("user-service-account") + TokenTypeGroupServiceAccount = TokenType("group-service-account") + TokenTypePipelineProjectTrigger = TokenType("pipeline-project-trigger") + TokenTypeProjectDeploy = TokenType("project-deploy") + TokenTypeGroupDeploy = TokenType("group-deploy") TokenTypeUnknown = TokenType("") ) @@ -27,6 +30,9 @@ var ( TokenTypeGroup.String(), TokenTypeUserServiceAccount.String(), TokenTypeGroupServiceAccount.String(), + TokenTypePipelineProjectTrigger.String(), + TokenTypeProjectDeploy.String(), + TokenTypeGroupDeploy.String(), } ) diff --git a/type_token_type_test.go b/type_token_type_test.go index 9d4853c..561a4e1 100644 --- a/type_token_type_test.go +++ b/type_token_type_test.go @@ -1,3 +1,5 @@ +//go:build unit + package gitlab_test import ( @@ -34,6 +36,18 @@ func TestTokenType(t *testing.T) { expected: gitlab.TokenTypeGroupServiceAccount, input: gitlab.TokenTypeGroupServiceAccount.String(), }, + { + expected: gitlab.TokenTypePipelineProjectTrigger, + input: gitlab.TokenTypePipelineProjectTrigger.String(), + }, + { + expected: gitlab.TokenTypeProjectDeploy, + input: gitlab.TokenTypeProjectDeploy.String(), + }, + { + expected: gitlab.TokenTypeGroupDeploy, + input: gitlab.TokenTypeGroupDeploy.String(), + }, { expected: gitlab.TokenTypeUnknown, input: "unknown", diff --git a/utils_test.go b/utils_test.go index 7fa7386..a1c728d 100644 --- a/utils_test.go +++ b/utils_test.go @@ -1,4 +1,4 @@ -//go:build !integration +//go:build unit package gitlab diff --git a/with_admin_user_pat_gitlab_revokes_token_test.go b/with_admin_user_pat_gitlab_revokes_token_test.go index d82a060..8744e93 100644 --- a/with_admin_user_pat_gitlab_revokes_token_test.go +++ b/with_admin_user_pat_gitlab_revokes_token_test.go @@ -1,3 +1,5 @@ +//go:build local + package gitlab_test import ( @@ -11,13 +13,13 @@ import ( "github.com/hashicorp/vault/sdk/logical" "github.com/stretchr/testify/require" - g "github.com/xanzy/go-gitlab" + g "gitlab.com/gitlab-org/api/client-go" gitlab "github.com/ilijamt/vault-plugin-secrets-gitlab" ) func TestWithAdminUser_PAT_AdminUser_GitlabRevokesToken(t *testing.T) { - httpClient, url := getClient(t) + httpClient, url := getClient(t, "local") ctx := gitlab.HttpClientNewContext(context.Background(), httpClient) b, l, events, err := getBackendWithEvents(ctx) diff --git a/with_admin_user_pat_vault_revokes_token_test.go b/with_admin_user_pat_vault_revokes_token_test.go index efcf68d..e073b1b 100644 --- a/with_admin_user_pat_vault_revokes_token_test.go +++ b/with_admin_user_pat_vault_revokes_token_test.go @@ -1,3 +1,5 @@ +//go:build local + package gitlab_test import ( @@ -11,13 +13,13 @@ import ( "github.com/hashicorp/vault/sdk/logical" "github.com/stretchr/testify/require" - g "github.com/xanzy/go-gitlab" + g "gitlab.com/gitlab-org/api/client-go" gitlab "github.com/ilijamt/vault-plugin-secrets-gitlab" ) func TestWithAdminUser_PAT_AdminUser_VaultRevokesToken(t *testing.T) { - httpClient, url := getClient(t) + httpClient, url := getClient(t, "local") ctx := gitlab.HttpClientNewContext(context.Background(), httpClient) b, l, events, err := getBackendWithEvents(ctx) diff --git a/with_gitlab_com_user_rotate_token_test.go b/with_gitlab_com_user_rotate_token_test.go index e42ef40..cde952b 100644 --- a/with_gitlab_com_user_rotate_token_test.go +++ b/with_gitlab_com_user_rotate_token_test.go @@ -1,3 +1,5 @@ +//go:build saas + package gitlab_test import ( @@ -8,13 +10,13 @@ import ( "github.com/hashicorp/vault/sdk/logical" "github.com/stretchr/testify/require" - g "github.com/xanzy/go-gitlab" + g "gitlab.com/gitlab-org/api/client-go" gitlab "github.com/ilijamt/vault-plugin-secrets-gitlab" ) func TestWithGitlabUser_RotateToken(t *testing.T) { - httpClient, _ := getClient(t) + httpClient, _ := getClient(t, "saas") ctx := gitlab.HttpClientNewContext(context.Background(), httpClient) b, l, events, err := getBackendWithEvents(ctx) diff --git a/with_group_deploy_token_test.go b/with_group_deploy_token_test.go new file mode 100644 index 0000000..fa895e6 --- /dev/null +++ b/with_group_deploy_token_test.go @@ -0,0 +1,115 @@ +//go:build local + +package gitlab_test + +import ( + "context" + "fmt" + "strconv" + "testing" + "time" + + "github.com/hashicorp/vault/sdk/logical" + "github.com/stretchr/testify/require" + g "gitlab.com/gitlab-org/api/client-go" + + gitlab "github.com/ilijamt/vault-plugin-secrets-gitlab" +) + +func TestWithGroupDeployToken(t *testing.T) { + httpClient, url := getClient(t, "local") + ctx := gitlab.HttpClientNewContext(context.Background(), httpClient) + + b, l, events, err := getBackendWithEvents(ctx) + require.NoError(t, err) + + resp, err := b.HandleRequest(ctx, &logical.Request{ + Operation: logical.UpdateOperation, + Path: fmt.Sprintf("%s/%s", gitlab.PathConfigStorage, gitlab.DefaultConfigName), Storage: l, + Data: map[string]any{ + "token": "glpat-secret-normal-token", + "base_url": url, + "auto_rotate_token": true, + "auto_rotate_before": "24h", + "type": gitlab.TypeSelfManaged.String(), + }, + }) + + require.NoError(t, err) + require.NotNil(t, resp) + require.NoError(t, resp.Error()) + require.NotEmpty(t, events) + + var c *g.Client + var token string + var secret *logical.Secret + + { + resp, err := b.HandleRequest(ctx, &logical.Request{ + Operation: logical.CreateOperation, + Path: fmt.Sprintf("%s/role", gitlab.PathRoleStorage), Storage: l, + Data: map[string]any{ + "path": "example", + "name": gitlab.TokenTypeGroupDeploy.String(), + "token_type": gitlab.TokenTypeGroupDeploy.String(), + "gitlab_revokes_token": strconv.FormatBool(false), + "ttl": 120 * time.Hour, + "scopes": []string{gitlab.TokenScopeReadRepository.String()}, + }, + }) + require.NoError(t, err) + require.NotNil(t, resp) + require.NoError(t, resp.Error()) + } + + { + ctxIssueToken, _ := ctxTestTime(ctx, t.Name()) + resp, err := b.HandleRequest(ctxIssueToken, &logical.Request{ + Operation: logical.ReadOperation, Storage: l, + Path: fmt.Sprintf("%s/role", gitlab.PathTokenRoleStorage), + }) + + require.NoError(t, err) + require.NotNil(t, resp) + require.NoError(t, resp.Error()) + token = resp.Data["token"].(string) + require.NotEmpty(t, token) + secret = resp.Secret + require.NotNil(t, secret) + } + + c = b.GetClient(gitlab.DefaultConfigName).GitlabClient(ctx) + require.NotNil(t, c) + + { + tt, _, err := c.DeployTokens.ListGroupDeployTokens("example", &g.ListGroupDeployTokensOptions{}) + require.NoError(t, err) + out := filterSlice(tt, func(item *g.DeployToken, index int) bool { return !item.Expired && !item.Revoked }) + require.Len(t, out, 1) + } + + { + resp, err := b.HandleRequest(ctx, &logical.Request{ + Operation: logical.RevokeOperation, + Path: "/", + Storage: l, + Secret: secret, + }) + require.NoError(t, err) + require.Nil(t, resp) + } + + { + tt, _, err := c.DeployTokens.ListGroupDeployTokens("example", &g.ListGroupDeployTokensOptions{}) + require.NoError(t, err) + out := filterSlice(tt, func(item *g.DeployToken, index int) bool { return !item.Expired && !item.Revoked }) + require.Len(t, out, 0) + } + + events.expectEvents(t, []expectedEvent{ + {eventType: "gitlab/config-write"}, + {eventType: "gitlab/role-write"}, + {eventType: "gitlab/token-write"}, + {eventType: "gitlab/token-revoke"}, + }) +} diff --git a/with_normal_user_gat_test.go b/with_normal_user_gat_test.go index 66beb3f..f0315d3 100644 --- a/with_normal_user_gat_test.go +++ b/with_normal_user_gat_test.go @@ -1,3 +1,5 @@ +//go:build local + package gitlab_test import ( @@ -11,13 +13,13 @@ import ( "github.com/hashicorp/vault/sdk/logical" "github.com/stretchr/testify/require" - g "github.com/xanzy/go-gitlab" + g "gitlab.com/gitlab-org/api/client-go" gitlab "github.com/ilijamt/vault-plugin-secrets-gitlab" ) func TestWithNormalUser_GAT(t *testing.T) { - httpClient, url := getClient(t) + httpClient, url := getClient(t, "local") ctx := gitlab.HttpClientNewContext(context.Background(), httpClient) b, l, events, err := getBackendWithEvents(ctx) diff --git a/with_normal_user_personal_at_fails_test.go b/with_normal_user_personal_at_fails_test.go index 5a2f2f7..cedbc76 100644 --- a/with_normal_user_personal_at_fails_test.go +++ b/with_normal_user_personal_at_fails_test.go @@ -1,3 +1,5 @@ +//go:build local + package gitlab_test import ( @@ -15,7 +17,7 @@ import ( ) func TestWithNormalUser_PersonalAT_Fails(t *testing.T) { - httpClient, url := getClient(t) + httpClient, url := getClient(t, "local") ctx := gitlab.HttpClientNewContext(context.Background(), httpClient) b, l, events, err := getBackendWithEvents(ctx) diff --git a/with_normal_user_project_at_test.go b/with_normal_user_project_at_test.go index 723772d..e6c7fa0 100644 --- a/with_normal_user_project_at_test.go +++ b/with_normal_user_project_at_test.go @@ -1,3 +1,5 @@ +//go:build local + package gitlab_test import ( @@ -11,13 +13,13 @@ import ( "github.com/hashicorp/vault/sdk/logical" "github.com/stretchr/testify/require" - g "github.com/xanzy/go-gitlab" + g "gitlab.com/gitlab-org/api/client-go" gitlab "github.com/ilijamt/vault-plugin-secrets-gitlab" ) func TestWithNormalUser_ProjectAT(t *testing.T) { - httpClient, url := getClient(t) + httpClient, url := getClient(t, "local") ctx := gitlab.HttpClientNewContext(context.Background(), httpClient) b, l, events, err := getBackendWithEvents(ctx) diff --git a/with_pipeline_project_trigger_token_test.go b/with_pipeline_project_trigger_token_test.go new file mode 100644 index 0000000..1586977 --- /dev/null +++ b/with_pipeline_project_trigger_token_test.go @@ -0,0 +1,110 @@ +//go:build local + +package gitlab_test + +import ( + "context" + "fmt" + "strconv" + "testing" + + "github.com/hashicorp/vault/sdk/logical" + "github.com/stretchr/testify/require" + g "gitlab.com/gitlab-org/api/client-go" + + gitlab "github.com/ilijamt/vault-plugin-secrets-gitlab" +) + +func TestWithPipelineProjectTriggerAccessToken(t *testing.T) { + httpClient, url := getClient(t, "local") + ctx := gitlab.HttpClientNewContext(context.Background(), httpClient) + + b, l, events, err := getBackendWithEvents(ctx) + require.NoError(t, err) + + resp, err := b.HandleRequest(ctx, &logical.Request{ + Operation: logical.UpdateOperation, + Path: fmt.Sprintf("%s/%s", gitlab.PathConfigStorage, gitlab.DefaultConfigName), Storage: l, + Data: map[string]any{ + "token": "glpat-secret-normal-token", + "base_url": url, + "auto_rotate_token": true, + "auto_rotate_before": "24h", + "type": gitlab.TypeSelfManaged.String(), + }, + }) + + require.NoError(t, err) + require.NotNil(t, resp) + require.NoError(t, resp.Error()) + require.NotEmpty(t, events) + + var c *g.Client + var token string + var secret *logical.Secret + + { + resp, err := b.HandleRequest(ctx, &logical.Request{ + Operation: logical.CreateOperation, + Path: fmt.Sprintf("%s/pptat", gitlab.PathRoleStorage), Storage: l, + Data: map[string]any{ + "path": "example/example", + "name": gitlab.TokenTypePipelineProjectTrigger.String(), + "token_type": gitlab.TokenTypePipelineProjectTrigger.String(), + "gitlab_revokes_token": strconv.FormatBool(false), + }, + }) + require.NoError(t, err) + require.NotNil(t, resp) + require.NoError(t, resp.Error()) + } + + { + ctxIssueToken, _ := ctxTestTime(ctx, t.Name()) + resp, err := b.HandleRequest(ctxIssueToken, &logical.Request{ + Operation: logical.ReadOperation, Storage: l, + Path: fmt.Sprintf("%s/pptat", gitlab.PathTokenRoleStorage), + }) + + require.NoError(t, err) + require.NotNil(t, resp) + require.NoError(t, resp.Error()) + token = resp.Data["token"].(string) + require.NotEmpty(t, token) + secret = resp.Secret + require.NotNil(t, secret) + } + + c = b.GetClient(gitlab.DefaultConfigName).GitlabClient(ctx) + require.NotNil(t, c) + + { + tt, _, err := c.PipelineTriggers.ListPipelineTriggers("example/example", &g.ListPipelineTriggersOptions{}) + require.NoError(t, err) + require.Len(t, tt, 1) + } + + { + resp, err := b.HandleRequest(ctx, &logical.Request{ + Operation: logical.RevokeOperation, + Path: "/", + Storage: l, + Secret: secret, + }) + require.NoError(t, err) + require.Nil(t, resp) + } + + { + tt, _, err := c.PipelineTriggers.ListPipelineTriggers("example/example", &g.ListPipelineTriggersOptions{}) + require.NoError(t, err) + require.Len(t, tt, 0) + } + + events.expectEvents(t, []expectedEvent{ + {eventType: "gitlab/config-write"}, + {eventType: "gitlab/role-write"}, + {eventType: "gitlab/token-write"}, + {eventType: "gitlab/token-revoke"}, + }) +} diff --git a/with_project_deploy_token_test.go b/with_project_deploy_token_test.go new file mode 100644 index 0000000..e50157d --- /dev/null +++ b/with_project_deploy_token_test.go @@ -0,0 +1,115 @@ +//go:build local + +package gitlab_test + +import ( + "context" + "fmt" + "strconv" + "testing" + "time" + + "github.com/hashicorp/vault/sdk/logical" + "github.com/stretchr/testify/require" + g "gitlab.com/gitlab-org/api/client-go" + + gitlab "github.com/ilijamt/vault-plugin-secrets-gitlab" +) + +func TestWithProjectDeployToken(t *testing.T) { + httpClient, url := getClient(t, "local") + ctx := gitlab.HttpClientNewContext(context.Background(), httpClient) + + b, l, events, err := getBackendWithEvents(ctx) + require.NoError(t, err) + + resp, err := b.HandleRequest(ctx, &logical.Request{ + Operation: logical.UpdateOperation, + Path: fmt.Sprintf("%s/%s", gitlab.PathConfigStorage, gitlab.DefaultConfigName), Storage: l, + Data: map[string]any{ + "token": "glpat-secret-normal-token", + "base_url": url, + "auto_rotate_token": true, + "auto_rotate_before": "24h", + "type": gitlab.TypeSelfManaged.String(), + }, + }) + + require.NoError(t, err) + require.NotNil(t, resp) + require.NoError(t, resp.Error()) + require.NotEmpty(t, events) + + var c *g.Client + var token string + var secret *logical.Secret + + { + resp, err := b.HandleRequest(ctx, &logical.Request{ + Operation: logical.CreateOperation, + Path: fmt.Sprintf("%s/role", gitlab.PathRoleStorage), Storage: l, + Data: map[string]any{ + "path": "example/example", + "name": gitlab.TokenTypeProjectDeploy.String(), + "token_type": gitlab.TokenTypeProjectDeploy.String(), + "gitlab_revokes_token": strconv.FormatBool(false), + "ttl": 120 * time.Hour, + "scopes": []string{gitlab.TokenScopeReadRepository.String()}, + }, + }) + require.NoError(t, err) + require.NotNil(t, resp) + require.NoError(t, resp.Error()) + } + + { + ctxIssueToken, _ := ctxTestTime(ctx, t.Name()) + resp, err := b.HandleRequest(ctxIssueToken, &logical.Request{ + Operation: logical.ReadOperation, Storage: l, + Path: fmt.Sprintf("%s/role", gitlab.PathTokenRoleStorage), + }) + + require.NoError(t, err) + require.NotNil(t, resp) + require.NoError(t, resp.Error()) + token = resp.Data["token"].(string) + require.NotEmpty(t, token) + secret = resp.Secret + require.NotNil(t, secret) + } + + c = b.GetClient(gitlab.DefaultConfigName).GitlabClient(ctx) + require.NotNil(t, c) + + { + tt, _, err := c.DeployTokens.ListProjectDeployTokens("example/example", &g.ListProjectDeployTokensOptions{}) + require.NoError(t, err) + out := filterSlice(tt, func(item *g.DeployToken, index int) bool { return !item.Expired && !item.Revoked }) + require.Len(t, out, 1) + } + + { + resp, err := b.HandleRequest(ctx, &logical.Request{ + Operation: logical.RevokeOperation, + Path: "/", + Storage: l, + Secret: secret, + }) + require.NoError(t, err) + require.Nil(t, resp) + } + + { + tt, _, err := c.DeployTokens.ListProjectDeployTokens("example/example", &g.ListProjectDeployTokensOptions{}) + require.NoError(t, err) + out := filterSlice(tt, func(item *g.DeployToken, index int) bool { return !item.Expired && !item.Revoked }) + require.Len(t, out, 0) + } + + events.expectEvents(t, []expectedEvent{ + {eventType: "gitlab/config-write"}, + {eventType: "gitlab/role-write"}, + {eventType: "gitlab/token-write"}, + {eventType: "gitlab/token-revoke"}, + }) +} diff --git a/with_service_account_fail_test.go b/with_service_account_fail_test.go index 9b93cab..8e3d2e6 100644 --- a/with_service_account_fail_test.go +++ b/with_service_account_fail_test.go @@ -1,3 +1,5 @@ +//go:build selfhosted + package gitlab_test import ( @@ -7,6 +9,7 @@ import ( "github.com/hashicorp/vault/sdk/logical" "github.com/stretchr/testify/require" + g "gitlab.com/gitlab-org/api/client-go" gitlab "github.com/ilijamt/vault-plugin-secrets-gitlab" ) @@ -17,7 +20,7 @@ func TestWithServiceAccountUserFail(t *testing.T) { gitlab.TypeDedicated, } { t.Run(typ.String(), func(t *testing.T) { - httpClient, _ := getClient(t) + httpClient, _ := getClient(t, "selfhosted") ctx := gitlab.HttpClientNewContext(context.Background(), httpClient) b, l, events, err := getBackendWithEvents(ctx) @@ -44,7 +47,7 @@ func TestWithServiceAccountUserFail(t *testing.T) { var gClient = b.GetClient(gitlab.DefaultConfigName).GitlabClient(ctx) require.NotNil(t, gClient) - usr, _, err := gClient.Users.CreateServiceAccountUser() + usr, _, err := gClient.Users.CreateServiceAccountUser(&g.CreateServiceAccountUserOptions{}) require.NoError(t, err) require.NotNil(t, usr) diff --git a/with_service_account_group_test.go b/with_service_account_group_test.go index 3043926..e37f41d 100644 --- a/with_service_account_group_test.go +++ b/with_service_account_group_test.go @@ -1,3 +1,5 @@ +//go:build selfhosted + package gitlab_test import ( @@ -9,13 +11,13 @@ import ( "github.com/hashicorp/vault/sdk/logical" "github.com/stretchr/testify/require" - g "github.com/xanzy/go-gitlab" + g "gitlab.com/gitlab-org/api/client-go" gitlab "github.com/ilijamt/vault-plugin-secrets-gitlab" ) func TestWithServiceAccountGroup(t *testing.T) { - httpClient, _ := getClient(t) + httpClient, _ := getClient(t, "selfhosted") ctx := gitlab.HttpClientNewContext(context.Background(), httpClient) b, l, events, err := getBackendWithEvents(ctx) diff --git a/with_service_account_user_test.go b/with_service_account_user_test.go index b797840..b3a7ca1 100644 --- a/with_service_account_user_test.go +++ b/with_service_account_user_test.go @@ -1,3 +1,5 @@ +//go:build selfhosted + package gitlab_test import ( @@ -8,13 +10,13 @@ import ( "github.com/hashicorp/vault/sdk/logical" "github.com/stretchr/testify/require" - g "github.com/xanzy/go-gitlab" + g "gitlab.com/gitlab-org/api/client-go" gitlab "github.com/ilijamt/vault-plugin-secrets-gitlab" ) func TestWithServiceAccountUser(t *testing.T) { - httpClient, _ := getClient(t) + httpClient, _ := getClient(t, "selfhosted") ctx := gitlab.HttpClientNewContext(context.Background(), httpClient) b, l, events, err := getBackendWithEvents(ctx) @@ -42,7 +44,7 @@ func TestWithServiceAccountUser(t *testing.T) { require.NotNil(t, gClient) // Create a service account user - usr, _, err := gClient.Users.CreateServiceAccountUser() + usr, _, err := gClient.Users.CreateServiceAccountUser(&g.CreateServiceAccountUserOptions{}) require.NoError(t, err) require.NotNil(t, usr)