Skip to content

Commit 722f503

Browse files
committed
Include QoP and add Github workflows
1 parent 53990a0 commit 722f503

File tree

10 files changed

+186
-14
lines changed

10 files changed

+186
-14
lines changed

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
open-pull-requests-limit: 99

.github/scripts/gofmt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
TMPDIR=$(mktemp -d)
4+
5+
cleanup() {
6+
rm -rf "${TMPDIR}"
7+
}
8+
9+
trap cleanup EXIT
10+
11+
12+
gofmt -l -d . >${TMPDIR}/fmt.out
13+
14+
if [ -s ${TMPDIR}/fmt.out ];
15+
then
16+
echo "The following files are not formatted correctly:"
17+
cat ${TMPDIR}/fmt.out
18+
exit 1
19+
fi
20+
21+
echo "gofmt-output=gofmt step successful" >>$GITHUB_OUTPUT
22+
exit 0

.github/workflows/checks.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Checks
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
12+
consistency-checks:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Go 1.22
18+
uses: actions/setup-go@v5
19+
with:
20+
go-version: 1.22.x
21+
22+
- name: Code format check
23+
run: ./.github/scripts/gofmt
24+
25+
- uses: dominikh/staticcheck-action@v1.3.1
26+
with:
27+
working-directory: v3
28+
29+
basic-tests:
30+
name: Basic tests
31+
strategy:
32+
matrix:
33+
# os: ['windows-latest', 'ubuntu-latest']
34+
os: ['ubuntu-latest']
35+
go-version: ['1.21.x', '1.22.x' ]
36+
37+
runs-on: ${{ matrix.os }}
38+
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- name: Set up Go ${{ matrix.go-version }}
43+
uses: actions/setup-go@v5
44+
with:
45+
go-version: ${{ matrix.go-version }}
46+
47+
- name: Generate test includes
48+
run: |
49+
echo pkgs=$(cd v3 && go list ./... | grep -v /examples/) >> "$GITHUB_ENV"
50+
51+
- name: Run tests
52+
run: cd v3 && go test $pkgs -count 100 -coverprofile=../cover.out -covermode=atomic
53+
54+
- name: Check test coverage
55+
uses: vladopajic/go-test-coverage@v2
56+
with:
57+
config: ./.testcoverage.yml

.github/workflows/coverage-report.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Simple workflow for deploying static content to GitHub Pages
2+
name: Deploy static content to Pages
3+
4+
on:
5+
# Runs on pushes targeting the default branch
6+
push:
7+
branches: ["main"]
8+
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19+
concurrency:
20+
group: "pages"
21+
cancel-in-progress: true
22+
23+
jobs:
24+
# Single deploy job since we're just deploying
25+
deploy:
26+
environment:
27+
name: github-pages
28+
url: ${{ steps.deployment.outputs.page_url }}
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
- name: Set up Go '1.22.x'
34+
uses: actions/setup-go@v5
35+
with:
36+
go-version: '1.22.x'
37+
- name: Generate test includes
38+
run: |
39+
echo pkgs=$(go list ./... | grep -v /examples/) >> "$GITHUB_ENV"
40+
- name: Generate coverage profile
41+
run: |
42+
go test $pkgs -count 100 -coverprofile=./cover.out -covermode=atomic
43+
- name: Generate report
44+
run: |
45+
mkdir -p ./coverage
46+
go tool cover -html=cover.out -o ./coverage/coverage.html
47+
- name: Setup Pages
48+
uses: actions/configure-pages@v5
49+
- name: Upload artifact
50+
uses: actions/upload-pages-artifact@v3
51+
with:
52+
path: ./coverage
53+
- name: Deploy to GitHub Pages
54+
id: deployment
55+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ examples/go/gss-server-go
2121
# Dependency directories (remove the comment below to include it)
2222
# vendor/
2323
#
24+
#
25+
toolbin/

.testcoverage.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# (mandatory)
2+
# Path to coverprofile file (output of `go test -coverprofile` command).
3+
#
4+
# For cases where there are many coverage profiles, such as when running
5+
# unit tests and integration tests separately, you can combine all those
6+
# profiles into one. In this case, the profile should have a comma-separated list
7+
# of profile files, e.g., 'cover_unit.out,cover_integration.out'.
8+
profile: cover.out
9+
10+
# (optional; but recommended to set)
11+
# When specified reported file paths will not contain local prefix in the output
12+
local-prefix: "github.com/jake-scott/go-functional"
13+
14+
# Holds coverage thresholds percentages, values should be in range [0-100]
15+
threshold:
16+
# (optional; default 0)
17+
# The minimum coverage that each file should have
18+
file: 75
19+
20+
# (optional; default 0)
21+
# The minimum coverage that each package should have
22+
package: 85
23+
24+
# (optional; default 0)
25+
# The minimum total coverage project should have
26+
total: 95
27+

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ $(src_dir)/mechs_gen.go: build-tools/gen-gss-mech-oids.go $(src_dir)/mechs.go
2929
.PHONY: test
3030
test:
3131
cd $(src_dir) && ../scripts/gofmt
32-
${GO} test ./... -coverprofile=./cover.out -covermode=atomic
32+
cd $(src_dir) && ${GO} test ./... -coverprofile=./cover.out -covermode=atomic
3333

3434

3535
.PHONY: lint

v3/names_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestNtOid(t *testing.T) {
2020
assert.Equal(Oid{0x2a, 0x86, 0x48, 0x86, 0xf7, 0x12, 0x01, 0x02, 0x01, 0x01}, oid)
2121

2222
badNt := GssNameType(100)
23-
assert.PanicsWithValue(ErrBadNameType, func() { badNt.Oid() })
23+
assert.PanicsWithValue(ErrBadNameType, func() { _ = badNt.Oid() })
2424
}
2525

2626
func TestNtOidString(t *testing.T) {
@@ -36,7 +36,7 @@ func TestNtOidString(t *testing.T) {
3636
assert.Equal("1.2.840.113554.1.2.1.1", oid)
3737

3838
badNt := GssNameType(100)
39-
assert.PanicsWithValue(ErrBadNameType, func() { badNt.OidString() })
39+
assert.PanicsWithValue(ErrBadNameType, func() { _ = badNt.OidString() })
4040
}
4141

4242
func TestNtString(t *testing.T) {
@@ -52,7 +52,7 @@ func TestNtString(t *testing.T) {
5252
assert.Equal("GSS_NT_USER_NAME", oid)
5353

5454
badNt := GssNameType(100)
55-
assert.PanicsWithValue(ErrBadNameType, func() { badNt.String() })
55+
assert.PanicsWithValue(ErrBadNameType, func() { _ = badNt.String() })
5656
}
5757

5858
func TestNameFromOid(t *testing.T) {

v3/provider.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ func NewProvider(name string) Provider {
4040
return f()
4141
}
4242

43+
type QoP uint
44+
4345
type InitSecContextOptions struct {
4446
Credential Credential
4547
Mech GssMech

v3/seccontext.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ type SecContextInfo struct {
2020
}
2121

2222
type SecContext interface {
23-
Delete() ([]byte, error) // RFC 2743 § 2.2.3
24-
ProcessToken([]byte) error // RFC 2743 § 2.2.4
25-
ExpiresAt() (*time.Time, error) // RFC 2743 § 2.2.5
26-
Inquire() (*SecContextInfo, error) // RFC 2743 § 2.2.6
27-
WrapSizeLimit(bool, uint) (uint, error) // RFC 2743 § 2.2.7
28-
Export() ([]byte, error) // RFC 2743 § 2.2.8
29-
GetMIC([]byte) ([]byte, error) // RFC 2743 § 2.3.1
30-
VerifyMIC([]byte, []byte) error // RFC 2743 § 2.3.2
31-
Wrap([]byte, bool) ([]byte, bool, error) // RFC 2743 § 2.3.3
32-
Unwrap([]byte) ([]byte, bool, error) // RFC 2743 § 2.3.4
23+
Delete() ([]byte, error) // RFC 2743 § 2.2.3
24+
ProcessToken([]byte) error // RFC 2743 § 2.2.4
25+
ExpiresAt() (*time.Time, error) // RFC 2743 § 2.2.5
26+
Inquire() (*SecContextInfo, error) // RFC 2743 § 2.2.6
27+
WrapSizeLimit(bool, uint, QoP) (uint, error) // RFC 2743 § 2.2.7
28+
Export() ([]byte, error) // RFC 2743 § 2.2.8
29+
GetMIC([]byte, QoP) ([]byte, error) // RFC 2743 § 2.3.1
30+
VerifyMIC([]byte, []byte) (QoP, error) // RFC 2743 § 2.3.2
31+
Wrap([]byte, bool, QoP) ([]byte, bool, error) // RFC 2743 § 2.3.3
32+
Unwrap([]byte) ([]byte, bool, QoP, error) // RFC 2743 § 2.3.4
3333

3434
ContinueNeeded() bool
3535
Continue([]byte) ([]byte, error)

0 commit comments

Comments
 (0)