Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Removed] unnecessary warning for imports without token #130

Merged
merged 1 commit into from
Dec 16, 2020
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
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")
}
}