ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/tomcat/util/http/TestSameSiteCookies.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/tomcat/util/http/TestSameSiteCookies.java
Status
scanned
Type
file
Name
TestSameSiteCookies.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
4597 (4.5 KB)
MD5
31dfd84cdf005775d36fd5ed86dffae1
SHA1
20b54feac5c1419bff377363260fad1d32e8b870
SHA256
378894d0c3ebc57246e96bb0fddebdafa7263cebbc9fec7801324f7b42a08574
SHA512

      
    
SHA1_git
a737b555d454bedca7f21f9ef1a4dd1256074ea4
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestSameSiteCookies.java | 4.5 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.tomcat.util.http; import org.junit.Assert; import org.junit.Test; public class TestSameSiteCookies { @Test public void testUnset() { SameSiteCookies attribute = SameSiteCookies.UNSET; Assert.assertEquals("Unset", attribute.getValue()); Assert.assertEquals(SameSiteCookies.UNSET, attribute); Assert.assertNotEquals(SameSiteCookies.NONE, attribute); Assert.assertNotEquals(SameSiteCookies.LAX, attribute); Assert.assertNotEquals(SameSiteCookies.STRICT, attribute); } @Test public void testNone() { SameSiteCookies attribute = SameSiteCookies.NONE; Assert.assertEquals("None", attribute.getValue()); Assert.assertEquals(SameSiteCookies.NONE, attribute); Assert.assertNotEquals(SameSiteCookies.UNSET, attribute); Assert.assertNotEquals(SameSiteCookies.LAX, attribute); Assert.assertNotEquals(SameSiteCookies.STRICT, attribute); } @Test public void testLax() { SameSiteCookies attribute = SameSiteCookies.LAX; Assert.assertEquals("Lax", attribute.getValue()); Assert.assertEquals(SameSiteCookies.LAX, attribute); Assert.assertNotEquals(SameSiteCookies.UNSET, attribute); Assert.assertNotEquals(SameSiteCookies.NONE, attribute); Assert.assertNotEquals(SameSiteCookies.STRICT, attribute); } @Test public void testStrict() { SameSiteCookies attribute = SameSiteCookies.STRICT; Assert.assertEquals("Strict", attribute.getValue()); Assert.assertEquals(SameSiteCookies.STRICT, attribute); Assert.assertNotEquals(SameSiteCookies.UNSET, attribute); Assert.assertNotEquals(SameSiteCookies.NONE, attribute); Assert.assertNotEquals(SameSiteCookies.LAX, attribute); } @Test public void testToValidAttribute() { Assert.assertEquals(SameSiteCookies.fromString("unset"), SameSiteCookies.UNSET); Assert.assertEquals(SameSiteCookies.fromString("Unset"), SameSiteCookies.UNSET); Assert.assertEquals(SameSiteCookies.fromString("UNSET"), SameSiteCookies.UNSET); Assert.assertEquals(SameSiteCookies.fromString("none"), SameSiteCookies.NONE); Assert.assertEquals(SameSiteCookies.fromString("None"), SameSiteCookies.NONE); Assert.assertEquals(SameSiteCookies.fromString("NONE"), SameSiteCookies.NONE); Assert.assertEquals(SameSiteCookies.fromString("lax"), SameSiteCookies.LAX); Assert.assertEquals(SameSiteCookies.fromString("Lax"), SameSiteCookies.LAX); Assert.assertEquals(SameSiteCookies.fromString("LAX"), SameSiteCookies.LAX); Assert.assertEquals(SameSiteCookies.fromString("strict"), SameSiteCookies.STRICT); Assert.assertEquals(SameSiteCookies.fromString("Strict"), SameSiteCookies.STRICT); Assert.assertEquals(SameSiteCookies.fromString("STRICT"), SameSiteCookies.STRICT); } @Test(expected = IllegalStateException.class) public void testToInvalidAttribute01() { SameSiteCookies.fromString(""); } @Test(expected = IllegalStateException.class) public void testToInvalidAttribute02() { SameSiteCookies.fromString(" "); } @Test(expected = IllegalStateException.class) public void testToInvalidAttribute03() { SameSiteCookies.fromString("Strict1"); } @Test(expected = IllegalStateException.class) public void testToInvalidAttribute04() { SameSiteCookies.fromString("foo"); } @Test(expected = IllegalStateException.class) public void testToInvalidAttribute05() { SameSiteCookies.fromString("Lax "); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
29.9
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9