Skip to content

Commit

Permalink
[Removed] unnecessary warning for imports without token (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiashanel authored Dec 16, 2020
1 parent 2e78446 commit 03232ed
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 43 deletions.
5 changes: 1 addition & 4 deletions v2/imports.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2019 The NATS Authors
* Copyright 2018-2020 The NATS Authors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -118,10 +118,7 @@ func (i *Import) Validate(actPubKey string, vr *ValidationResults) {
vr.AddError("activation token doesn't match account it is being included in, %q", i.Subject)
}
act.validateWithTimeChecks(vr, false)
} else {
vr.AddWarning("no activation provided for import %s", i.Subject)
}

}

// Imports is a list of import structs
Expand Down
55 changes: 18 additions & 37 deletions v2/imports_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 The NATS Authors
* Copyright 2018-2020 The NATS Authors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -34,24 +34,16 @@ func TestImportValidation(t *testing.T) {
vr := CreateValidationResults()
i.Validate("", vr)

if vr.IsEmpty() {
t.Errorf("imports without token or url should warn the caller")
}

if vr.IsBlocking(true) {
t.Errorf("imports without token or url should not be blocking")
if !vr.IsEmpty() {
t.Errorf("imports should not generate an issue")
}

i.Type = Service
vr = CreateValidationResults()
i.Validate("", vr)

if vr.IsEmpty() {
t.Errorf("imports without token or url should warn the caller")
}

if vr.IsBlocking(true) {
t.Errorf("imports without token or url should not be blocking")
if !vr.IsEmpty() {
t.Errorf("imports should not generate an issue")
}

activation := NewActivationClaims(akp)
Expand Down Expand Up @@ -203,24 +195,16 @@ func TestInvalidImportTokenValuesValidation(t *testing.T) {
vr := CreateValidationResults()
i.Validate("", vr)

if vr.IsEmpty() {
t.Errorf("imports without token or url should warn the caller")
}

if vr.IsBlocking(true) {
t.Errorf("imports without token or url should not be blocking")
if !vr.IsEmpty() {
t.Errorf("imports should not generate an issue")
}

i.Type = Service
vr = CreateValidationResults()
i.Validate("", vr)

if vr.IsEmpty() {
t.Errorf("imports without token or url should warn the caller")
}

if vr.IsBlocking(true) {
t.Errorf("imports without token or url should not be blocking")
if !vr.IsEmpty() {
t.Errorf("imports should not generate an issue")
}

activation := NewActivationClaims(akp)
Expand Down Expand Up @@ -263,8 +247,8 @@ func TestMissingAccountInImport(t *testing.T) {
vr := CreateValidationResults()
i.Validate("", vr)

if len(vr.Issues) != 2 {
t.Errorf("imports without token or url should warn the caller, as should missing account")
if len(vr.Issues) != 1 {
t.Errorf("expected only one issue")
}

if vr.IsBlocking(true) {
Expand All @@ -280,8 +264,8 @@ func TestServiceImportWithWildcard(t *testing.T) {
vr := CreateValidationResults()
i.Validate("", vr)

if len(vr.Issues) != 2 {
t.Errorf("imports without token or url should warn the caller, as should wildcard service")
if len(vr.Issues) != 1 {
t.Errorf("expected only one issue")
}

if !vr.IsBlocking(true) {
Expand All @@ -295,8 +279,8 @@ func TestStreamImportWithWildcardPrefix(t *testing.T) {
vr := CreateValidationResults()
i.Validate("", vr)

if len(vr.Issues) != 3 {
t.Errorf("should have registered 3 issues with this import, got %d", len(vr.Issues))
if len(vr.Issues) != 2 {
t.Errorf("should have registered 2 issues with this import, got %d", len(vr.Issues))
}

if !vr.IsBlocking(true) {
Expand All @@ -312,7 +296,7 @@ func TestStreamImportInformationSharing(t *testing.T) {
vr := CreateValidationResults()
i.Validate("", vr)

if len(vr.Issues) != 2 {
if len(vr.Issues) != 1 {
t.Errorf("should have registered 1 issues with this import, got %d", len(vr.Issues))
}
if !vr.IsBlocking(true) {
Expand All @@ -323,12 +307,9 @@ func TestStreamImportInformationSharing(t *testing.T) {
vr = CreateValidationResults()
i.Validate("", vr)

if len(vr.Issues) != 1 {
if len(vr.Issues) != 0 {
t.Errorf("should have registered 0 issues with this import, got %d", len(vr.Issues))
}
if vr.IsBlocking(true) {
t.Fatalf("remaining issue is not expected to be blocking")
}
}

func TestImportsValidation(t *testing.T) {
Expand All @@ -343,7 +324,7 @@ func TestImportsValidation(t *testing.T) {
vr := CreateValidationResults()
imports.Validate("", vr)

if len(vr.Issues) != 3 {
if len(vr.Issues) != 1 {
t.Errorf("imports without token or url should warn the caller x2, wildcard service as well")
}

Expand Down
3 changes: 1 addition & 2 deletions v2/revocation_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestRevocationCompact(t *testing.T) {
a.Revocations.Revoke(keys[2], now.Add(-time.Second))
// no change expected - there's no
deleted := a.Revocations.MaybeCompact()
if len(a.Revocations) != 3 || deleted != nil{
if len(a.Revocations) != 3 || deleted != nil {
t.Error("expected 3 revocations")
}
// should delete the first key
Expand All @@ -52,4 +52,3 @@ func TestRevocationCompact(t *testing.T) {
t.Error("didn't revoke expected entries")
}
}

0 comments on commit 03232ed

Please sign in to comment.