diff --git a/xos/synchronizer/tests/test_sync_secret.py b/xos/synchronizer/tests/test_sync_secret.py
new file mode 100644
index 0000000..ba7b39e
--- /dev/null
+++ b/xos/synchronizer/tests/test_sync_secret.py
@@ -0,0 +1,123 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# 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
+#
+# 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.
+
+import json
+import os
+import sys
+import unittest
+from mock import patch, PropertyMock, ANY, MagicMock
+from unit_test_common import setup_sync_unit_test
+
+class ApiException(Exception):
+    def __init__(self, status, *args, **kwargs):
+        super(ApiException, self).__init__(*args, **kwargs)
+        self.status = status
+
+def fake_init_kubernetes_client(self):
+    self.kubernetes_client = MagicMock()
+    self.v1core = MagicMock()
+    self.ApiException = ApiException
+
+class TestSyncSecret(unittest.TestCase):
+
+    def setUp(self):
+        self.unittest_setup = setup_sync_unit_test(os.path.abspath(os.path.dirname(os.path.realpath(__file__))),
+                                                   globals(),
+                                                   [("kubernetes-service", "kubernetes.proto")] )
+
+        sys.path.append(os.path.join(os.path.abspath(os.path.dirname(os.path.realpath(__file__))), "../steps"))
+
+        from sync_secret import SyncKubernetesSecret
+        self.step_class = SyncKubernetesSecret
+
+        self.service = KubernetesService()
+        self.trust_domain = TrustDomain(name="test-trust", owner=self.service)
+
+    def tearDown(self):
+        sys.path = self.unittest_setup["sys_path_save"]
+
+    def test_get_secret_exists(self):
+        with patch.object(self.step_class, "init_kubernetes_client", new=fake_init_kubernetes_client):
+            xos_secret = KubernetesSecret(trust_domain=self.trust_domain, name="test-secret")
+
+            step = self.step_class()
+            secret = MagicMock()
+            step.v1core.read_namespaced_secret.return_value = secret
+
+            result = step.get_secret(xos_secret)
+
+            self.assertEqual(result, secret)
+            step.v1core.read_namespaced_secret.assert_called_with("test-secret", "test-trust")
+
+    def test_get_secret_noexist(self):
+        with patch.object(self.step_class, "init_kubernetes_client", new=fake_init_kubernetes_client):
+            xos_secret = KubernetesSecret(trust_domain=self.trust_domain, name="test-secret")
+
+            step = self.step_class()
+            secret = MagicMock()
+            step.v1core.read_namespaced_secret.side_effect = step.ApiException(status=404)
+
+            result = step.get_secret(xos_secret)
+
+            self.assertEqual(result, None)
+
+    def test_sync_record_create(self):
+        with patch.object(self.step_class, "init_kubernetes_client", new=fake_init_kubernetes_client):
+            data = {"foo": "bar"}
+            xos_secret = KubernetesSecret(trust_domain=self.trust_domain, name="test-secret", data=json.dumps(data))
+
+            step = self.step_class()
+            step.v1core.read_namespaced_secret.side_effect = step.ApiException(status=404)
+
+            secret = MagicMock()
+            secret.metadata.self_link="1234"
+            step.v1core.create_namespaced_secret.return_value = secret
+
+            step.sync_record(xos_secret)
+
+            step.v1core.create_namespaced_secret.assert_called()
+            self.assertEqual(xos_secret.backend_handle, "1234")
+
+    def test_sync_record_update(self):
+        with patch.object(self.step_class, "init_kubernetes_client", new=fake_init_kubernetes_client):
+            data = {"foo": "bar"}
+            xos_secret = KubernetesSecret(trust_domain=self.trust_domain, name="test-secret", data=json.dumps(data))
+
+            orig_secret = MagicMock()
+            orig_secret.data = {"foo": "not_bar"}
+            orig_secret.metadata.self_link = "1234"
+
+            step = self.step_class()
+            step.v1core.read_namespaced_secret.return_value = orig_secret
+
+            new_secret = MagicMock()
+            new_secret.data = {"foo": "bar"}
+            new_secret.metadata.self_link = "1234"
+
+            step.v1core.patch_namespaced_secret.return_value = new_secret
+
+            step.sync_record(xos_secret)
+
+            self.assertEqual(step.v1core.patch_namespaced_secret.call_count, 1)
+            call_args = step.v1core.patch_namespaced_secret.call_args[0]
+            self.assertEqual(call_args[0], "test-secret")
+            self.assertEqual(call_args[1], "test-trust")
+            self.assertEqual(call_args[2].data, {"foo": "bar"})
+
+            self.assertEqual(xos_secret.backend_handle, "1234")
+
+
+if __name__ == '__main__':
+    unittest.main()
