Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/stale-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '30 1 * * *'
workflow_dispatch:

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v9
with:
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
days-before-stale: 40
days-before-close: 5
6 changes: 3 additions & 3 deletions config/configClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,7 @@ func (cs ConfiguredService) GetRequiredCredentialTypes(scope string) (types []st
}

func (cs ConfiguredService) GetScope(scope string) (scopeEntry ScopeEntry, err error) {
if scope != SERVICE_DEFAULT_SCOPE {
scope = cs.DefaultOidcScope
}

scopeEntry, exists := cs.ServiceScopes[scope]
if !exists {
return scopeEntry, ErrorNoSuchScope
Expand All @@ -238,6 +236,7 @@ func (cs ConfiguredService) GetScope(scope string) (scopeEntry ScopeEntry, err e
}

func (cs ConfiguredService) GetCredentials(scope string) (credentials []Credential, err error) {

scopeEntry, err := cs.GetScope(scope)
if err != nil {
return credentials, err
Expand All @@ -262,6 +261,7 @@ func (cs ConfiguredService) GetDcqlQuery(scope string) (dcql *DCQL, err error) {
}

func (cs ConfiguredService) GetCredential(scope, credentialType string) (Credential, bool) {

credentials, err := cs.GetCredentials(scope)
if err == nil {
for _, credential := range credentials {
Expand Down
35 changes: 35 additions & 0 deletions config/configClient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"testing"

"net/http"
"reflect"

"github.com/fiware/VCVerifier/logging"
"github.com/stretchr/testify/assert"
)

Expand All @@ -27,6 +29,39 @@ func readFile(filename string, t *testing.T) string {
return string(data)
}

func Test_getScope(t *testing.T) {

logging.Configure(true, "DEBUG", true, []string{})
type test struct {
testName string
testScope string
expectedEntry ScopeEntry
expectedError error
mockServiceScopes map[string]ScopeEntry
}

tests := []test{
{testName: "For an existing scope, the correct entry should be returned.", testScope: "exists", mockServiceScopes: map[string]ScopeEntry{"exists": {Credentials: []Credential{{Type: "Test"}}}, "other": {Credentials: []Credential{{Type: "Other"}}}}, expectedEntry: ScopeEntry{Credentials: []Credential{{Type: "Test"}}}},
{testName: "For an non-existing scope, an error should be returned.", testScope: "non-existing", mockServiceScopes: map[string]ScopeEntry{"exists": {Credentials: []Credential{{Type: "Test"}}}, "other": {Credentials: []Credential{{Type: "Other"}}}}, expectedError: ErrorNoSuchScope},
}
for _, tc := range tests {

t.Run(tc.testName, func(t *testing.T) {
testService := ConfiguredService{ServiceScopes: tc.mockServiceScopes}
scopeEntry, err := testService.GetScope(tc.testScope)
if tc.expectedError != err {
t.Errorf("%s - expected error %s but was %s.", tc.testName, tc.expectedError, err)
return
}
if !reflect.DeepEqual(tc.expectedEntry, scopeEntry) {
t.Errorf("%s - expected entry %s but was %s.", tc.testName, logging.PrettyPrintObject(tc.expectedEntry), logging.PrettyPrintObject(scopeEntry))
return
}
})
}

}

func Test_getServices(t *testing.T) {
mockedHttpClient := MockHttpClient{readFile("ccs_full.json", t)}
ccsClient := HttpConfigClient{mockedHttpClient, "test.com"}
Expand Down
Loading