1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.sdksandbox.audit; 17 18 import static com.google.common.truth.Truth.assertThat; 19 20 import static org.junit.Assume.assumeTrue; 21 22 import android.app.sdksandbox.testutils.DeviceSupportUtils; 23 import android.os.SELinux; 24 import android.platform.test.annotations.RequiresFlagsEnabled; 25 import android.platform.test.flag.junit.CheckFlagsRule; 26 import android.platform.test.flag.junit.DeviceFlagsValueProvider; 27 28 import androidx.test.platform.app.InstrumentationRegistry; 29 30 import com.android.sdksandbox.flags.Flags; 31 32 import org.junit.Before; 33 import org.junit.Rule; 34 import org.junit.Test; 35 import org.junit.runner.RunWith; 36 import org.junit.runners.JUnit4; 37 38 /** Tests to check some basic properties of the Sdk Sandbox audit process. */ 39 @RunWith(JUnit4.class) 40 @RequiresFlagsEnabled(Flags.FLAG_SELINUX_SDK_SANDBOX_AUDIT) 41 public class SdkSandboxAuditTest { 42 43 @Rule 44 public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule(); 45 46 @Before setUp()47 public void setUp() { 48 assumeTrue( 49 DeviceSupportUtils.isSdkSandboxSupported( 50 InstrumentationRegistry.getInstrumentation().getContext())); 51 } 52 53 @Test 54 @RequiresFlagsEnabled(Flags.FLAG_SELINUX_INPUT_SELECTOR) testSdkSandboxAuditDomain()55 public void testSdkSandboxAuditDomain() { 56 assertThat(SELinux.getContext()).contains("u:r:sdk_sandbox_audit"); 57 } 58 } 59