From dc07bbf32aa9a8db835e2f88bd9135890a403523 Mon Sep 17 00:00:00 2001 From: Kris De Volder Date: Fri, 21 Jul 2017 11:47:40 -0700 Subject: [PATCH] Missing sha1 error demoted to a warning --- .../ide/vscode/bosh/BoshConstraints.java | 6 +++--- .../ide/vscode/bosh/BoshSchemaProblems.java | 21 +++++++++++++++++++ .../ide/vscode/bosh/BoshEditorTest.java | 7 ++++++- 3 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 headless-services/bosh-language-server/src/main/java/org/springframework/ide/vscode/bosh/BoshSchemaProblems.java diff --git a/headless-services/bosh-language-server/src/main/java/org/springframework/ide/vscode/bosh/BoshConstraints.java b/headless-services/bosh-language-server/src/main/java/org/springframework/ide/vscode/bosh/BoshConstraints.java index 5c80ef16d..bb3e226ca 100644 --- a/headless-services/bosh-language-server/src/main/java/org/springframework/ide/vscode/bosh/BoshConstraints.java +++ b/headless-services/bosh-language-server/src/main/java/org/springframework/ide/vscode/bosh/BoshConstraints.java @@ -10,7 +10,7 @@ *******************************************************************************/ package org.springframework.ide.vscode.bosh; -import static org.springframework.ide.vscode.commons.yaml.reconcile.YamlSchemaProblems.MISSING_PROPERTY; +import static org.springframework.ide.vscode.bosh.BoshSchemaProblems.MISSING_SHA1_PROPERTY; import static org.springframework.ide.vscode.commons.yaml.reconcile.YamlSchemaProblems.problem; import org.springframework.ide.vscode.commons.languageserver.reconcile.IProblemCollector; @@ -24,7 +24,7 @@ import org.yaml.snakeyaml.nodes.NodeTuple; public class BoshConstraints { public static final Constraint SHA1_REQUIRED_FOR_HTTP_URL = new Constraint() { - + @Override public void verify(DynamicSchemaContext dc, Node parent, Node node, YType type, IProblemCollector problems) { NodeTuple urlProp = NodeUtil.getPropertyTuple(node, "url"); @@ -33,7 +33,7 @@ public class BoshConstraints { if (url!=null && url.startsWith("http")) { Node sha1 = NodeUtil.getProperty(node, "sha1"); if (sha1==null) { - problems.accept(problem(MISSING_PROPERTY, "'sha1' is required when the 'url' is http(s)", urlProp.getKeyNode())); + problems.accept(problem(MISSING_SHA1_PROPERTY, "'sha1' is recommended when the 'url' is http(s)", urlProp.getKeyNode())); } } } diff --git a/headless-services/bosh-language-server/src/main/java/org/springframework/ide/vscode/bosh/BoshSchemaProblems.java b/headless-services/bosh-language-server/src/main/java/org/springframework/ide/vscode/bosh/BoshSchemaProblems.java new file mode 100644 index 000000000..489a241ca --- /dev/null +++ b/headless-services/bosh-language-server/src/main/java/org/springframework/ide/vscode/bosh/BoshSchemaProblems.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2017 Pivotal, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Pivotal, Inc. - initial API and implementation + *******************************************************************************/ +package org.springframework.ide.vscode.bosh; + +import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity; +import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemType; +import org.springframework.ide.vscode.commons.yaml.reconcile.YamlSchemaProblems; + +public class BoshSchemaProblems { + + public static final ProblemType MISSING_SHA1_PROPERTY = YamlSchemaProblems.problemType("MISSING_SHA1_PROPERTY", ProblemSeverity.WARNING); + +} diff --git a/headless-services/bosh-language-server/src/test/java/org/springframework/ide/vscode/bosh/BoshEditorTest.java b/headless-services/bosh-language-server/src/test/java/org/springframework/ide/vscode/bosh/BoshEditorTest.java index 30de9531d..eaf89436d 100644 --- a/headless-services/bosh-language-server/src/test/java/org/springframework/ide/vscode/bosh/BoshEditorTest.java +++ b/headless-services/bosh-language-server/src/test/java/org/springframework/ide/vscode/bosh/BoshEditorTest.java @@ -18,6 +18,8 @@ import java.io.IOException; import java.util.concurrent.TimeoutException; import org.eclipse.lsp4j.CompletionItem; +import org.eclipse.lsp4j.Diagnostic; +import org.eclipse.lsp4j.DiagnosticSeverity; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; @@ -276,10 +278,13 @@ public class BoshEditorTest { "#x" ); editor.assertProblems( - "url|'sha1' is required when the 'url' is http(s)", + "url|'sha1' is recommended when the 'url' is http(s)", "proto|Url scheme must be one of [http, https, file]", "x|are required" ); + Diagnostic missingSha1Problem = editor.assertProblem("url"); + assertContains("'sha1' is recommended", missingSha1Problem.getMessage()); + assertEquals(DiagnosticSeverity.Warning, missingSha1Problem.getSeverity()); } @Test public void releasesBlockPropertyReconcileAndHovers() throws Exception {