Skip to content

Commit

Permalink
Include QoP and add Github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
jake-scott authored and jake-desco committed Aug 27, 2024
1 parent 5edceeb commit c1e5ea9
Show file tree
Hide file tree
Showing 10 changed files with 186 additions and 14 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
open-pull-requests-limit: 99
22 changes: 22 additions & 0 deletions .github/scripts/gofmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

TMPDIR=$(mktemp -d)

cleanup() {
rm -rf "${TMPDIR}"
}

trap cleanup EXIT


gofmt -l -d . >${TMPDIR}/fmt.out

if [ -s ${TMPDIR}/fmt.out ];
then
echo "The following files are not formatted correctly:"
cat ${TMPDIR}/fmt.out
exit 1
fi

echo "gofmt-output=gofmt step successful" >>$GITHUB_OUTPUT
exit 0
57 changes: 57 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Checks

on:
push:
pull_request:

permissions:
contents: read

jobs:

consistency-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go 1.22
uses: actions/setup-go@v5
with:
go-version: 1.22.x

- name: Code format check
run: ./.github/scripts/gofmt

- uses: dominikh/staticcheck-action@v1.3.1
with:
working-directory: v3

basic-tests:
name: Basic tests
strategy:
matrix:
# os: ['windows-latest', 'ubuntu-latest']
os: ['ubuntu-latest']
go-version: ['1.21.x', '1.22.x' ]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4

- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Generate test includes
run: |
echo pkgs=$(cd v3 && go list ./... | grep -v /examples/) >> "$GITHUB_ENV"
- name: Run tests
run: cd v3 && go test $pkgs -count 100 -coverprofile=../cover.out -covermode=atomic

- name: Check test coverage
uses: vladopajic/go-test-coverage@v2
with:
config: ./.testcoverage.yml
55 changes: 55 additions & 0 deletions .github/workflows/coverage-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
concurrency:
group: "pages"
cancel-in-progress: true

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go '1.22.x'
uses: actions/setup-go@v5
with:
go-version: '1.22.x'
- name: Generate test includes
run: |
echo pkgs=$(go list ./... | grep -v /examples/) >> "$GITHUB_ENV"
- name: Generate coverage profile
run: |
go test $pkgs -count 100 -coverprofile=./cover.out -covermode=atomic
- name: Generate report
run: |
mkdir -p ./coverage
go tool cover -html=cover.out -o ./coverage/coverage.html
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./coverage
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ examples/go/gss-server-go
# Dependency directories (remove the comment below to include it)
# vendor/
#
#
toolbin/
27 changes: 27 additions & 0 deletions .testcoverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# (mandatory)
# Path to coverprofile file (output of `go test -coverprofile` command).
#
# For cases where there are many coverage profiles, such as when running
# unit tests and integration tests separately, you can combine all those
# profiles into one. In this case, the profile should have a comma-separated list
# of profile files, e.g., 'cover_unit.out,cover_integration.out'.
profile: cover.out

# (optional; but recommended to set)
# When specified reported file paths will not contain local prefix in the output
local-prefix: "github.com/jake-scott/go-functional"

# Holds coverage thresholds percentages, values should be in range [0-100]
threshold:
# (optional; default 0)
# The minimum coverage that each file should have
file: 75

# (optional; default 0)
# The minimum coverage that each package should have
package: 85

# (optional; default 0)
# The minimum total coverage project should have
total: 95

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $(src_dir)/mechs_gen.go: build-tools/gen-gss-mech-oids.go $(src_dir)/mechs.go
.PHONY: test
test:
cd $(src_dir) && ../scripts/gofmt
${GO} test ./... -coverprofile=./cover.out -covermode=atomic
cd $(src_dir) && ${GO} test ./... -coverprofile=./cover.out -covermode=atomic


.PHONY: lint
Expand Down
6 changes: 3 additions & 3 deletions v3/names_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestNtOid(t *testing.T) {
assert.Equal(Oid{0x2a, 0x86, 0x48, 0x86, 0xf7, 0x12, 0x01, 0x02, 0x01, 0x01}, oid)

badNt := GssNameType(100)
assert.PanicsWithValue(ErrBadNameType, func() { badNt.Oid() })
assert.PanicsWithValue(ErrBadNameType, func() { _ = badNt.Oid() })
}

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

badNt := GssNameType(100)
assert.PanicsWithValue(ErrBadNameType, func() { badNt.OidString() })
assert.PanicsWithValue(ErrBadNameType, func() { _ = badNt.OidString() })
}

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

badNt := GssNameType(100)
assert.PanicsWithValue(ErrBadNameType, func() { badNt.String() })
assert.PanicsWithValue(ErrBadNameType, func() { _ = badNt.String() })
}

func TestNameFromOid(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions v3/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ func NewProvider(name string) Provider {
return f()
}

type QoP uint

type InitSecContextOptions struct {
Credential Credential
Mech GssMech
Expand Down
20 changes: 10 additions & 10 deletions v3/seccontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ type SecContextInfo struct {
}

type SecContext interface {
Delete() ([]byte, error) // RFC 2743 § 2.2.3
ProcessToken([]byte) error // RFC 2743 § 2.2.4
ExpiresAt() (*time.Time, error) // RFC 2743 § 2.2.5
Inquire() (*SecContextInfo, error) // RFC 2743 § 2.2.6
WrapSizeLimit(bool, uint) (uint, error) // RFC 2743 § 2.2.7
Export() ([]byte, error) // RFC 2743 § 2.2.8
GetMIC([]byte) ([]byte, error) // RFC 2743 § 2.3.1
VerifyMIC([]byte, []byte) error // RFC 2743 § 2.3.2
Wrap([]byte, bool) ([]byte, bool, error) // RFC 2743 § 2.3.3
Unwrap([]byte) ([]byte, bool, error) // RFC 2743 § 2.3.4
Delete() ([]byte, error) // RFC 2743 § 2.2.3
ProcessToken([]byte) error // RFC 2743 § 2.2.4
ExpiresAt() (*time.Time, error) // RFC 2743 § 2.2.5
Inquire() (*SecContextInfo, error) // RFC 2743 § 2.2.6
WrapSizeLimit(bool, uint, QoP) (uint, error) // RFC 2743 § 2.2.7
Export() ([]byte, error) // RFC 2743 § 2.2.8
GetMIC([]byte, QoP) ([]byte, error) // RFC 2743 § 2.3.1
VerifyMIC([]byte, []byte) (QoP, error) // RFC 2743 § 2.3.2
Wrap([]byte, bool, QoP) ([]byte, bool, error) // RFC 2743 § 2.3.3
Unwrap([]byte) ([]byte, bool, QoP, error) // RFC 2743 § 2.3.4

ContinueNeeded() bool
Continue([]byte) ([]byte, error)
Expand Down

0 comments on commit c1e5ea9

Please sign in to comment.