diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index d263241..81fbd52 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -35,11 +35,19 @@ jobs: steps: - name: Checkout repository +<<<<<<< HEAD uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@6a28655e3dcb49cb0840ea372fd6d17733edd8a4 # v2 +======= + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@ddccb873888234080b77e9bc2d4764d5ccaaccf9 # v2 +>>>>>>> 2b2d0398193a806a0ae8c4a3c44a6e15f65c0568 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -50,7 +58,11 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild +<<<<<<< HEAD uses: github/codeql-action/autobuild@6a28655e3dcb49cb0840ea372fd6d17733edd8a4 # v2 +======= + uses: github/codeql-action/autobuild@ddccb873888234080b77e9bc2d4764d5ccaaccf9 # v2 +>>>>>>> 2b2d0398193a806a0ae8c4a3c44a6e15f65c0568 # ℹī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -64,4 +76,8 @@ jobs: # make release - name: Perform CodeQL Analysis +<<<<<<< HEAD uses: github/codeql-action/analyze@6a28655e3dcb49cb0840ea372fd6d17733edd8a4 # v2 +======= + uses: github/codeql-action/analyze@ddccb873888234080b77e9bc2d4764d5ccaaccf9 # v2 +>>>>>>> 2b2d0398193a806a0ae8c4a3c44a6e15f65c0568 diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 06b0329..302460d 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -11,7 +11,11 @@ jobs: runs-on: ubuntu-latest steps: - name: clone +<<<<<<< HEAD uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 +======= + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4 +>>>>>>> 2b2d0398193a806a0ae8c4a3c44a6e15f65c0568 - name: install go uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4 @@ -34,7 +38,11 @@ jobs: runs-on: ubuntu-latest steps: - name: clone +<<<<<<< HEAD uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 +======= + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4 +>>>>>>> 2b2d0398193a806a0ae8c4a3c44a6e15f65c0568 - name: install go uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fd003b2..bc718e0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,11 @@ jobs: runs-on: ubuntu-latest steps: - name: clone +<<<<<<< HEAD uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 +======= + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4 +>>>>>>> 2b2d0398193a806a0ae8c4a3c44a6e15f65c0568 - name: install go uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4 diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index fb6e8cd..4602640 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -12,7 +12,11 @@ jobs: runs-on: ubuntu-latest steps: - name: clone +<<<<<<< HEAD uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 +======= + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4 +>>>>>>> 2b2d0398193a806a0ae8c4a3c44a6e15f65c0568 - name: install go uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4 diff --git a/go.mod b/go.mod index c5419ae..05d586b 100644 --- a/go.mod +++ b/go.mod @@ -6,8 +6,8 @@ require ( github.com/buildkite/yaml v0.0.0-20230306222819-0e4e032d4835 github.com/coreos/go-semver v0.3.1 github.com/gin-gonic/gin v1.9.1 - github.com/go-vela/server v0.20.1-0.20230926205857-ff2e943bb81d - github.com/go-vela/types v0.20.2-0.20230926151838-42959d67d753 + github.com/go-vela/server v0.21.0-rc1 + github.com/go-vela/types v0.21.0-rc1 github.com/golang-jwt/jwt/v5 v5.0.0 github.com/google/go-cmp v0.5.9 github.com/google/go-querystring v1.1.0 @@ -37,10 +37,10 @@ require ( github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.11 // indirect golang.org/x/arch v0.3.0 // indirect - golang.org/x/crypto v0.12.0 // indirect - golang.org/x/net v0.14.0 // indirect - golang.org/x/sys v0.11.0 // indirect - golang.org/x/text v0.12.0 // indirect + golang.org/x/crypto v0.13.0 // indirect + golang.org/x/net v0.15.0 // indirect + golang.org/x/sys v0.12.0 // indirect + golang.org/x/text v0.13.0 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index c1c591b..31d0b29 100644 --- a/go.sum +++ b/go.sum @@ -30,10 +30,10 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js= github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= -github.com/go-vela/server v0.20.1-0.20230926205857-ff2e943bb81d h1:FYnItUmMYEf2ek+yXVY9tuAdN3FwAP8oUo/dAR7S+LA= -github.com/go-vela/server v0.20.1-0.20230926205857-ff2e943bb81d/go.mod h1:+NqAFyWoIZ797jYfiXBEnDZt9ECKe/9hfIEeZljUIr0= -github.com/go-vela/types v0.20.2-0.20230926151838-42959d67d753 h1:kxbNe8B1Y9wo4sk2sW5EHiysNkI+CuZOJT9b3VQhJsQ= -github.com/go-vela/types v0.20.2-0.20230926151838-42959d67d753/go.mod h1:1VyxKYQT0twymljVb83j2ljNS26mUfu/YLjQI7LQ4uQ= +github.com/go-vela/server v0.21.0-rc1 h1:3hfCqHV2vms7O4MkwAZKtq0GcXhDtseGuXxsxg3Bt9A= +github.com/go-vela/server v0.21.0-rc1/go.mod h1:lx0BjaTKWY1u45qrm4tZvL6ndDlecxHTS8+PCssBqPk= +github.com/go-vela/types v0.21.0-rc1 h1:k5XgPh4h5oVGwto7qPELoSp6Y8OL/z/z6FCjqTNZQHE= +github.com/go-vela/types v0.21.0-rc1/go.mod h1:Jn8K28uj7mACc55fkFgaIzL0q45iXydOFGEeoSeHUtQ= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= @@ -96,17 +96,17 @@ github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZ golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= -golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= -golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= -golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= +golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= +golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= +golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= +golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= -golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= diff --git a/vela/authentication.go b/vela/authentication.go index 8641e92..852e2b7 100644 --- a/vela/authentication.go +++ b/vela/authentication.go @@ -231,3 +231,14 @@ func (svc *AuthenticationService) ValidateToken() (*Response, error) { return resp, err } + +// ValidateOAuthToken makes a request to validate user oauth tokens with the Vela server. +func (svc *AuthenticationService) ValidateOAuthToken() (*Response, error) { + // set the API endpoint path we send the request to + u := "/validate-oauth" + + // attempt to validate an oauth token + resp, err := svc.client.Call("GET", u, nil, nil) + + return resp, err +} diff --git a/vela/authentication_test.go b/vela/authentication_test.go index b1b3068..ee8b056 100644 --- a/vela/authentication_test.go +++ b/vela/authentication_test.go @@ -326,3 +326,45 @@ func TestVela_Authentication_ValidateToken_NoToken(t *testing.T) { t.Error("ValidateToken response should be nil") } } + +func TestVela_Authentication_ValidateOAuthToken_200(t *testing.T) { + // setup context + gin.SetMode(gin.TestMode) + + s := httptest.NewServer(server.FakeHandler()) + c, _ := NewClient(s.URL, "", nil) + + c.Authentication.SetTokenAuth("foo") + + // run test + resp, err := c.Authentication.ValidateOAuthToken() + + if err != nil { + t.Errorf("ValidateOAuthToken returned error %v", err) + } + + if resp.StatusCode != http.StatusOK { + t.Errorf("ValidateOAuthToken returned %v, want %v", resp.StatusCode, http.StatusOK) + } +} + +func TestVela_Authentication_ValidateOAuthToken_NoToken(t *testing.T) { + // setup context + gin.SetMode(gin.TestMode) + + s := httptest.NewServer(server.FakeHandler()) + c, _ := NewClient(s.URL, "", nil) + + c.Authentication.SetTokenAuth("") + + // run test + resp, err := c.Authentication.ValidateOAuthToken() + + if err == nil { + t.Error("ValidateOAuthToken should have returned error") + } + + if resp != nil { + t.Error("ValidateOAuthToken response should be nil") + } +} diff --git a/version/version.go b/version/version.go index 394e6cc..3cff270 100644 --- a/version/version.go +++ b/version/version.go @@ -10,7 +10,7 @@ var ( // VersionMajor is for an API incompatible changes. VersionMajor int64 // VersionMinor is for functionality in a backwards-compatible manner. - VersionMinor int64 = 20 + VersionMinor int64 = 21 // VersionPatch is for backwards-compatible bug fixes. VersionPatch int64 )