(t *testing.T)
| 74 | } |
| 75 | |
| 76 | func TestGenerateClient(t *testing.T) { |
| 77 | p := &cephv1.CephClient{ |
| 78 | ObjectMeta: metav1.ObjectMeta{Name: "client1", Namespace: "myns"}, |
| 79 | Spec: cephv1.ClientSpec{ |
| 80 | Caps: map[string]string{ |
| 81 | "osd": "allow *", |
| 82 | "mon": "allow rw", |
| 83 | "mds": "allow rwx", |
| 84 | }, |
| 85 | }, |
| 86 | } |
| 87 | |
| 88 | client, caps := genClientEntity(p) |
| 89 | assert.Equal(t, []byte(client), []byte("client.client1")) |
| 90 | assert.True(t, strings.Contains(strings.Join(caps, " "), "osd allow *")) |
| 91 | assert.True(t, strings.Contains(strings.Join(caps, " "), "mon allow rw")) |
| 92 | assert.True(t, strings.Contains(strings.Join(caps, " "), "mds allow rwx")) |
| 93 | |
| 94 | // Fail if caps are empty |
| 95 | p2 := &cephv1.CephClient{ |
| 96 | ObjectMeta: metav1.ObjectMeta{Name: "client2", Namespace: "myns"}, |
| 97 | Spec: cephv1.ClientSpec{ |
| 98 | Caps: map[string]string{ |
| 99 | "osd": "", |
| 100 | "mon": "", |
| 101 | }, |
| 102 | }, |
| 103 | } |
| 104 | |
| 105 | client, _ = genClientEntity(p2) |
| 106 | assert.Equal(t, []byte(client), []byte("client.client2")) |
| 107 | |
| 108 | // test client name override |
| 109 | p = &cephv1.CephClient{ |
| 110 | ObjectMeta: metav1.ObjectMeta{Name: "client1", Namespace: "myns"}, |
| 111 | Spec: cephv1.ClientSpec{ |
| 112 | Name: "client-override", |
| 113 | Caps: map[string]string{ |
| 114 | "osd": "allow *", |
| 115 | "mon": "allow rw", |
| 116 | "mds": "allow rwx", |
| 117 | }, |
| 118 | }, |
| 119 | } |
| 120 | |
| 121 | client, _ = genClientEntity(p) |
| 122 | assert.Equal(t, []byte(client), []byte("client.client-override")) |
| 123 | } |
| 124 | |
| 125 | func TestCephClientController(t *testing.T) { |
| 126 | ctx := context.TODO() |
nothing calls this directly
no test coverage detected