test/jdk/sun/security/krb5/auto/NullRenewUntil.java
author ssahoo
Thu, 25 Jan 2018 05:57:22 -0800
changeset 48668 2da4a52715d8
parent 47216 71c04702a3d5
permissions -rw-r--r--
8194486: Several krb5 tests failed in Mac. Summary: Several tests failed due to improper host service Reviewed-by: weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47005
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
     1
/*
48668
2da4a52715d8 8194486: Several krb5 tests failed in Mac.
ssahoo
parents: 47216
diff changeset
     2
 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
47005
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
     4
 *
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
     7
 * published by the Free Software Foundation.
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
     8
 *
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    13
 * accompanied this code).
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    14
 *
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    18
 *
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    21
 * questions.
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    22
 */
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    23
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    24
/*
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    25
 * @test
48668
2da4a52715d8 8194486: Several krb5 tests failed in Mac.
ssahoo
parents: 47216
diff changeset
    26
 * @bug 8186576 8194486
47005
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    27
 * @summary KerberosTicket does not properly handle renewable tickets
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    28
 *          at the end of their lifetime
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    29
 * @library /test/lib
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    30
 * @compile -XDignore.symbol.file NullRenewUntil.java
48668
2da4a52715d8 8194486: Several krb5 tests failed in Mac.
ssahoo
parents: 47216
diff changeset
    31
 * @run main jdk.test.lib.FileInstaller TestHosts TestHosts
2da4a52715d8 8194486: Several krb5 tests failed in Mac.
ssahoo
parents: 47216
diff changeset
    32
 * @run main/othervm -Djdk.net.hosts.file=TestHosts
2da4a52715d8 8194486: Several krb5 tests failed in Mac.
ssahoo
parents: 47216
diff changeset
    33
 *      -Dtest.set.null.renew NullRenewUntil
47005
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    34
 */
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    35
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    36
import jdk.test.lib.Asserts;
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    37
import sun.security.krb5.Config;
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    38
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    39
import javax.security.auth.kerberos.KerberosTicket;
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    40
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    41
public class NullRenewUntil {
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    42
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    43
    public static void main(String[] args) throws Exception {
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    44
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    45
        OneKDC kdc = new OneKDC(null);
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    46
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    47
        KDC.saveConfig(OneKDC.KRB5_CONF, kdc,
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    48
                "ticket_lifetime = 10s",
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    49
                "renew_lifetime = 11s");
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    50
        Config.refresh();
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    51
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    52
        KerberosTicket ticket = Context
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    53
                .fromUserPass(OneKDC.USER, OneKDC.PASS, false).s()
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    54
                .getPrivateCredentials(KerberosTicket.class).iterator().next();
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    55
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    56
        System.out.println(ticket);
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    57
        Asserts.assertTrue(ticket.getRenewTill() != null, ticket.toString());
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    58
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    59
        Thread.sleep(2000);
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    60
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    61
        ticket.refresh();
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    62
        System.out.println(ticket);
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    63
        Asserts.assertTrue(ticket.getRenewTill() == null, ticket.toString());
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    64
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    65
        Thread.sleep(2000);
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    66
        ticket.refresh();
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    67
        System.out.println(ticket);
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    68
    }
dbfaf076da58 8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
diff changeset
    69
}