mirror of
https://github.com/wneessen/go-hibp.git
synced 2024-11-22 12:50:50 +01:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
43c99d2889
7 changed files with 45 additions and 9 deletions
6
.github/workflows/codecov.yml
vendored
6
.github/workflows/codecov.yml
vendored
|
@ -16,13 +16,15 @@ on:
|
||||||
- 'go.*'
|
- 'go.*'
|
||||||
- '.github/**'
|
- '.github/**'
|
||||||
- 'codecov.yml'
|
- 'codecov.yml'
|
||||||
|
env:
|
||||||
|
HIBP_API_KEY: ${{ secrets.HIBP_API_KEY }}
|
||||||
jobs:
|
jobs:
|
||||||
run:
|
run:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
os: [ubuntu-latest]
|
||||||
go: [1.15, 1.16, 1.17, 1.18]
|
go: [1.18]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@master
|
||||||
|
|
32
.github/workflows/codecov_testonly.yml
vendored
Normal file
32
.github/workflows/codecov_testonly.yml
vendored
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
name: Codecov workflow
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- '**.go'
|
||||||
|
- 'go.*'
|
||||||
|
- '.github/**'
|
||||||
|
- 'codecov.yml'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- '**.go'
|
||||||
|
- 'go.*'
|
||||||
|
- '.github/**'
|
||||||
|
- 'codecov.yml'
|
||||||
|
jobs:
|
||||||
|
run:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
|
go: [1.15, 1.16, 1.17, 1.18]
|
||||||
|
steps:
|
||||||
|
- name: Checkout Code
|
||||||
|
uses: actions/checkout@master
|
||||||
|
|
||||||
|
- name: Run Tests
|
||||||
|
run: |
|
||||||
|
go test -v -race --coverprofile=coverage.coverprofile --covermode=atomic .
|
2
.github/workflows/sonarqube.yml
vendored
2
.github/workflows/sonarqube.yml
vendored
|
@ -3,6 +3,8 @@ on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main # or the name of your main branch
|
- main # or the name of your main branch
|
||||||
|
env:
|
||||||
|
HIBP_API_KEY: ${{ secrets.HIBP_API_KEY }}
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build
|
name: Build
|
||||||
|
|
|
@ -41,7 +41,7 @@ func TestBreachesWithDomain(t *testing.T) {
|
||||||
{"example.com is not breached", "example.com", false},
|
{"example.com is not breached", "example.com", false},
|
||||||
}
|
}
|
||||||
|
|
||||||
hc := New()
|
hc := New(WithRateLimitSleep())
|
||||||
for _, tc := range testTable {
|
for _, tc := range testTable {
|
||||||
t.Run(tc.testName, func(t *testing.T) {
|
t.Run(tc.testName, func(t *testing.T) {
|
||||||
breachList, _, err := hc.BreachApi.Breaches(WithDomain(tc.domain))
|
breachList, _, err := hc.BreachApi.Breaches(WithDomain(tc.domain))
|
||||||
|
@ -80,7 +80,7 @@ func TestBreachesWithoutUnverified(t *testing.T) {
|
||||||
{"xiaomi.cn is breached but not verified", "xiaomi.cn", true, false},
|
{"xiaomi.cn is breached but not verified", "xiaomi.cn", true, false},
|
||||||
}
|
}
|
||||||
|
|
||||||
hc := New()
|
hc := New(WithRateLimitSleep())
|
||||||
for _, tc := range testTable {
|
for _, tc := range testTable {
|
||||||
t.Run(tc.testName, func(t *testing.T) {
|
t.Run(tc.testName, func(t *testing.T) {
|
||||||
breachList, _, err := hc.BreachApi.Breaches(WithDomain(tc.domain), WithoutUnverified())
|
breachList, _, err := hc.BreachApi.Breaches(WithDomain(tc.domain), WithoutUnverified())
|
||||||
|
@ -108,7 +108,7 @@ func TestBreachByName(t *testing.T) {
|
||||||
{"Example is not a known breach", "Example", false, true},
|
{"Example is not a known breach", "Example", false, true},
|
||||||
}
|
}
|
||||||
|
|
||||||
hc := New()
|
hc := New(WithRateLimitSleep())
|
||||||
for _, tc := range testTable {
|
for _, tc := range testTable {
|
||||||
t.Run(tc.testName, func(t *testing.T) {
|
t.Run(tc.testName, func(t *testing.T) {
|
||||||
breachDetails, _, err := hc.BreachApi.BreachByName(tc.breachName)
|
breachDetails, _, err := hc.BreachApi.BreachByName(tc.breachName)
|
||||||
|
@ -159,7 +159,7 @@ func TestBreachedAccount(t *testing.T) {
|
||||||
if apiKey == "" {
|
if apiKey == "" {
|
||||||
t.SkipNow()
|
t.SkipNow()
|
||||||
}
|
}
|
||||||
hc := New(WithApiKey(apiKey))
|
hc := New(WithApiKey(apiKey), WithRateLimitSleep())
|
||||||
for _, tc := range testTable {
|
for _, tc := range testTable {
|
||||||
t.Run(tc.testName, func(t *testing.T) {
|
t.Run(tc.testName, func(t *testing.T) {
|
||||||
breachDetails, _, err := hc.BreachApi.BreachedAccount(
|
breachDetails, _, err := hc.BreachApi.BreachedAccount(
|
||||||
|
|
|
@ -2,7 +2,7 @@ coverage:
|
||||||
status:
|
status:
|
||||||
project:
|
project:
|
||||||
default:
|
default:
|
||||||
target: 80%
|
target: 50%
|
||||||
threshold: 5%
|
threshold: 5%
|
||||||
base: auto
|
base: auto
|
||||||
if_ci_failed: error
|
if_ci_failed: error
|
||||||
|
|
|
@ -44,7 +44,7 @@ func TestNewWithPwnedPadding(t *testing.T) {
|
||||||
// TestNewWithApiKey tests the New() function with the API key set
|
// TestNewWithApiKey tests the New() function with the API key set
|
||||||
func TestNewWithApiKey(t *testing.T) {
|
func TestNewWithApiKey(t *testing.T) {
|
||||||
apiKey := os.Getenv("HIBP_API_KEY")
|
apiKey := os.Getenv("HIBP_API_KEY")
|
||||||
hc := New(WithApiKey(apiKey))
|
hc := New(WithApiKey(apiKey), WithRateLimitSleep())
|
||||||
if hc.ak != apiKey {
|
if hc.ak != apiKey {
|
||||||
t.Errorf("hibp client API key was not set properly. Expected %s, got: %s",
|
t.Errorf("hibp client API key was not set properly. Expected %s, got: %s",
|
||||||
apiKey, hc.ak)
|
apiKey, hc.ak)
|
||||||
|
|
|
@ -22,7 +22,7 @@ func TestPasteAccount(t *testing.T) {
|
||||||
if apiKey == "" {
|
if apiKey == "" {
|
||||||
t.SkipNow()
|
t.SkipNow()
|
||||||
}
|
}
|
||||||
hc := New(WithApiKey(apiKey))
|
hc := New(WithApiKey(apiKey), WithRateLimitSleep())
|
||||||
for _, tc := range testTable {
|
for _, tc := range testTable {
|
||||||
t.Run(tc.testName, func(t *testing.T) {
|
t.Run(tc.testName, func(t *testing.T) {
|
||||||
pasteDetails, _, err := hc.PasteApi.PastedAccount(tc.accountName)
|
pasteDetails, _, err := hc.PasteApi.PastedAccount(tc.accountName)
|
||||||
|
|
Loading…
Reference in a new issue