@@ -888,7 +888,7 @@ describe("deviceHandlers", () => {
888888 ) ;
889889 } ) ;
890890
891- it ( "allows non-device operator sessions to approve operator roles within caller scopes" , async ( ) => {
891+ it ( "allows shared-auth operator sessions to approve operator roles within caller scopes" , async ( ) => {
892892 getPendingDevicePairingMock . mockResolvedValue ( {
893893 requestId : "req-1" ,
894894 deviceId : "device-2" ,
@@ -914,7 +914,7 @@ describe("deviceHandlers", () => {
914914 const opts = createOptions (
915915 "device.pair.approve" ,
916916 { requestId : "req-1" } ,
917- { client : createClient ( [ "operator.pairing" ] ) } ,
917+ { client : createClient ( [ "operator.pairing" ] , "device-1" , { isDeviceTokenAuth : false } ) } ,
918918 ) ;
919919
920920 await deviceHandlers [ "device.pair.approve" ] ( opts ) ;
@@ -941,19 +941,40 @@ describe("deviceHandlers", () => {
941941 ) ;
942942 } ) ;
943943
944+ it ( "rejects approving node roles for the caller device without admin scope" , async ( ) => {
945+ getPendingDevicePairingMock . mockResolvedValue ( {
946+ requestId : "req-1" ,
947+ deviceId : " device-1 " ,
948+ publicKey : "pk-1" ,
949+ role : "node" ,
950+ roles : [ "node" ] ,
951+ ts : 100 ,
952+ } ) ;
953+ const opts = createOptions (
954+ "device.pair.approve" ,
955+ { requestId : "req-1" } ,
956+ { client : createClient ( [ "operator.pairing" ] , "device-1" , { isDeviceTokenAuth : true } ) } ,
957+ ) ;
958+
959+ await deviceHandlers [ "device.pair.approve" ] ( opts ) ;
960+
961+ expect ( approveDevicePairingMock ) . not . toHaveBeenCalled ( ) ;
962+ expectRespondedErrorMessage ( opts , "device pairing approval denied" ) ;
963+ } ) ;
964+
944965 it ( "rejects approving node roles from non-admin shared-auth sessions" , async ( ) => {
945966 getPendingDevicePairingMock . mockResolvedValue ( {
946967 requestId : "req-1" ,
947- deviceId : "device-2 " ,
948- publicKey : "pk-2 " ,
968+ deviceId : "device-1 " ,
969+ publicKey : "pk-1 " ,
949970 role : "node" ,
950971 roles : [ "node" ] ,
951972 ts : 100 ,
952973 } ) ;
953974 const opts = createOptions (
954975 "device.pair.approve" ,
955976 { requestId : "req-1" } ,
956- { client : createClient ( [ "operator.pairing" ] ) } ,
977+ { client : createClient ( [ "operator.pairing" ] , "device-1" , { isDeviceTokenAuth : false } ) } ,
957978 ) ;
958979
959980 await deviceHandlers [ "device.pair.approve" ] ( opts ) ;
@@ -998,27 +1019,6 @@ describe("deviceHandlers", () => {
9981019 expectRespondedErrorMessage ( opts , "device pairing approval denied" ) ;
9991020 } ) ;
10001021
1001- it ( "rejects approving node roles for the caller device without admin scope" , async ( ) => {
1002- getPendingDevicePairingMock . mockResolvedValue ( {
1003- requestId : "req-1" ,
1004- deviceId : " device-1 " ,
1005- publicKey : "pk-1" ,
1006- role : "node" ,
1007- roles : [ "node" ] ,
1008- ts : 100 ,
1009- } ) ;
1010- const opts = createOptions (
1011- "device.pair.approve" ,
1012- { requestId : "req-1" } ,
1013- { client : createClient ( [ "operator.pairing" ] , "device-1" , { isDeviceTokenAuth : true } ) } ,
1014- ) ;
1015-
1016- await deviceHandlers [ "device.pair.approve" ] ( opts ) ;
1017-
1018- expect ( approveDevicePairingMock ) . not . toHaveBeenCalled ( ) ;
1019- expectRespondedErrorMessage ( opts , "device pairing approval denied" ) ;
1020- } ) ;
1021-
10221022 it ( "rejects rejecting another device from a non-admin device session" , async ( ) => {
10231023 getPendingDevicePairingMock . mockResolvedValue ( {
10241024 requestId : "req-2" ,
0 commit comments