Skip to content

Commit 4aa37d0

Browse files
Vasilii Iakliushine_forbes
authored andcommitted
Merge branch 'ef-migrate-final-ruby-spec-tests' into 'main'
Removes final Ruby Spec Tests from this repository See merge request https://gitlab.com/gitlab-org/gitlab-shell/-/merge_requests/1368 Merged-by: Vasilii Iakliushin <viakliushin@gitlab.com> Approved-by: Igor Drozdov <idrozdov@gitlab.com> Approved-by: Vasilii Iakliushin <viakliushin@gitlab.com> Co-authored-by: e_forbes <eforbes@gitlab.com>
2 parents bf89af2 + e154d2d commit 4aa37d0

15 files changed

Lines changed: 44 additions & 540 deletions

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ race:
196196
- .go-matrix-job
197197
- .test-job
198198
script:
199-
- make test_golang_race
199+
- make test_race
200200

201201
code_quality:
202202
stage: lint

.ruby-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

.tool-versions

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
ruby 3.3.10
21
golang 1.24.5
32
golangci-lint 2.3.1

Gemfile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
source 'https://rubygems.org'
22

3-
group :development, :test do
4-
gem 'base64', '~> 0.3.0'
5-
gem 'rspec', '~> 3.13.1'
6-
gem 'webrick', '~> 1.9', '>= 1.9.1'
7-
end
8-
93
group :development, :danger do
104
gem 'gitlab-dangerfiles', '~> 4.9.2'
115
end

Gemfile.lock

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ GEM
3131
danger-gitlab (8.0.0)
3232
danger
3333
gitlab (~> 4.2, >= 4.2.0)
34-
diff-lcs (1.5.1)
3534
faraday (2.13.1)
3635
faraday-net_http (>= 2.0, < 3.5)
3736
json
@@ -75,36 +74,19 @@ GEM
7574
rake (13.2.1)
7675
rchardet (1.9.0)
7776
rexml (3.4.1)
78-
rspec (3.13.1)
79-
rspec-core (~> 3.13.0)
80-
rspec-expectations (~> 3.13.0)
81-
rspec-mocks (~> 3.13.0)
82-
rspec-core (3.13.4)
83-
rspec-support (~> 3.13.0)
84-
rspec-expectations (3.13.5)
85-
diff-lcs (>= 1.2.0, < 2.0)
86-
rspec-support (~> 3.13.0)
87-
rspec-mocks (3.13.5)
88-
diff-lcs (>= 1.2.0, < 2.0)
89-
rspec-support (~> 3.13.0)
90-
rspec-support (3.13.4)
9177
sawyer (0.9.2)
9278
addressable (>= 2.3.5)
9379
faraday (>= 0.17.3, < 3)
9480
terminal-table (3.0.2)
9581
unicode-display_width (>= 1.1.1, < 3)
9682
unicode-display_width (2.6.0)
9783
uri (0.13.2)
98-
webrick (1.9.1)
9984

10085
PLATFORMS
10186
ruby
10287

10388
DEPENDENCIES
104-
base64 (~> 0.3.0)
10589
gitlab-dangerfiles (~> 4.9.2)
106-
rspec (~> 3.13.1)
107-
webrick (~> 1.9, >= 1.9.1)
10890

10991
BUNDLED WITH
11092
2.6.5

Makefile

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: validate verify verify_ruby verify_golang test test_ruby test_golang test_fancy test_golang_fancy coverage coverage_golang setup _script_install make_necessary_dirs build compile check clean install lint
1+
.PHONY: validate verify verify_ruby verify_golang test test_fancy coverage coverage_golang setup _script_install make_necessary_dirs build compile check clean install lint
22

33
FIPS_MODE ?= 0
44
OS := $(shell uname | tr A-Z a-z)
@@ -56,39 +56,27 @@ build: compile
5656

5757
validate: verify test
5858

59-
verify: verify_golang
60-
61-
verify_golang:
59+
verify:
6260
gofmt -s -l $(GO_SOURCES) | awk '{ print } END { if (NR > 0) { print "Please run make fmt"; exit 1 } }'
6361

6462
fmt:
6563
gofmt -w -s $(GO_SOURCES)
6664

67-
test: test_ruby test_golang
68-
69-
test_fancy: test_ruby test_golang_fancy
70-
71-
# The Ruby tests are now all integration specs that test the Go implementation.
72-
test_ruby:
73-
bundle exec rspec --color --format d spec
74-
75-
test_golang:
65+
test:
7666
go test -cover -coverprofile=cover.out -count 1 -tags "$(GO_TAGS)" ./...
7767

78-
test_golang_fancy: ${GOTESTSUM_FILE}
68+
test_fancy: ${GOTESTSUM_FILE}
7969
@${GOTESTSUM_FILE} --version
8070
@${GOTESTSUM_FILE} --junitfile ./cover.xml --format pkgname -- -coverprofile=./cover.out -covermode=atomic -count 1 -tags "$(GO_TAGS)" ./...
8171

8272
${GOTESTSUM_FILE}:
8373
mkdir -p $(shell dirname ${GOTESTSUM_FILE})
8474
curl -L https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_${OS}_${ARCH}.tar.gz | tar -zOxf - gotestsum > ${GOTESTSUM_FILE} && chmod +x ${GOTESTSUM_FILE}
8575

86-
test_golang_race:
76+
test_race:
8777
go test -race -count 1 ./...
8878

89-
coverage: coverage_golang
90-
91-
coverage_golang:
79+
coverage:
9280
[ -f cover.out ] && go tool cover -func cover.out
9381

9482
lint:

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ Development documentation for GitLab Shell [has moved into the `gitlab` reposito
2828
| `client/` | HTTP and GitLab client logic that is used internally and by other modules, e.g. Gitaly. |
2929
| `bin/` | Compiled binaries are created here. |
3030
| `support/` | Scripts and tools that assist in development and/or testing. |
31-
| `spec/` | Ruby based integration tests. |
3231

3332
## Building
3433

cmd/gitlab-sshd/acceptance_test.go

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -473,23 +473,45 @@ func TwoFactorAuthVerifySuccess(t *testing.T) {
473473
}
474474

475475
func TestGitLfsAuthenticateSuccess(t *testing.T) {
476-
handler := customHandler{
477-
url: "/api/v4/internal/lfs_authenticate",
478-
caller: func(w http.ResponseWriter, _ *http.Request) {
479-
fmt.Fprint(w, `{"username": "test-user", "lfs_token": "testlfstoken", "repo_path": "foo", "expires_in": 7200}`)
480-
},
481-
}
482-
client := runSSHD(t, "ed25519", successAPI(t, handler))
476+
t.Run("lfs is successfully authed when a correct user is provided", func(t *testing.T) {
477+
handler := customHandler{
478+
url: "/api/v4/internal/lfs_authenticate",
479+
caller: func(w http.ResponseWriter, _ *http.Request) {
480+
fmt.Fprint(w, `{"username": "test-user", "lfs_token": "testlfstoken", "repo_path": "foo", "expires_in": 7200}`)
481+
},
482+
}
483+
client := runSSHD(t, "ed25519", successAPI(t, handler))
483484

484-
session, err := client.NewSession()
485-
require.NoError(t, err)
486-
defer session.Close()
485+
session, err := client.NewSession()
486+
require.NoError(t, err)
487+
defer session.Close()
487488

488-
output, err := session.Output("git-lfs-authenticate test-user/repo.git download")
489+
output, err := session.Output("git-lfs-authenticate test-user/repo.git download")
489490

490-
require.NoError(t, err)
491-
require.JSONEq(t, `{"header":{"Authorization":"Basic dGVzdC11c2VyOnRlc3RsZnN0b2tlbg=="},"href":"/info/lfs","expires_in":7200}
491+
require.NoError(t, err)
492+
require.JSONEq(t, `{"header":{"Authorization":"Basic dGVzdC11c2VyOnRlc3RsZnN0b2tlbg=="},"href":"/info/lfs","expires_in":7200}
492493
`, string(output))
494+
})
495+
496+
t.Run("lfs is not authenticated when a user is not allowed to perform an action", func(t *testing.T) {
497+
handler := customHandler{
498+
url: "/api/v4/internal/lfs_authenticate",
499+
caller: func(w http.ResponseWriter, _ *http.Request) {
500+
http.Error(w, "forbidden", http.StatusForbidden)
501+
},
502+
}
503+
client := runSSHD(t, "ed25519", successAPI(t, handler))
504+
session, err := client.NewSession()
505+
require.NoError(t, err)
506+
defer session.Close()
507+
508+
output, err := session.Output("git-lfs-authenticate test-user/repo.git download")
509+
510+
// we don't send back an error
511+
require.NoError(t, err)
512+
// we also ensure that we don't send back any output
513+
require.Empty(t, string(output))
514+
})
493515
}
494516

495517
func TestGitReceivePackSuccess(t *testing.T) {

lefthook.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@ pre-push:
22
commands:
33
test:
44
run: make test
5-
# Disabled for now as there's _lots_ of linter errors
6-
#lint:
7-
# run: make lint
5+
lint:
6+
run: make lint

spec/gitlab_shell_lfs_authentication_spec.rb

Lines changed: 0 additions & 128 deletions
This file was deleted.

0 commit comments

Comments
 (0)